[PATCH] D31168: Set FMF for -ffp-contract=fast
rjmccall added a comment. I may have missed earlier steps in this patch series. Why is this being done statefully and contextually in the IRBuilder instead of just applying the flag from the BinaryOperator to the instruction when building it? It's not like ScalarExprEmitter doesn't know that it's building an FMul. https://reviews.llvm.org/D31168 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31575: [clang-format] Use configured IndentWidth instead of 2
djasper accepted this revision. djasper added a comment. This revision is now accepted and ready to land. looks good https://reviews.llvm.org/D31575 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r299321 - [X86] Add __extension__ to f16c macro intrinsics to suppress warnings about compound literals when compiled for with earlier language standards enabled.
Author: ctopper Date: Sat Apr 1 22:02:53 2017 New Revision: 299321 URL: http://llvm.org/viewvc/llvm-project?rev=299321&view=rev Log: [X86] Add __extension__ to f16c macro intrinsics to suppress warnings about compound literals when compiled for with earlier language standards enabled. Fixes PR32491. Modified: cfe/trunk/lib/Headers/f16cintrin.h Modified: cfe/trunk/lib/Headers/f16cintrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/f16cintrin.h?rev=299321&r1=299320&r2=299321&view=diff == --- cfe/trunk/lib/Headers/f16cintrin.h (original) +++ cfe/trunk/lib/Headers/f16cintrin.h Sat Apr 1 22:02:53 2017 @@ -72,9 +72,9 @@ _cvtsh_ss(unsigned short __a) ///011: Truncate \n ///1XX: Use MXCSR.RC for rounding /// \returns The converted 16-bit half-precision float value. -#define _cvtss_sh(a, imm) \ - ((unsigned short)(((__v8hi)__builtin_ia32_vcvtps2ph((__v4sf){a, 0, 0, 0}, \ - (imm)))[0])) +#define _cvtss_sh(a, imm) __extension__ ({ \ + (unsigned short)(((__v8hi)__builtin_ia32_vcvtps2ph((__v4sf){a, 0, 0, 0}, \ + (imm)))[0]); }) /// \brief Converts a 128-bit vector containing 32-bit float values into a ///128-bit vector containing 16-bit half-precision float values. @@ -99,8 +99,8 @@ _cvtsh_ss(unsigned short __a) /// \returns A 128-bit vector containing converted 16-bit half-precision float ///values. The lower 64 bits are used to store the converted 16-bit ///half-precision floating-point values. -#define _mm_cvtps_ph(a, imm) \ - ((__m128i)__builtin_ia32_vcvtps2ph((__v4sf)(__m128)(a), (imm))) +#define _mm_cvtps_ph(a, imm) __extension__ ({ \ + (__m128i)__builtin_ia32_vcvtps2ph((__v4sf)(__m128)(a), (imm)); }) /// \brief Converts a 128-bit vector containing 16-bit half-precision float ///values into a 128-bit vector containing 32-bit float values. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31562: [coroutines] Fix building of new/delete expressions when get_return_object_on_allocation_failure() is present.
GorNishanov accepted this revision. GorNishanov added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D31562 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31168: Set FMF for -ffp-contract=fast
anemet added a comment. Ping. This is the only patch in the series now that wasn't approved. https://reviews.llvm.org/D31168 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31487: [coroutines] Fix rebuilding of implicit and dependent coroutine statements.
GorNishanov added inline comments. Comment at: lib/Sema/CoroutineBuilder.h:1 +//===- CoroutineBuilder.h - Coroutine Semantic checking -*- C++ -*-===// +// I would name the file to match the class it declares, i.e CoroutineStmtBuilder.h, since it is the only class defined in this header. Comment at: lib/Sema/CoroutineBuilder.h:9 +// +// This file implements a semantic tree transformation that takes a given +// AST and rebuilds it, possibly transforming some nodes in the process. I do not think that this description matches the content of the file. Comment at: lib/Sema/CoroutineBuilder.h:37 +public: + CoroutineStmtBuilder(Sema &S, FunctionDecl &FD, sema::FunctionScopeInfo &Fn, + Stmt *Body) I would move the constructor and two build methods implementations into SemaCoroutine.cpp. Comment at: lib/Sema/TreeTransform.h:6908 + } else { +if (S->getFallthroughHandler()) { + StmtResult Res = getDerived().TransformStmt(S->getFallthroughHandler()); if(Expr *OnFallthrough = ...) { ...getDerived().TransformStmt(OnFallthrough); Comment at: lib/Sema/TreeTransform.h:6915 - // Transform any additional statements we may have already built - if (S->getAllocate() && S->getDeallocate()) { +if (S->getExceptionHandler()) { + StmtResult Res = getDerived().TransformStmt(S->getExceptionHandler()); if(Expr *OnException = ...) { ...getDerived().TransformStmt(OnException); Comment at: lib/Sema/TreeTransform.h:6922 + +if (S->getReturnStmtOnAllocFailure()) { + StmtResult Res = if(Expr *OnAllocFailure = ...) { ...getDerived().TransformStmt(OnAllocFailure); https://reviews.llvm.org/D31487 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31508: [ThinLTO] Set up lto::Config properly for codegen in ThinLTO backends
tejohnson added a comment. In https://reviews.llvm.org/D31508#716087, @davide wrote: > clang -cc1 crashes if an invalid reloc model is passed (via > `-mreloc-model=`), see https://bugs.llvm.org/show_bug.cgi?id=32490 > I'm not sure if the bug was already there or this refactoring exposed it. > Either way, I'm going to submit a patch to get this fixed. > Ideally, we shouldn't keep two codepath in sync (as we do already for > `getCodeModel()`, but that's the status quo). I may decide to refactor the > whole handling to avoid this sync issue, but that won't be today. Thanks for fixing. I don't think this refactoring would have affected this though, the non-ThinLTO backend changes were NFC, it is the same switch statement that was there before. Repository: rL LLVM https://reviews.llvm.org/D31508 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31575: [clang-format] Use configured IndentWidth instead of 2
thatguystone created this revision. Herald added a subscriber: klimek. For JS projects that use a IdentWidth other than 2, this was causing the indent to be 2 when creating new objects in arrays. Repository: rL LLVM https://reviews.llvm.org/D31575 Files: lib/Format/ContinuationIndenter.cpp unittests/Format/FormatTestJS.cpp Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -287,6 +287,31 @@ "};"); } +TEST_F(FormatTestJS, ContainerLiteralsIndentWidth) { + FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript); + Style.IndentWidth = 4; + + verifyFormat("return [\n" + "{\n" + "a: 1,\n" + "},\n" + "{\n" + "b: 2,\n" + "},\n" + "];", + Style); + verifyFormat("return {\n" + "nested: {\n" + "values: {\n" + "indent: [\n" + "right,\n" + "],\n" + "},\n" + "},\n" + "};", + Style); +} + TEST_F(FormatTestJS, MethodsInObjectLiterals) { verifyFormat("var o = {\n" " value: 'test',\n" Index: lib/Format/ContinuationIndenter.cpp === --- lib/Format/ContinuationIndenter.cpp +++ lib/Format/ContinuationIndenter.cpp @@ -991,7 +991,7 @@ if (Current.isOneOf(tok::l_brace, TT_ArrayInitializerLSquare)) { if (Current.opensBlockOrBlockTypeList(Style)) { NewIndent = State.Stack.back().NestedBlockIndent + Style.IndentWidth; - NewIndent = std::min(State.Column + 2, NewIndent); + NewIndent = std::min(State.Column + Style.IndentWidth, NewIndent); } else { NewIndent = State.Stack.back().LastSpace + Style.ContinuationIndentWidth; } Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -287,6 +287,31 @@ "};"); } +TEST_F(FormatTestJS, ContainerLiteralsIndentWidth) { + FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript); + Style.IndentWidth = 4; + + verifyFormat("return [\n" + "{\n" + "a: 1,\n" + "},\n" + "{\n" + "b: 2,\n" + "},\n" + "];", + Style); + verifyFormat("return {\n" + "nested: {\n" + "values: {\n" + "indent: [\n" + "right,\n" + "],\n" + "},\n" + "},\n" + "};", + Style); +} + TEST_F(FormatTestJS, MethodsInObjectLiterals) { verifyFormat("var o = {\n" " value: 'test',\n" Index: lib/Format/ContinuationIndenter.cpp === --- lib/Format/ContinuationIndenter.cpp +++ lib/Format/ContinuationIndenter.cpp @@ -991,7 +991,7 @@ if (Current.isOneOf(tok::l_brace, TT_ArrayInitializerLSquare)) { if (Current.opensBlockOrBlockTypeList(Style)) { NewIndent = State.Stack.back().NestedBlockIndent + Style.IndentWidth; - NewIndent = std::min(State.Column + 2, NewIndent); + NewIndent = std::min(State.Column + Style.IndentWidth, NewIndent); } else { NewIndent = State.Stack.back().LastSpace + Style.ContinuationIndentWidth; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r299316 - [NFC, Scoped Enum] Convert Sema::ExpressionEvaluationContext into a scoped Enum
Author: faisalv Date: Sat Apr 1 16:30:49 2017 New Revision: 299316 URL: http://llvm.org/viewvc/llvm-project?rev=299316&view=rev Log: [NFC, Scoped Enum] Convert Sema::ExpressionEvaluationContext into a scoped Enum - also replace direct equality checks against the ConstantEvaluated enumerator with isConstantEvaluted(), in anticipation of adding finer granularity to the various ConstantEvaluated contexts and reinstating certain restrictions on where lambda expressions can occur in C++17. - update the clang tablegen backend that uses these Enumerators, and add the relevant scope where needed. Modified: cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp cfe/trunk/lib/Parse/ParseDecl.cpp cfe/trunk/lib/Parse/ParseDeclCXX.cpp cfe/trunk/lib/Parse/ParseExpr.cpp cfe/trunk/lib/Parse/ParseExprCXX.cpp cfe/trunk/lib/Parse/ParseStmt.cpp cfe/trunk/lib/Parse/ParseTemplate.cpp cfe/trunk/lib/Sema/Sema.cpp cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaDeclCXX.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/lib/Sema/SemaExprMember.cpp cfe/trunk/lib/Sema/SemaLambda.cpp cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/lib/Sema/SemaStmt.cpp cfe/trunk/lib/Sema/SemaStmtAsm.cpp cfe/trunk/lib/Sema/SemaTemplate.cpp cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp cfe/trunk/lib/Sema/TreeTransform.h cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=299316&r1=299315&r2=299316&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Sat Apr 1 16:30:49 2017 @@ -681,7 +681,8 @@ public: : S(S), SavedContext(S, DC) { S.PushFunctionScope(); - S.PushExpressionEvaluationContext(Sema::PotentiallyEvaluated); + S.PushExpressionEvaluationContext( + Sema::ExpressionEvaluationContext::PotentiallyEvaluated); } ~SynthesizedFunctionScope() { @@ -802,7 +803,7 @@ public: /// \brief Describes how the expressions currently being parsed are /// evaluated at run-time, if at all. - enum ExpressionEvaluationContext { + enum class ExpressionEvaluationContext { /// \brief The current expression and its subexpressions occur within an /// unevaluated operand (C++11 [expr]p7), such as the subexpression of /// \c sizeof, where the type of the expression may be significant but @@ -908,8 +909,12 @@ public: MangleNumberingContext &getMangleNumberingContext(ASTContext &Ctx); bool isUnevaluated() const { - return Context == Unevaluated || Context == UnevaluatedAbstract || - Context == UnevaluatedList; + return Context == ExpressionEvaluationContext::Unevaluated || + Context == ExpressionEvaluationContext::UnevaluatedAbstract || + Context == ExpressionEvaluationContext::UnevaluatedList; +} +bool isConstantEvaluated() const { + return Context == ExpressionEvaluationContext::ConstantEvaluated; } }; @@ -10315,6 +10320,7 @@ class EnterExpressionEvaluationContext { bool Entered = true; public: + EnterExpressionEvaluationContext(Sema &Actions, Sema::ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl = nullptr, @@ -10345,8 +10351,8 @@ public: // a context. if (ShouldEnter && Actions.isUnevaluatedContext() && Actions.getLangOpts().CPlusPlus11) { - Actions.PushExpressionEvaluationContext(Sema::UnevaluatedList, nullptr, - false); + Actions.PushExpressionEvaluationContext( + Sema::ExpressionEvaluationContext::UnevaluatedList, nullptr, false); Entered = true; } } Modified: cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp?rev=299316&r1=299315&r2=299316&view=diff == --- cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp (original) +++ cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp Sat Apr 1 16:30:49 2017 @@ -344,9 +344,9 @@ void Parser::ParseLexedMethodDeclaration // The argument isn't actually potentially evaluated unless it is // used. - EnterExpressionEvaluationContext Eval(Actions, -Sema::PotentiallyEvaluatedIfUsed, -Param); + EnterExpressionEvaluationContext Eval( + Actions, + Sema::ExpressionEvaluationContext::
[PATCH] D31508: [ThinLTO] Set up lto::Config properly for codegen in ThinLTO backends
davide added a comment. r299315 Repository: rL LLVM https://reviews.llvm.org/D31508 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r299315 - [Driver] Don't crash on invalid values of -mrelocation-model=.
Author: davide Date: Sat Apr 1 16:07:07 2017 New Revision: 299315 URL: http://llvm.org/viewvc/llvm-project?rev=299315&view=rev Log: [Driver] Don't crash on invalid values of -mrelocation-model=. This is handled in a similar way we handle invalid -mcode-model. PR: 31840 Added: cfe/trunk/test/Driver/reloc-model.c Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=299315&r1=299314&r2=299315&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Sat Apr 1 16:07:07 2017 @@ -323,7 +323,8 @@ static llvm::CodeModel::Model getCodeMod } static llvm::Reloc::Model getRelocModel(const CodeGenOptions &CodeGenOpts) { - // Keep this synced with the equivalent code in tools/driver/cc1as_main.cpp. + // Keep this synced with the equivalent code in + // lib/Frontend/CompilerInvocation.cpp llvm::Optional RM; RM = llvm::StringSwitch(CodeGenOpts.RelocationModel) .Case("static", llvm::Reloc::Static) Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=299315&r1=299314&r2=299315&view=diff == --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Sat Apr 1 16:07:07 2017 @@ -330,6 +330,17 @@ static StringRef getCodeModel(ArgList &A return "default"; } +static StringRef getRelocModel(ArgList &Args, DiagnosticsEngine &Diags) { + if (Arg *A = Args.getLastArg(OPT_mrelocation_model)) { +StringRef Value = A->getValue(); +if (Value == "static" || Value == "pic" || Value == "ropi" || +Value == "rwpi" || Value == "ropi-rwpi" || Value == "dynamic-no-pic") + return Value; +Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Value; + } + return "pic"; +} + /// \brief Create a new Regex instance out of the string value in \p RpassArg. /// It returns a pointer to the newly generated Regex instance. static std::shared_ptr @@ -615,7 +626,7 @@ static bool ParseCodeGenArgs(CodeGenOpti Args.hasArg(OPT_cl_unsafe_math_optimizations) || Args.hasArg(OPT_cl_fast_relaxed_math); Opts.UnwindTables = Args.hasArg(OPT_munwind_tables); - Opts.RelocationModel = Args.getLastArgValue(OPT_mrelocation_model, "pic"); + Opts.RelocationModel = getRelocModel(Args, Diags); Opts.ThreadModel = Args.getLastArgValue(OPT_mthread_model, "posix"); if (Opts.ThreadModel != "posix" && Opts.ThreadModel != "single") Diags.Report(diag::err_drv_invalid_value) Added: cfe/trunk/test/Driver/reloc-model.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/reloc-model.c?rev=299315&view=auto == --- cfe/trunk/test/Driver/reloc-model.c (added) +++ cfe/trunk/test/Driver/reloc-model.c Sat Apr 1 16:07:07 2017 @@ -0,0 +1,4 @@ +// RUN: not %clang -cc1 -mrelocation-model tinkywinky \ +// RUN: -emit-llvm %s 2>&1 | FileCheck -check-prefix CHECK-INVALID %s + +// CHECK-INVALID: error: invalid value 'tinkywinky' in '-mrelocation-model tinkywinky' ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31508: [ThinLTO] Set up lto::Config properly for codegen in ThinLTO backends
davide added a comment. clang -cc1 crashes if an invalid reloc model is passed (via `-mreloc-model=`), see https://bugs.llvm.org/show_bug.cgi?id=32490 I'm not sure if the bug was already there or this refactoring exposed it. Either way, I'm going to submit a patch to get this fixed. Ideally, we shouldn't keep two codepath in sync (as we do already for `getCodeModel()`, but that's the status quo). I may decide to refactor the whole handling to avoid this sync issue, but that won't be today. Repository: rL LLVM https://reviews.llvm.org/D31508 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] Use the correct ObjC++ personality
Landed in r299306 with a test case. Yes, even one-liners should have a test case. On Thu, Mar 30, 2017 at 10:30 PM, Jonathan Schleifer via cfe-commits wrote: >> Testcase? > > Shouldn't be necessary for such a simple and extremely obvious one-liner. > > -- > Jonathan > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r299306 - [ObjC++] Use the correct EH personality in GNU mode
Author: d0k Date: Sat Apr 1 12:59:01 2017 New Revision: 299306 URL: http://llvm.org/viewvc/llvm-project?rev=299306&view=rev Log: [ObjC++] Use the correct EH personality in GNU mode Previously, it would just always use the ObjC DWARF personality, even with SjLj or SEH exceptions. Patch by Jonathan Schleifer, test case by me. Added: cfe/trunk/test/CodeGenObjCXX/objfw-exceptions.mm Modified: cfe/trunk/lib/CodeGen/CGException.cpp Modified: cfe/trunk/lib/CodeGen/CGException.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=299306&r1=299305&r2=299306&view=diff == --- cfe/trunk/lib/CodeGen/CGException.cpp (original) +++ cfe/trunk/lib/CodeGen/CGException.cpp Sat Apr 1 12:59:01 2017 @@ -180,8 +180,8 @@ static const EHPersonality &getObjCXXPer // The GCC runtime's personality function inherently doesn't support // mixed EH. Use the C++ personality just to avoid returning null. case ObjCRuntime::GCC: - case ObjCRuntime::ObjFW: // XXX: this will change soon -return EHPersonality::GNU_ObjC; + case ObjCRuntime::ObjFW: +return getObjCPersonality(T, L); case ObjCRuntime::GNUstep: return EHPersonality::GNU_ObjCXX; } Added: cfe/trunk/test/CodeGenObjCXX/objfw-exceptions.mm URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/objfw-exceptions.mm?rev=299306&view=auto == --- cfe/trunk/test/CodeGenObjCXX/objfw-exceptions.mm (added) +++ cfe/trunk/test/CodeGenObjCXX/objfw-exceptions.mm Sat Apr 1 12:59:01 2017 @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -fexceptions -fobjc-exceptions -fobjc-runtime=objfw -fcxx-exceptions -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-DWARF +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -fexceptions -fobjc-exceptions -fobjc-runtime=objfw -fcxx-exceptions -fsjlj-exceptions -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-SJLJ + +@interface OCType @end +void opaque(); + +// CHECK: define void @_Z3foov() +// CHECK-DWARF-SAME: personality i8* bitcast (i32 (...)* @__gnu_objc_personality_v0 to i8*) +// CHECK-SJLJ-SAME: personality i8* bitcast (i32 (...)* @__gnu_objc_personality_sj0 to i8*) +void foo() { +try { +// CHECK: invoke void @_Z6opaquev +opaque(); +} catch (OCType *T) { +// CHECK: landingpad { i8*, i32 } +} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31568: Add Python 3 support to clang.cindex
jbcoe created this revision. jbcoe added a project: clang-c. Introduce an interop string to convert from unicode to c-strings where needed. Add missing conversions from _CXString to strings in function registrations. Explicitly evaluate lists where Python 3's lazy iterators would not otherwise do so. This is an improvement upon the reverted change proposed in https://reviews.llvm.org/D26082 Repository: rL LLVM https://reviews.llvm.org/D31568 Files: clang/bindings/python/clang/__init__.py clang/bindings/python/clang/cindex.py clang/bindings/python/tests/cindex/test_translation_unit.py Index: clang/bindings/python/tests/cindex/test_translation_unit.py === --- clang/bindings/python/tests/cindex/test_translation_unit.py +++ clang/bindings/python/tests/cindex/test_translation_unit.py @@ -59,9 +59,12 @@ assert spellings[-1] == 'y' def test_unsaved_files_2(): -import StringIO +try: +from StringIO import StringIO +except: +from io import StringIO tu = TranslationUnit.from_source('fake.c', unsaved_files = [ -('fake.c', StringIO.StringIO('int x;'))]) +('fake.c', StringIO('int x;'))]) spellings = [c.spelling for c in tu.cursor.get_children()] assert spellings[-1] == 'x' Index: clang/bindings/python/clang/cindex.py === --- clang/bindings/python/clang/cindex.py +++ clang/bindings/python/clang/cindex.py @@ -67,6 +67,60 @@ import clang.enumerations +import sys +if sys.version_info[0] == 3: +# Python 3 strings are unicode, translate them to/from utf8 for C-interop. +class c_interop_string(c_char_p): + +def __init__(self, p=None): +if p is None: +p = "" +if isinstance(p, str): +p = p.encode("utf8") +super(c_char_p, self).__init__(p) + +def __str__(self): +return self.value + +@property +def value(self): +if super(c_char_p, self).value is None: +return None +return super(c_char_p, self).value.decode("utf8") + +@classmethod +def from_param(cls, param): +if isinstance(param, str): +return cls(param) +if isinstance(param, bytes): +return cls(param) +raise TypeError("Cannot convert '{}' to '{}'".format(type(param).__name__, cls.__name__)) + +@staticmethod +def to_python_string(x, *args): +return x.value + +def b(x): +if isinstance(x, bytes): +return x +return x.encode('utf8') + +xrange = range + +elif sys.version_info[0] == 2: +# Python 2 strings are utf8 byte strings, no translation is needed for +# C-interop. +c_interop_string = c_char_p + +def _to_python_string(x, *args): +return x + +c_interop_string.to_python_string = staticmethod(_to_python_string) + +def b(x): +return x + + # ctypes doesn't implicitly convert c_void_p to the appropriate wrapper # object. This is a problem, because it means that from_parameter will see an # integer and pass the wrong value on platforms where int != void*. Work around @@ -157,6 +211,7 @@ assert isinstance(res, _CXString) return conf.lib.clang_getCString(res) + class SourceLocation(Structure): """ A SourceLocation represents a particular location within a source file. @@ -596,7 +651,7 @@ @staticmethod def get_all_kinds(): """Return all CursorKind enumeration instances.""" -return filter(None, CursorKind._kinds) +return [x for x in CursorKind._kinds if not x is None] def is_declaration(self): """Test if this is a declaration kind.""" @@ -2128,7 +2183,7 @@ """ Retrieve the offset of a field in the record. """ -return conf.lib.clang_Type_getOffsetOf(self, c_char_p(fieldname)) +return conf.lib.clang_Type_getOffsetOf(self, fieldname) def get_ref_qualifier(self): """ @@ -2233,13 +2288,13 @@ self.__kindNumberCache = -1 def __repr__(self): -return "{'" + self.spelling + "', " + str(self.kind) + "}" +return "{'" + str(self.spelling) + "', " + str(self.kind) + "}" @CachedProperty def spelling(self): if self.__kindNumber in SpellingCache: return SpellingCache[self.__kindNumber] -return conf.lib.clang_getCompletionChunkText(self.cs, self.key).spelling +return conf.lib.clang_getCompletionChunkText(self.cs, self.key) # We do not use @CachedProperty here, as the manual implementation is # apparently still significantly faster. Please profile carefully if you @@ -2345,7 +2400,7 @@ return " | ".join([str(a) for a in self]) \ + " || Priority: " + str(self.priority) \
[PATCH] D31562: [coroutines] Fix building of new/delete expressions when get_return_object_on_allocation_failure() is present.
EricWF updated this revision to Diff 93742. EricWF added a comment. - Actually remove incorrectly added changes. https://reviews.llvm.org/D31562 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaCoroutine.cpp test/SemaCXX/coroutines.cpp Index: test/SemaCXX/coroutines.cpp === --- test/SemaCXX/coroutines.cpp +++ test/SemaCXX/coroutines.cpp @@ -654,6 +654,20 @@ co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}} } +namespace std { + struct nothrow_t {}; + constexpr nothrow_t nothrow = {}; +} + +using SizeT = decltype(sizeof(int)); + +void* operator new(SizeT __sz, const std::nothrow_t&) noexcept; +void operator delete(void* __p, const std::nothrow_t&) noexcept; + +void* operator new[](SizeT __sz, const std::nothrow_t&) noexcept; +void operator delete[](void* __p, const std::nothrow_t&) noexcept; + + struct promise_on_alloc_failure_tag {}; template<> @@ -694,3 +708,25 @@ } template coro dependent_private_alloc_failure_handler(bad_promise_11); // expected-note@-1 {{requested here}} + + +struct bad_promise_12 { + coro get_return_object(); + suspend_always initial_suspend(); + suspend_always final_suspend(); + void unhandled_exception(); + void return_void(); + static coro get_return_object_on_allocation_failure(); + + static void* operator new(SizeT); + // expected-error@-1 2 {{'operator new' is required to have a non-throwing noexcept specification when the promise type declares 'get_return_object_on_allocation_failure()'}} +}; +coro throwing_in_class_new() { // expected-note {{call to 'operator new' implicitly required by coroutine function here}} + co_return; +} + +template +coro dependent_throwing_in_class_new(T) { // expected-note {{call to 'operator new' implicitly required by coroutine function here}} + co_return; +} +template coro dependent_throwing_in_class_new(bad_promise_12); // expected-note {{requested here}} Index: lib/Sema/SemaCoroutine.cpp === --- lib/Sema/SemaCoroutine.cpp +++ lib/Sema/SemaCoroutine.cpp @@ -454,7 +454,7 @@ /*IsImplicit*/ true); Suspend = S.ActOnFinishFullExpr(Suspend.get()); if (Suspend.isInvalid()) { - S.Diag(Loc, diag::note_coroutine_promise_call_implicitly_required) + S.Diag(Loc, diag::note_coroutine_promise_suspend_implicitly_required) << ((Name == "initial_suspend") ? 0 : 1); S.Diag(KWLoc, diag::note_declared_coroutine_here) << Keyword; return StmtError(); @@ -660,6 +660,37 @@ return Res; } +/// Look up the std::nothrow object. +static Expr *buildStdNoThrowDeclRef(Sema &S, SourceLocation Loc) { + NamespaceDecl *Std = S.getStdNamespace(); + assert(Std && "Should already be diagnosed"); + + LookupResult Result(S, &S.PP.getIdentifierTable().get("nothrow"), Loc, + Sema::LookupOrdinaryName); + if (!S.LookupQualifiedName(Result, Std)) { +// FIXME: should have been included already. +// If we require it to include then this diagnostic is no longer +// needed. +S.Diag(Loc, diag::err_implicit_coroutine_std_nothrow_type_not_found); +return nullptr; + } + + auto *VD = Result.getAsSingle(); + if (!VD) { +Result.suppressDiagnostics(); +// We found something weird. Complain about the first thing we found. +NamedDecl *Found = *Result.begin(); +S.Diag(Found->getLocation(), diag::err_malformed_std_nothrow); +return nullptr; + } + + ExprResult DR = S.BuildDeclRefExpr(VD, VD->getType(), VK_LValue, Loc); + if (DR.isInvalid()) +return nullptr; + + return DR.get(); +} + // Find an appropriate delete for the promise. static FunctionDecl *findDeleteForPromise(Sema &S, SourceLocation Loc, QualType PromiseType) { @@ -815,23 +846,51 @@ if (S.RequireCompleteType(Loc, PromiseType, diag::err_incomplete_type)) return false; - // FIXME: Add nothrow_t placement arg for global alloc - //if ReturnStmtOnAllocFailure != nullptr. + const bool RequiresNoThrowAlloc = ReturnStmtOnAllocFailure != nullptr; + // FIXME: Add support for stateful allocators. FunctionDecl *OperatorNew = nullptr; FunctionDecl *OperatorDelete = nullptr; FunctionDecl *UnusedResult = nullptr; bool PassAlignment = false; + MultiExprArg PlacementArgs = None; S.FindAllocationFunctions(Loc, SourceRange(), /*UseGlobal*/ false, PromiseType, -/*isArray*/ false, PassAlignment, -/*PlacementArgs*/ None, OperatorNew, UnusedResult); +/*isArray*/ false, PassAlignment, PlacementArgs, +OperatorNew, UnusedResult); + + bool IsGlobalOverload = + OperatorNew && !isa(OperatorNew->getDeclContext()); + // If we didn't find a class-local new declaration