r298835 - [XRay][clang] Remove dependency on libatomic for XRay builds
Author: dberris Date: Mon Mar 27 02:14:11 2017 New Revision: 298835 URL: http://llvm.org/viewvc/llvm-project?rev=298835&view=rev Log: [XRay][clang] Remove dependency on libatomic for XRay builds Summary: This change depends on D31381 where we change the implementation to use sanitizer_common provided atomic operations library. Fixes http://llvm.org/PR32274. Reviewers: pelikan, dblaikie Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D31382 Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=298835&r1=298834&r2=298835&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Mon Mar 27 02:14:11 2017 @@ -346,7 +346,6 @@ static void linkXRayRuntimeDeps(const To CmdArgs.push_back("-lpthread"); CmdArgs.push_back("-lrt"); CmdArgs.push_back("-lm"); - CmdArgs.push_back("-latomic"); if (TC.getTriple().getOS() != llvm::Triple::FreeBSD) CmdArgs.push_back("-ldl"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31382: [XRay][clang] Remove dependency on libatomic for XRay builds
This revision was automatically updated to reflect the committed changes. Closed by commit rL298835: [XRay][clang] Remove dependency on libatomic for XRay builds (authored by dberris). Changed prior to commit: https://reviews.llvm.org/D31382?vs=93097&id=93101#toc Repository: rL LLVM https://reviews.llvm.org/D31382 Files: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp === --- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp +++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp @@ -346,7 +346,6 @@ CmdArgs.push_back("-lpthread"); CmdArgs.push_back("-lrt"); CmdArgs.push_back("-lm"); - CmdArgs.push_back("-latomic"); if (TC.getTriple().getOS() != llvm::Triple::FreeBSD) CmdArgs.push_back("-ldl"); Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp === --- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp +++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp @@ -346,7 +346,6 @@ CmdArgs.push_back("-lpthread"); CmdArgs.push_back("-lrt"); CmdArgs.push_back("-lm"); - CmdArgs.push_back("-latomic"); if (TC.getTriple().getOS() != llvm::Triple::FreeBSD) CmdArgs.push_back("-ldl"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30248: [libclang] Fix crash in member access code completion with implicit base
bkramer accepted this revision. bkramer added a comment. This revision is now accepted and ready to land. Let's fix those crashes one at a time. This patch looks good, only minor comments below. Comment at: lib/Sema/SemaOverload.cpp:6311 + if (isa(FD) && !cast(FD)->isStatic()) { +QualType ObjectType; +Expr::Classification ObjectClassification; This could use a comment explaining that this can happen if there's an error in the code, e.g. in code completion context. Comment at: lib/Sema/SemaOverload.cpp:6329 + !cast(FunTmpl->getTemplatedDecl())->isStatic()) { +QualType ObjectType; +Expr::Classification ObjectClassification; Same here. https://reviews.llvm.org/D30248 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30427: Fix whitespace before token-paste of an argument.
jyknight added a comment. Ping. https://reviews.llvm.org/D30427 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31183: [OpenCL] Added parsing for OpenCL vector types.
echuraev added a comment. In https://reviews.llvm.org/D31183#710202, @Anastasia wrote: > In https://reviews.llvm.org/D31183#709566, @echuraev wrote: > > > In https://reviews.llvm.org/D31183#708833, @yaxunl wrote: > > > > > I think this is a good feature for the convenience of user. I've seen > > > usage like this. > > > > > > I agree. I don't see any reasons why this case doesn't have the right to > > exist. I don't think that using extra parenthesis is a good solution for > > solving this problem. > > > I am just saying that I don't see a big use case for this. I am guessing it > can largely come from the macro expansions, but those are generally good > style to parenthesize. Ok. But in current implementation if I forget to parenthesize the defined expression (as in the test) I will get the following message: "error: member reference base type 'int' is not a structure or union". I don't think that the message is clear to understand that you just forgot to add parenthesis. So, should we change the diagnostic message to do it more understandable or push this patch because it can be more convenience for users? https://reviews.llvm.org/D31183 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r298838 - [OpenCL] Extended mapping of parcing CodeGen arguments
Author: echuraev Date: Mon Mar 27 05:38:01 2017 New Revision: 298838 URL: http://llvm.org/viewvc/llvm-project?rev=298838&view=rev Log: [OpenCL] Extended mapping of parcing CodeGen arguments Summary: Enable cl_mad_enamle and cl_no_signed_zeros options when user turns on cl_unsafe_math_optimizations or cl_fast_relaxed_math options. Reviewers: Anastasia, cfe-commits Reviewed By: Anastasia Subscribers: bader, yaxunl Differential Revision: https://reviews.llvm.org/D31324 Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/CodeGenOpenCL/relaxed-fpmath.cl Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=298838&r1=298837&r2=298838&view=diff == --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Mar 27 05:38:01 2017 @@ -573,7 +573,9 @@ static bool ParseCodeGenArgs(CodeGenOpti Opts.DiscardValueNames = Args.hasArg(OPT_discard_value_names); Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls); Opts.FloatABI = Args.getLastArgValue(OPT_mfloat_abi); - Opts.LessPreciseFPMAD = Args.hasArg(OPT_cl_mad_enable); + Opts.LessPreciseFPMAD = Args.hasArg(OPT_cl_mad_enable) || + Args.hasArg(OPT_cl_unsafe_math_optimizations) || + Args.hasArg(OPT_cl_fast_relaxed_math); Opts.LimitFloatPrecision = Args.getLastArgValue(OPT_mlimit_float_precision); Opts.NoInfsFPMath = (Args.hasArg(OPT_menable_no_infinities) || Args.hasArg(OPT_cl_finite_math_only) || @@ -583,7 +585,9 @@ static bool ParseCodeGenArgs(CodeGenOpti Args.hasArg(OPT_cl_finite_math_only) || Args.hasArg(OPT_cl_fast_relaxed_math)); Opts.NoSignedZeros = (Args.hasArg(OPT_fno_signed_zeros) || -Args.hasArg(OPT_cl_no_signed_zeros)); +Args.hasArg(OPT_cl_no_signed_zeros) || +Args.hasArg(OPT_cl_unsafe_math_optimizations) || +Args.hasArg(OPT_cl_fast_relaxed_math)); Opts.FlushDenorm = Args.hasArg(OPT_cl_denorms_are_zero); Opts.CorrectlyRoundedDivSqrt = Args.hasArg(OPT_cl_fp32_correctly_rounded_divide_sqrt); Modified: cfe/trunk/test/CodeGenOpenCL/relaxed-fpmath.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/relaxed-fpmath.cl?rev=298838&r1=298837&r2=298838&view=diff == --- cfe/trunk/test/CodeGenOpenCL/relaxed-fpmath.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/relaxed-fpmath.cl Mon Mar 27 05:38:01 2017 @@ -2,33 +2,54 @@ // RUN: %clang_cc1 %s -emit-llvm -cl-fast-relaxed-math -o - | FileCheck %s -check-prefix=FAST // RUN: %clang_cc1 %s -emit-llvm -cl-finite-math-only -o - | FileCheck %s -check-prefix=FINITE // RUN: %clang_cc1 %s -emit-llvm -cl-unsafe-math-optimizations -o - | FileCheck %s -check-prefix=UNSAFE - -typedef __attribute__(( ext_vector_type(4) )) float float4; +// RUN: %clang_cc1 %s -emit-llvm -cl-mad-enable -o - | FileCheck %s -check-prefix=MAD +// RUN: %clang_cc1 %s -emit-llvm -cl-no-signed-zeros -o - | FileCheck %s -check-prefix=NOSIGNED float spscalardiv(float a, float b) { // CHECK: @spscalardiv( - // NORMAL: fdiv float + // NORMAL: fdiv float // FAST: fdiv fast float // FINITE: fdiv nnan ninf float - // UNSAFE: fdiv nnan float + // UNSAFE: fdiv nnan nsz float + // MAD: fdiv float + // NOSIGNED: fdiv nsz float return a / b; } // CHECK: attributes +// NORMAL: "less-precise-fpmad"="false" // NORMAL: "no-infs-fp-math"="false" // NORMAL: "no-nans-fp-math"="false" +// NORMAL: "no-signed-zeros-fp-math"="false" // NORMAL: "unsafe-fp-math"="false" +// FAST: "less-precise-fpmad"="true" // FAST: "no-infs-fp-math"="true" // FAST: "no-nans-fp-math"="true" +// FAST: "no-signed-zeros-fp-math"="true" // FAST: "unsafe-fp-math"="true" +// FINITE: "less-precise-fpmad"="false" // FINITE: "no-infs-fp-math"="true" // FINITE: "no-nans-fp-math"="true" +// FINITE: "no-signed-zeros-fp-math"="false" // FINITE: "unsafe-fp-math"="false" +// UNSAFE: "less-precise-fpmad"="true" // UNSAFE: "no-infs-fp-math"="false" // UNSAFE: "no-nans-fp-math"="true" +// UNSAFE: "no-signed-zeros-fp-math"="true" // UNSAFE: "unsafe-fp-math"="true" +// MAD: "less-precise-fpmad"="true" +// MAD: "no-infs-fp-math"="false" +// MAD: "no-nans-fp-math"="false" +// MAD: "no-signed-zeros-fp-math"="false" +// MAD: "unsafe-fp-math"="false" + +// NOSIGNED: "less-precise-fpmad"="false" +// NOSIGNED: "no-infs-fp-math"="false" +// NOSIGNED: "no-nans-fp-math"="false" +// NOSIGNED: "no-signed-zeros-fp-math"="true" +// NOSIGNED: "unsafe-fp-math"="false" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lis
[libcxx] r298839 - Mark *pass tests as UNUSUPPORTED instead of XFAIL on old compilers
Author: marshall Date: Mon Mar 27 05:44:33 2017 New Revision: 298839 URL: http://llvm.org/viewvc/llvm-project?rev=298839&view=rev Log: Mark *pass tests as UNUSUPPORTED instead of XFAIL on old compilers Modified: libcxx/trunk/test/std/language.support/support.types/byteops/and.assign.pass.cpp libcxx/trunk/test/std/language.support/support.types/byteops/and.pass.cpp libcxx/trunk/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp libcxx/trunk/test/std/language.support/support.types/byteops/lshift.pass.cpp libcxx/trunk/test/std/language.support/support.types/byteops/not.pass.cpp libcxx/trunk/test/std/language.support/support.types/byteops/or.assign.pass.cpp libcxx/trunk/test/std/language.support/support.types/byteops/or.pass.cpp libcxx/trunk/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp libcxx/trunk/test/std/language.support/support.types/byteops/rshift.pass.cpp libcxx/trunk/test/std/language.support/support.types/byteops/to_integer.pass.cpp libcxx/trunk/test/std/language.support/support.types/byteops/xor.assign.pass.cpp libcxx/trunk/test/std/language.support/support.types/byteops/xor.pass.cpp Modified: libcxx/trunk/test/std/language.support/support.types/byteops/and.assign.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/and.assign.pass.cpp?rev=298839&r1=298838&r2=298839&view=diff == --- libcxx/trunk/test/std/language.support/support.types/byteops/and.assign.pass.cpp (original) +++ libcxx/trunk/test/std/language.support/support.types/byteops/and.assign.pass.cpp Mon Mar 27 05:44:33 2017 @@ -12,8 +12,8 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 // The following compilers don't like "std::byte b1{1}" -// XFAIL: clang-3.5, clang-3.6, clang-3.7, clang-3.8 -// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8.0 +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 // constexpr byte& operator &=(byte l, byte r) noexcept; Modified: libcxx/trunk/test/std/language.support/support.types/byteops/and.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/and.pass.cpp?rev=298839&r1=298838&r2=298839&view=diff == --- libcxx/trunk/test/std/language.support/support.types/byteops/and.pass.cpp (original) +++ libcxx/trunk/test/std/language.support/support.types/byteops/and.pass.cpp Mon Mar 27 05:44:33 2017 @@ -12,8 +12,8 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 // The following compilers don't like "std::byte b1{1}" -// XFAIL: clang-3.5, clang-3.6, clang-3.7, clang-3.8 -// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8.0 +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 // constexpr byte operator&(byte l, byte r) noexcept; Modified: libcxx/trunk/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp?rev=298839&r1=298838&r2=298839&view=diff == --- libcxx/trunk/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp (original) +++ libcxx/trunk/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp Mon Mar 27 05:44:33 2017 @@ -12,8 +12,8 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 // The following compilers don't like "std::byte b1{1}" -// XFAIL: clang-3.5, clang-3.6, clang-3.7, clang-3.8 -// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8.0 +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 // template // constexpr byte& operator<<=(byte& b, IntegerType shift) noexcept; Modified: libcxx/trunk/test/std/language.support/support.types/byteops/lshift.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/lshift.pass.cpp?rev=298839&r1=298838&r2=298839&view=diff == --- libcxx/trunk/test/std/language.support/support.types/byteops/lshift.pass.cpp (original) +++ libcxx/trunk/test/std/language.support/support.types/byteops/lshift.pass.cpp Mon Mar 27 05:44:33 2017 @@ -12,8 +12,8 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 // The following compilers don't like "std::byte b1{1}" -// XFAIL: clang-3.5, clang-3.6, clang-3.7, clang-3.8 -// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8.0 +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 // templa
[PATCH] D30643: [OpenCL] Extended diagnostics for atomic initialization
echuraev updated this revision to Diff 93113. echuraev marked 2 inline comments as done. echuraev removed a reviewer: bader. echuraev added a subscriber: bader. https://reviews.llvm.org/D30643 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp lib/Sema/SemaInit.cpp test/Parser/opencl-atomics-cl20.cl test/SemaOpenCL/atomic-init.cl Index: test/SemaOpenCL/atomic-init.cl === --- /dev/null +++ test/SemaOpenCL/atomic-init.cl @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify %s + +global atomic_int a1 = 0; + +kernel void test_atomic_initialization() { + a1 = 1; // expected-error {{atomic variable can only be assigned to a compile time constant and to variables in global adress space}} + atomic_int a2 = 0; // expected-error {{atomic variable can only be assigned to a compile time constant and to variables in global adress space}} + private atomic_int a3 = 0; // expected-error {{atomic variable can only be assigned to a compile time constant and to variables in global adress space}} + local atomic_int a4 = 0; // expected-error {{'__local' variable cannot have an initializer}} + global atomic_int a5 = 0; // expected-error {{function scope variable cannot be declared in global address space}} +} Index: test/Parser/opencl-atomics-cl20.cl === --- test/Parser/opencl-atomics-cl20.cl +++ test/Parser/opencl-atomics-cl20.cl @@ -67,7 +67,7 @@ foo(&i); // OpenCL v2.0 s6.13.11.8, arithemtic operations are not permitted on atomic types. i++; // expected-error {{invalid argument type 'atomic_int' (aka '_Atomic(int)') to unary expression}} - i = 1; // expected-error {{atomic variable can only be assigned to a compile time constant in the declaration statement in the program scope}} + i = 1; // expected-error {{atomic variable can only be assigned to a compile time constant and to variables in global adress space}} i += 1; // expected-error {{invalid operands to binary expression ('atomic_int' (aka '_Atomic(int)') and 'int')}} i = i + i; // expected-error {{invalid operands to binary expression ('atomic_int' (aka '_Atomic(int)') and 'atomic_int')}} } Index: lib/Sema/SemaInit.cpp === --- lib/Sema/SemaInit.cpp +++ lib/Sema/SemaInit.cpp @@ -6502,6 +6502,20 @@ << Init->getSourceRange(); } + // OpenCL v2.0 s6.13.11.1. atomic variables can be initialized in global scope + QualType ETy = Entity.getType(); + Qualifiers TyQualifiers = ETy.getQualifiers(); + bool HasGlobalAS = TyQualifiers.hasAddressSpace() && + TyQualifiers.getAddressSpace() == LangAS::opencl_global; + + if (S.getLangOpts().OpenCLVersion >= 200 && + ETy->isAtomicType() && !HasGlobalAS && + Entity.getKind() == InitializedEntity::EK_Variable && Args.size() > 0) { +S.Diag(Args[0]->getLocStart(), diag::err_opencl_atomic_init) << +SourceRange(Entity.getDecl()->getLocStart(), Args[0]->getLocEnd()); +return ExprError(); + } + // Diagnose cases where we initialize a pointer to an array temporary, and the // pointer obviously outlives the temporary. if (Args.size() == 1 && Args[0]->getType()->isArrayType() && Index: lib/Sema/SemaExpr.cpp === --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -2,7 +2,7 @@ if (LHSTy->isAtomicType() || RHSTy->isAtomicType()) { SourceRange SR(LHSExpr->getLocStart(), RHSExpr->getLocEnd()); if (BO_Assign == Opc) -Diag(OpLoc, diag::err_atomic_init_constant) << SR; +Diag(OpLoc, diag::err_opencl_atomic_init) << SR; else ResultTy = InvalidOperands(OpLoc, LHS, RHS); return ExprError(); Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -8284,9 +8284,8 @@ "return value cannot be qualified with address space">; def err_opencl_constant_no_init : Error< "variable in constant address space must be initialized">; -def err_atomic_init_constant : Error< - "atomic variable can only be assigned to a compile time constant" - " in the declaration statement in the program scope">; +def err_opencl_atomic_init: Error< + "atomic variable can only be assigned to a compile time constant and to variables in global adress space">; def err_opencl_implicit_vector_conversion : Error< "implicit conversions between vector types (%0 and %1) are not permitted">; def err_opencl_invalid_type_array : Error< Index: test/SemaOpenCL/atomic-init.cl === --- /dev/null +++ test/SemaOpenCL/atomic-init.cl @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only
[PATCH] D30547: [clang-tidy] Forwarding reference overload in constructors
JonasToth added a comment. Why does diff contain so many files? Could you maybe merge the latest master into your branch? Repository: rL LLVM https://reviews.llvm.org/D30547 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30547: [clang-tidy] Forwarding reference overload in constructors
leanil updated this revision to Diff 93114. leanil added a comment. Correct earlier diff issue with outdated master. Repository: rL LLVM https://reviews.llvm.org/D30547 Files: clang-tidy/misc/CMakeLists.txt clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp clang-tidy/misc/ForwardingReferenceOverloadCheck.h clang-tidy/misc/MiscTidyModule.cpp docs/ReleaseNotes.rst docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/misc-forwarding-reference-overload.rst test/clang-tidy/misc-forwarding-reference-overload.cpp Index: test/clang-tidy/misc-forwarding-reference-overload.cpp === --- /dev/null +++ test/clang-tidy/misc-forwarding-reference-overload.cpp @@ -0,0 +1,139 @@ +// RUN: %check_clang_tidy %s misc-forwarding-reference-overload %t + +namespace std { +template +struct enable_if {}; + +template +struct enable_if { typedef T type; }; + +template +using enable_if_t = typename enable_if::type; + +template +struct enable_if_nice { typedef T type; }; +} + +namespace foo { +template +struct enable_if { typedef T type; }; +} + +template +constexpr bool just_true = true; + +class Test1 { +public: + template + Test1(T &&n); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide the copy and the move constructors [misc-forwarding-reference-overload] + + template + Test1(T &&n, int i = 5, ...); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide the copy and the move constructors [misc-forwarding-reference-overload] + + template ::type> + Test1(T &&n); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide the copy and the move constructors [misc-forwarding-reference-overload] + + template + Test1(T &&n, typename foo::enable_if::type i = 5, ...); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide the copy and the move constructors [misc-forwarding-reference-overload] + + Test1(const Test1 &other) {} + // CHECK-MESSAGES: :[[@LINE-1]]:3: note: copy constructor declared here + + Test1(Test1 &other) {} + // CHECK-MESSAGES: :[[@LINE-1]]:3: note: copy constructor declared here + + Test1(Test1 &&other) {} + // CHECK-MESSAGES: :[[@LINE-1]]:3: note: move constructor declared here +}; + +template +class Test2 { +public: + // Two parameters without default value, can't act as copy / move constructor. + template + Test2(T &&n, V &&m, int i = 5, ...); + + // Guarded with enable_if. + template + Test2(T &&n, int i = 5, std::enable_if_t a = 5, ...); + + // Guarded with enable_if. + template ::type &> + Test2(T &&n); + + // Guarded with enable_if. + template + Test2(T &&n, typename std::enable_if>::type **a = nullptr); + + // Guarded with enable_if. + template > *&&> + Test2(T &&n, double d = 0.0); + + // Not a forwarding reference parameter. + template + Test2(const T &&n); + + // Not a forwarding reference parameter. + Test2(int &&x); + + // Two parameters without default value, can't act as copy / move constructor. + template + Test2(T &&n, int x); + + // Not a forwarding reference parameter. + template + Test2(U &&n); +}; + +// The copy and the move constructors are both disabled. +class Test3 { +public: + template + Test3(T &&n); + + template + Test3(T &&n, int I = 5, ...); + + Test3(const Test3 &rhs) = delete; + +private: + Test3(Test3 &&rhs); +}; + +// Both the copy and the (compiler generated) move constructors can be hidden. +class Test4 { +public: + template + Test4(T &&n); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide the copy and the move constructors [misc-forwarding-reference-overload] + + Test4(const Test4 &rhs); + // CHECK-MESSAGES: :[[@LINE-1]]:3: note: copy constructor declared here +}; + +// Only the (compiler generated) copy constructor can be hidden. +class Test5 { +public: + template + Test5(T &&n); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide the copy constructor [misc-forwarding-reference-overload] + + Test5(Test5 &&rhs) = delete; +}; + +// Only the move constructor can be hidden. +class Test6 { +public: + template + Test6(T &&n); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide the move constructor [misc-forwarding-reference-overload] + + Test6(Test6 &&rhs); + // CHECK-MESSAGES: :[[@LINE-1]]:3: note: move constructor declared here +private: + Test6(const Test6 &rhs); +}; \ No newline at end of file Index: docs/clang-tidy/checks/misc-forwarding-reference-overload.rst === --- /dev/null +++ docs/clang-tidy/checks/misc-forwarding-reference-overload.rst @@ -0,0 +1,52 @@ +.. title:: clang-tidy - misc-forwarding-reference-overload + +misc-for
[PATCH] D30547: [clang-tidy] Forwarding reference overload in constructors
leanil marked 2 inline comments as done. leanil added inline comments. Comment at: clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp:119 + DisabledMove = false; + for (const auto *OtherCtor : Ctor->getParent()->ctors()) { +if (OtherCtor->isCopyConstructor()) { This is the most precise way to formulate the warning message I could come up with. The condition for excluding either "copy" or "move" from the warning is to find only disabled instances of the constructor type, and there must be at least one, otherwise the compiler generated constructor (which is not present in this enumeration) can be hidden. Repository: rL LLVM https://reviews.llvm.org/D30547 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31153: Add the ability to use the children() range API in a const-correct manner
aaron.ballman added a comment. Ping. Because I expect this to be fairly uncontroversial, I'll give it a week in case folks have comments, then commit (and will handle anything in post-commit review). https://reviews.llvm.org/D31153 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r298842 - Publish one more parser RAII for external use.
Author: vvassilev Date: Mon Mar 27 08:11:32 2017 New Revision: 298842 URL: http://llvm.org/viewvc/llvm-project?rev=298842&view=rev Log: Publish one more parser RAII for external use. Modified: cfe/trunk/include/clang/Parse/RAIIObjectsForParser.h cfe/trunk/lib/Parse/Parser.cpp Modified: cfe/trunk/include/clang/Parse/RAIIObjectsForParser.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/RAIIObjectsForParser.h?rev=298842&r1=298841&r2=298842&view=diff == --- cfe/trunk/include/clang/Parse/RAIIObjectsForParser.h (original) +++ cfe/trunk/include/clang/Parse/RAIIObjectsForParser.h Mon Mar 27 08:11:32 2017 @@ -18,6 +18,7 @@ #include "clang/Parse/ParseDiagnostic.h" #include "clang/Parse/Parser.h" #include "clang/Sema/DelayedDiagnostic.h" +#include "clang/Sema/ParsedTemplate.h" #include "clang/Sema/Sema.h" namespace clang { @@ -442,6 +443,25 @@ namespace clang { void skipToEnd(); }; + /// \brief RAIIObject to destroy the contents of a SmallVector of + /// TemplateIdAnnotation pointers and clear the vector. + class DestroyTemplateIdAnnotationsRAIIObj { +SmallVectorImpl &Container; + + public: +DestroyTemplateIdAnnotationsRAIIObj( +SmallVectorImpl &Container) +: Container(Container) {} + +~DestroyTemplateIdAnnotationsRAIIObj() { + for (SmallVectorImpl::iterator I = + Container.begin(), + E = Container.end(); + I != E; ++I) +(*I)->Destroy(); + Container.clear(); +} + }; } // end namespace clang #endif Modified: cfe/trunk/lib/Parse/Parser.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=298842&r1=298841&r2=298842&view=diff == --- cfe/trunk/lib/Parse/Parser.cpp (original) +++ cfe/trunk/lib/Parse/Parser.cpp Mon Mar 27 08:11:32 2017 @@ -37,26 +37,6 @@ public: return false; } }; - -/// \brief RAIIObject to destroy the contents of a SmallVector of -/// TemplateIdAnnotation pointers and clear the vector. -class DestroyTemplateIdAnnotationsRAIIObj { - SmallVectorImpl &Container; - -public: - DestroyTemplateIdAnnotationsRAIIObj( - SmallVectorImpl &Container) - : Container(Container) {} - - ~DestroyTemplateIdAnnotationsRAIIObj() { -for (SmallVectorImpl::iterator I = - Container.begin(), - E = Container.end(); - I != E; ++I) - (*I)->Destroy(); -Container.clear(); - } -}; } // end anonymous namespace IdentifierInfo *Parser::getSEHExceptKeyword() { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r298676 - Fix handling of initialization from parenthesized initializer list.
Hi Richard, this seems to have an unwanted side-effect on -Wunused-value (test case attached). Could you take a look? Cheers, Daniel On Fri, Mar 24, 2017 at 2:14 AM, Richard Smith via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: rsmith > Date: Thu Mar 23 20:14:25 2017 > New Revision: 298676 > > URL: http://llvm.org/viewvc/llvm-project?rev=298676&view=rev > Log: > Fix handling of initialization from parenthesized initializer list. > > This change fixes a crash on initialization of a reference from ({}) during > template instantiation and incidentally improves diagnostics. > > This reverts a prior attempt to handle this in r286721. Instead, we teach > the > initialization code that initialization cannot be performed if a source > type > is required and the initializer is an initializer list (which is not an > expression and does not have a type), and likewise for function-style cast > expressions. > > Modified: > cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > cfe/trunk/include/clang/Sema/Initialization.h > cfe/trunk/include/clang/Sema/Sema.h > cfe/trunk/lib/Sema/SemaDecl.cpp > cfe/trunk/lib/Sema/SemaExprCXX.cpp > cfe/trunk/lib/Sema/SemaInit.cpp > cfe/trunk/test/SemaCXX/cxx0x-initializer-constructor.cpp > cfe/trunk/test/SemaCXX/cxx0x-initializer-references.cpp > cfe/trunk/test/SemaCXX/cxx0x-initializer-scalars.cpp > cfe/trunk/test/SemaCXX/type-convert-construct.cpp > > Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/ > DiagnosticSemaKinds.td?rev=298676&r1=298675&r2=298676&view=diff > > == > --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) > +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Mar 23 > 20:14:25 2017 > @@ -1814,8 +1814,9 @@ def note_uninit_fixit_remove_cond : Note >"remove the %select{'%1' if its condition|condition if it}0 " >"is always %select{false|true}2">; > def err_init_incomplete_type : Error<"initialization of incomplete type > %0">; > -def err_list_init_in_parens : Error<"list-initializer for non-class type > %0 " > - "must not be parenthesized">; > +def err_list_init_in_parens : Error< > + "cannot initialize %select{non-class|reference}0 type %1 with a " > + "parenthesized initializer list">; > > def warn_unsequenced_mod_mod : Warning< >"multiple unsequenced modifications to %0">, InGroup; > @@ -5865,8 +5866,8 @@ def err_builtin_func_cast_more_than_one_ >"function-style cast to a builtin type can only take one argument">; > def err_value_init_for_array_type : Error< >"array types cannot be value-initialized">; > -def err_value_init_for_function_type : Error< > - "function types cannot be value-initialized">; > +def err_init_for_function_type : Error< > + "cannot create object of function type %0">; > def warn_format_nonliteral_noargs : Warning< >"format string is not a string literal (potentially insecure)">, >InGroup; > > Modified: cfe/trunk/include/clang/Sema/Initialization.h > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/ > clang/Sema/Initialization.h?rev=298676&r1=298675&r2=298676&view=diff > > == > --- cfe/trunk/include/clang/Sema/Initialization.h (original) > +++ cfe/trunk/include/clang/Sema/Initialization.h Thu Mar 23 20:14:25 2017 > @@ -822,6 +822,8 @@ public: >enum FailureKind { > /// \brief Too many initializers provided for a reference. > FK_TooManyInitsForReference, > +/// \brief Reference initialized from a parenthesized initializer > list. > +FK_ParenthesizedListInitForReference, > /// \brief Array must be initialized with an initializer list. > FK_ArrayNeedsInitList, > /// \brief Array must be initialized with an initializer list or a > @@ -866,6 +868,8 @@ public: > FK_ConversionFromPropertyFailed, > /// \brief Too many initializers for scalar > FK_TooManyInitsForScalar, > +/// \brief Scalar initialized from a parenthesized initializer list. > +FK_ParenthesizedListInitForScalar, > /// \brief Reference initialization from an initializer list > FK_ReferenceBindingToInitList, > /// \brief Initialization of some unused destination type with an > @@ -892,7 +896,7 @@ public: > /// having its address taken. > FK_AddressOfUnaddressableFunction, > /// \brief List-copy-initialization chose an explicit constructor. > -FK_ExplicitConstructor > +FK_ExplicitConstructor, >}; > > private: > > Modified: cfe/trunk/include/clang/Sema/Sema.h > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/ > clang/Sema/Sema.h?rev=298676&r1=298675&r2=298676&view=diff > > == > --- cfe/trunk/include/clang/Sema/Sema.h (original) > +++ cfe/tru
[PATCH] D31183: [OpenCL] Added parsing for OpenCL vector types.
Anastasia added a comment. I don't think that diagnostics can always be very clear. This is not the case neither for C nor C++. As I said I don't see any issue to continue with this patch. I would just like to see the test simplified a bit. https://reviews.llvm.org/D31183 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r298676 - Fix handling of initialization from parenthesized initializer list.
What is the effect on that testcase? (Sorry, heading to vacation and can't easily check.) On 27 Mar 2017 6:33 am, "Daniel Jasper" wrote: > Hi Richard, > > this seems to have an unwanted side-effect on -Wunused-value (test case > attached). Could you take a look? > > Cheers, > Daniel > > On Fri, Mar 24, 2017 at 2:14 AM, Richard Smith via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: rsmith >> Date: Thu Mar 23 20:14:25 2017 >> New Revision: 298676 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=298676&view=rev >> Log: >> Fix handling of initialization from parenthesized initializer list. >> >> This change fixes a crash on initialization of a reference from ({}) >> during >> template instantiation and incidentally improves diagnostics. >> >> This reverts a prior attempt to handle this in r286721. Instead, we teach >> the >> initialization code that initialization cannot be performed if a source >> type >> is required and the initializer is an initializer list (which is not an >> expression and does not have a type), and likewise for function-style cast >> expressions. >> >> Modified: >> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td >> cfe/trunk/include/clang/Sema/Initialization.h >> cfe/trunk/include/clang/Sema/Sema.h >> cfe/trunk/lib/Sema/SemaDecl.cpp >> cfe/trunk/lib/Sema/SemaExprCXX.cpp >> cfe/trunk/lib/Sema/SemaInit.cpp >> cfe/trunk/test/SemaCXX/cxx0x-initializer-constructor.cpp >> cfe/trunk/test/SemaCXX/cxx0x-initializer-references.cpp >> cfe/trunk/test/SemaCXX/cxx0x-initializer-scalars.cpp >> cfe/trunk/test/SemaCXX/type-convert-construct.cpp >> >> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ >> Basic/DiagnosticSemaKinds.td?rev=298676&r1=298675&r2=298676&view=diff >> >> == >> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) >> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Mar 23 >> 20:14:25 2017 >> @@ -1814,8 +1814,9 @@ def note_uninit_fixit_remove_cond : Note >>"remove the %select{'%1' if its condition|condition if it}0 " >>"is always %select{false|true}2">; >> def err_init_incomplete_type : Error<"initialization of incomplete type >> %0">; >> -def err_list_init_in_parens : Error<"list-initializer for non-class type >> %0 " >> - "must not be parenthesized">; >> +def err_list_init_in_parens : Error< >> + "cannot initialize %select{non-class|reference}0 type %1 with a " >> + "parenthesized initializer list">; >> >> def warn_unsequenced_mod_mod : Warning< >>"multiple unsequenced modifications to %0">, InGroup; >> @@ -5865,8 +5866,8 @@ def err_builtin_func_cast_more_than_one_ >>"function-style cast to a builtin type can only take one argument">; >> def err_value_init_for_array_type : Error< >>"array types cannot be value-initialized">; >> -def err_value_init_for_function_type : Error< >> - "function types cannot be value-initialized">; >> +def err_init_for_function_type : Error< >> + "cannot create object of function type %0">; >> def warn_format_nonliteral_noargs : Warning< >>"format string is not a string literal (potentially insecure)">, >>InGroup; >> >> Modified: cfe/trunk/include/clang/Sema/Initialization.h >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ >> Sema/Initialization.h?rev=298676&r1=298675&r2=298676&view=diff >> >> == >> --- cfe/trunk/include/clang/Sema/Initialization.h (original) >> +++ cfe/trunk/include/clang/Sema/Initialization.h Thu Mar 23 20:14:25 >> 2017 >> @@ -822,6 +822,8 @@ public: >>enum FailureKind { >> /// \brief Too many initializers provided for a reference. >> FK_TooManyInitsForReference, >> +/// \brief Reference initialized from a parenthesized initializer >> list. >> +FK_ParenthesizedListInitForReference, >> /// \brief Array must be initialized with an initializer list. >> FK_ArrayNeedsInitList, >> /// \brief Array must be initialized with an initializer list or a >> @@ -866,6 +868,8 @@ public: >> FK_ConversionFromPropertyFailed, >> /// \brief Too many initializers for scalar >> FK_TooManyInitsForScalar, >> +/// \brief Scalar initialized from a parenthesized initializer list. >> +FK_ParenthesizedListInitForScalar, >> /// \brief Reference initialization from an initializer list >> FK_ReferenceBindingToInitList, >> /// \brief Initialization of some unused destination type with an >> @@ -892,7 +896,7 @@ public: >> /// having its address taken. >> FK_AddressOfUnaddressableFunction, >> /// \brief List-copy-initialization chose an explicit constructor. >> -FK_ExplicitConstructor >> +FK_ExplicitConstructor, >>}; >> >> private: >> >> Modified: cfe/trunk/include/clang/Sema/Sema.h >> URL:
Re: r298676 - Fix handling of initialization from parenthesized initializer list.
-Wunused-value is always triggered if a constructor of an object with a non-trivial destructor has an initializer list as first parameter. So in the test, even "Used({});" triggers -Wunused-value. That seems inconsistent (replacing the init list with something else silences the warning) and also there is a code pattern where this is used to construct and immediately destruct an object. On Mon, Mar 27, 2017 at 3:49 PM, Richard Smith wrote: > What is the effect on that testcase? (Sorry, heading to vacation and can't > easily check.) > > On 27 Mar 2017 6:33 am, "Daniel Jasper" wrote: > >> Hi Richard, >> >> this seems to have an unwanted side-effect on -Wunused-value (test case >> attached). Could you take a look? >> >> Cheers, >> Daniel >> >> On Fri, Mar 24, 2017 at 2:14 AM, Richard Smith via cfe-commits < >> cfe-commits@lists.llvm.org> wrote: >> >>> Author: rsmith >>> Date: Thu Mar 23 20:14:25 2017 >>> New Revision: 298676 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=298676&view=rev >>> Log: >>> Fix handling of initialization from parenthesized initializer list. >>> >>> This change fixes a crash on initialization of a reference from ({}) >>> during >>> template instantiation and incidentally improves diagnostics. >>> >>> This reverts a prior attempt to handle this in r286721. Instead, we >>> teach the >>> initialization code that initialization cannot be performed if a source >>> type >>> is required and the initializer is an initializer list (which is not an >>> expression and does not have a type), and likewise for function-style >>> cast >>> expressions. >>> >>> Modified: >>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td >>> cfe/trunk/include/clang/Sema/Initialization.h >>> cfe/trunk/include/clang/Sema/Sema.h >>> cfe/trunk/lib/Sema/SemaDecl.cpp >>> cfe/trunk/lib/Sema/SemaExprCXX.cpp >>> cfe/trunk/lib/Sema/SemaInit.cpp >>> cfe/trunk/test/SemaCXX/cxx0x-initializer-constructor.cpp >>> cfe/trunk/test/SemaCXX/cxx0x-initializer-references.cpp >>> cfe/trunk/test/SemaCXX/cxx0x-initializer-scalars.cpp >>> cfe/trunk/test/SemaCXX/type-convert-construct.cpp >>> >>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td >>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ >>> Basic/DiagnosticSemaKinds.td?rev=298676&r1=298675&r2=298676&view=diff >>> >>> == >>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) >>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Mar 23 >>> 20:14:25 2017 >>> @@ -1814,8 +1814,9 @@ def note_uninit_fixit_remove_cond : Note >>>"remove the %select{'%1' if its condition|condition if it}0 " >>>"is always %select{false|true}2">; >>> def err_init_incomplete_type : Error<"initialization of incomplete type >>> %0">; >>> -def err_list_init_in_parens : Error<"list-initializer for non-class >>> type %0 " >>> - "must not be parenthesized">; >>> +def err_list_init_in_parens : Error< >>> + "cannot initialize %select{non-class|reference}0 type %1 with a " >>> + "parenthesized initializer list">; >>> >>> def warn_unsequenced_mod_mod : Warning< >>>"multiple unsequenced modifications to %0">, InGroup; >>> @@ -5865,8 +5866,8 @@ def err_builtin_func_cast_more_than_one_ >>>"function-style cast to a builtin type can only take one argument">; >>> def err_value_init_for_array_type : Error< >>>"array types cannot be value-initialized">; >>> -def err_value_init_for_function_type : Error< >>> - "function types cannot be value-initialized">; >>> +def err_init_for_function_type : Error< >>> + "cannot create object of function type %0">; >>> def warn_format_nonliteral_noargs : Warning< >>>"format string is not a string literal (potentially insecure)">, >>>InGroup; >>> >>> Modified: cfe/trunk/include/clang/Sema/Initialization.h >>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ >>> Sema/Initialization.h?rev=298676&r1=298675&r2=298676&view=diff >>> >>> == >>> --- cfe/trunk/include/clang/Sema/Initialization.h (original) >>> +++ cfe/trunk/include/clang/Sema/Initialization.h Thu Mar 23 20:14:25 >>> 2017 >>> @@ -822,6 +822,8 @@ public: >>>enum FailureKind { >>> /// \brief Too many initializers provided for a reference. >>> FK_TooManyInitsForReference, >>> +/// \brief Reference initialized from a parenthesized initializer >>> list. >>> +FK_ParenthesizedListInitForReference, >>> /// \brief Array must be initialized with an initializer list. >>> FK_ArrayNeedsInitList, >>> /// \brief Array must be initialized with an initializer list or a >>> @@ -866,6 +868,8 @@ public: >>> FK_ConversionFromPropertyFailed, >>> /// \brief Too many initializers for scalar >>> FK_TooManyInitsForScalar, >>> +/// \brief Scalar initialized from a parenthesized initializer list. >
[PATCH] D31397: [Bug 25404] Fix crash on typedef in OpenCL 2.0
Anastasia created this revision. Herald added a subscriber: yaxunl. Fixing the assertion due to absence of source location for implicitly defined types (using addImplicitTypedef()). During Sema checks the source location is being expected and therefore an assertion is triggered. The change is not specific to OpenCL. But it is particular common for OpenCL types to be declared implicitly in Clang to support the mode without standard header. https://reviews.llvm.org/D31397 Files: lib/Sema/SemaDecl.cpp test/SemaOpenCL/types.cl Index: test/SemaOpenCL/types.cl === --- /dev/null +++ test/SemaOpenCL/types.cl @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only + +// expected-no-diagnostics + +// Check redefinition of standard types +typedef atomic_int atomic_flag; Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -2154,7 +2154,9 @@ // -Wtypedef-redefinition. If either the original or the redefinition is // in a system header, don't emit this for compatibility with GCC. if (getDiagnostics().getSuppressSystemWarnings() && - (Context.getSourceManager().isInSystemHeader(Old->getLocation()) || + // Some standard types are defined implicitly in Clang (e.g. OpenCL). + (Old->isImplicit() || New->isImplicit() || + Context.getSourceManager().isInSystemHeader(Old->getLocation()) || Context.getSourceManager().isInSystemHeader(New->getLocation( return; Index: test/SemaOpenCL/types.cl === --- /dev/null +++ test/SemaOpenCL/types.cl @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only + +// expected-no-diagnostics + +// Check redefinition of standard types +typedef atomic_int atomic_flag; Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -2154,7 +2154,9 @@ // -Wtypedef-redefinition. If either the original or the redefinition is // in a system header, don't emit this for compatibility with GCC. if (getDiagnostics().getSuppressSystemWarnings() && - (Context.getSourceManager().isInSystemHeader(Old->getLocation()) || + // Some standard types are defined implicitly in Clang (e.g. OpenCL). + (Old->isImplicit() || New->isImplicit() || + Context.getSourceManager().isInSystemHeader(Old->getLocation()) || Context.getSourceManager().isInSystemHeader(New->getLocation( return; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31183: [OpenCL] Added parsing for OpenCL vector types.
echuraev updated this revision to Diff 93132. echuraev marked an inline comment as done. https://reviews.llvm.org/D31183 Files: include/clang/Parse/Parser.h lib/Parse/ParseExpr.cpp test/Parser/vector-cast-define.cl Index: test/Parser/vector-cast-define.cl === --- /dev/null +++ test/Parser/vector-cast-define.cl @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only +// expected-no-diagnostics + +typedef int int3 __attribute__((ext_vector_type(3))); + +void test() +{ +int index = (int3)(1, 2, 3).x * (int3)(3, 2, 1).y; +} + Index: lib/Parse/ParseExpr.cpp === --- lib/Parse/ParseExpr.cpp +++ lib/Parse/ParseExpr.cpp @@ -473,12 +473,14 @@ /// ExprResult Parser::ParseCastExpression(bool isUnaryExpression, bool isAddressOfOperand, - TypeCastState isTypeCast) { + TypeCastState isTypeCast, + bool isVectorLiteral) { bool NotCastExpr; ExprResult Res = ParseCastExpression(isUnaryExpression, isAddressOfOperand, NotCastExpr, - isTypeCast); + isTypeCast, + isVectorLiteral); if (NotCastExpr) Diag(Tok, diag::err_expected_expression); return Res; @@ -694,7 +696,8 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, bool isAddressOfOperand, bool &NotCastExpr, - TypeCastState isTypeCast) { + TypeCastState isTypeCast, + bool isVectorLiteral) { ExprResult Res; tok::TokenKind SavedKind = Tok.getKind(); NotCastExpr = false; @@ -722,6 +725,9 @@ Res = ParseParenExpression(ParenExprType, false/*stopIfCastExr*/, isTypeCast == IsTypeCast, CastTy, RParenLoc); +if (isVectorLiteral) +return Res; + switch (ParenExprType) { case SimpleExpr: break;// Nothing else to do. case CompoundStmt: break; // Nothing else to do. @@ -2350,6 +2356,48 @@ return ParseCompoundLiteralExpression(Ty.get(), OpenLoc, RParenLoc); } + if (Tok.is(tok::l_paren)) { +// This could be OpenCL vector Literals +if (getLangOpts().OpenCL) +{ + TypeResult Ty; + { +InMessageExpressionRAIIObject InMessage(*this, false); +Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); + } + if(Ty.isInvalid()) + { + return ExprError(); + } + QualType QT = Ty.get().get().getCanonicalType(); + if (QT->isVectorType()) + { +// We parsed '(' vector-type-name ')' followed by '(' + +// Parse the cast-expression that follows it next. +// isVectorLiteral = true will make sure we don't parse any +// Postfix expression yet +Result = ParseCastExpression(/*isUnaryExpression=*/false, + /*isAddressOfOperand=*/false, + /*isTypeCast=*/IsTypeCast, + /*isVectorLiteral=*/true); + +if (!Result.isInvalid()) { + Result = Actions.ActOnCastExpr(getCurScope(), OpenLoc, + DeclaratorInfo, CastTy, + RParenLoc, Result.get()); +} + +// After we performed the cast we can check for postfix-expr pieces. +if (!Result.isInvalid()) { + Result = ParsePostfixExpressionSuffix(Result); +} + +return Result; + } +} + } + if (ExprType == CastExpr) { // We parsed '(' type-name ')' and the thing after it wasn't a '{'. @@ -2379,10 +2427,13 @@ } // Parse the cast-expression that follows it next. +// isVectorLiteral = true will make sure we don't parse any +// Postfix expression yet // TODO: For cast expression with CastTy. Result = ParseCastExpression(/*isUnaryExpression=*/false, /*isAddressOfOperand=*/false, - /*isTypeCast=*/IsTypeCast); + /*isTypeCast=*/IsTypeCast, + /*isVectorLiteral=*/true); if (!Result.isInvalid()) { Result = Actions.ActOnCastExpr(getCurScope(), OpenLoc, DeclaratorInfo, CastTy, Index: include/c
[PATCH] D31166: Encapsulate FPOptions and use it consistently
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM! Comment at: lib/CodeGen/CGExprScalar.cpp:1712 BinOp.Opcode = IsInc ? BO_Add : BO_Sub; - BinOp.FPContractable = false; + // FIXME: once UnaryOperator carries FPFeatures, copy it here. BinOp.E = E; anemet wrote: > aaron.ballman wrote: > > Why not make UnaryOperator carry this information now, since it's needed? > The trouble is that currently it's not needed. I'd rather wait for a > fast-math flag that actually needs it so that we can write tests. That seems sensible to me, thank you for the explanation. https://reviews.llvm.org/D31166 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31308: [clang-tidy] new check readability-no-alternative-tokens
aaron.ballman added inline comments. Comment at: clang-tidy/readability/OperatorsRepresentationCheck.cpp:34 + + if (const auto *B = Result.Nodes.getNodeAs("binary")) { +switch (B->getOpcode()) { I think this would make more sense lifted into an AST matcher -- there are bound to be a *lot* of binary operators, so letting the matcher memoize things is likely to give better performance. Comment at: clang-tidy/readability/OperatorsRepresentationCheck.cpp:68 + if (PrimarySpelling != Spelling) { +diag(OpLoc, "operator uses alternative spelling") +<< FixItHint::CreateReplacement(TokenRange, PrimarySpelling); This diagnostic doesn't help the user to understand what's wrong with their code (especially in the presence of multiple operators). Perhaps "'%0' is an alternative token spelling; consider using '%1'" It would be nice if we could say "consider using %1 for ", but I'm really not certain why we would diagnose this code in the first place (it's purely a matter of stylistic choice, as I understand it). Comment at: docs/clang-tidy/checks/readability-operators-representation.rst:4 +readability-operators-representation += + This underline is going to cause Sphinx diagnostics. Comment at: docs/clang-tidy/checks/readability-operators-representation.rst:8 +such as ``not`` (for ``!``), ``bitand`` (for ``&``), ``or`` (for ``||``) or ``not_eq`` +(for ``!=``). Why would someone want to do this? You should at least touch on that in the documentation. Also, this doesn't read very clearly to me. Perhaps it would be better as a table with two columns, the first specifying the alternative token spelling and the second specifying the replacement (with suitable headings), Comment at: test/clang-tidy/readability-operators-representation.cpp:54 + c = !a;// OK +} Please add a test where a class overloads the operators. For special fun: ``` struct S { friend S& operator and(const S &LHS, const S &RHS); }; int main() { S s1, s2; S s3 = s1 and s2; } ``` I'm not convinced the correct answer here is to tell the user to use a spelling that isn't used by the class definition... https://reviews.llvm.org/D31308 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31153: Add the ability to use the children() range API in a const-correct manner
dblaikie added a comment. As I mentioned to Craig Topper recently on another review, generally when implementing const and non-const overloads the non-const is implemented in terms of the const overload (& const_casts away const on the result). This ensures no UB if the const overload is called on a truly const object. Even if there aren't any truly const Stmts today, I'd still prefer the code be written so as not to assume they couldn't exist. https://reviews.llvm.org/D31153 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D18914: [clang-tidy] new readability-redundant-inline
aaron.ballman added inline comments. Comment at: clang-tidy/readability/RedundantInlineCheck.cpp:24 +AST_MATCHER(FriendDecl, isInlineAndHasBody) { + NamedDecl *D = Node.getFriendDecl(); + if (!D) const NamedDecl (same for const auto * below). Comment at: clang-tidy/readability/RedundantInlineCheck.cpp:46 +// Re-lex the tokens to get precise location of 'inline' +static Optional InlineTok(CharSourceRange Range, const MatchFinder::MatchResult &Result) { + const SourceManager &Sources = *Result.SourceManager; 80 col limit? Should just run clang-format over the whole patch. Comment at: clang-tidy/readability/RedundantInlineCheck.cpp:103-106 + if (Tok) +diag(Loc, Msg) << FixItHint::CreateRemoval(CharSourceRange::getTokenRange(Tok->getLocation(), Tok->getLocation())); + else +diag(Loc, Msg); I think that you should always emit a PartialDiagnostic and then if Tok, add the FixItHint -- it should make it more clear what's going on. Comment at: clang-tidy/readability/RedundantInlineCheck.h:19 + +/// Flags redundant 'inline' when used on a method with inline body or on a constexpr function. +/// with inline body -> with an inline body Comment at: test/clang-tidy/readability-redundant-inline.cpp:6 +// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 'inline' is redundant because method body is defined inside class [readability-redundant-inline] +// CHECK-FIXES: {{^}} int f1() +return 0; mgehre wrote: > Personally, I never use "inline" to mean anything else than "multiple > definitions can appear". I didn't know that > compilers still respected this. > > Does that mean that the whole checker is useless? I don't think it means that this checker is useless, but we should definitely make sure that the checker isn't suggesting changes that have unintended impact like this. Perhaps there's a way to have a test which generates llvm ir for the original code and compares it against llvm ir generated after automatically applying all fixits to ensure the salient data are the same? That would also make this check a bit more forward-compatible with anyone who changes the behavior of where we specify `inlinehint`. Comment at: test/clang-tidy/readability-redundant-inline.cpp:77 + return 1; +} You should add a template test, because explicit specializations are special. ``` template struct S { void f(); } template void S::f() {} // implicitly inline template <> void S::f() {} // Not implicitly inline ``` https://reviews.llvm.org/D18914 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r298850 - [ARM] Add a driver option for +no-neg-immediates
Author: sanwou01 Date: Mon Mar 27 10:34:52 2017 New Revision: 298850 URL: http://llvm.org/viewvc/llvm-project?rev=298850&view=rev Log: [ARM] Add a driver option for +no-neg-immediates Reviewers: olista01, rengolin, javed.absar, samparker Reviewed By: samparker Subscribers: samparker, llvm-commits, aemerson Differential Revision: https://reviews.llvm.org/D31197 Added: cfe/trunk/test/Driver/arm-no-neg-immediates.c Modified: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=298850&r1=298849&r2=298850&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Mon Mar 27 10:34:52 2017 @@ -1760,6 +1760,8 @@ def mcrc : Flag<["-"], "mcrc">, Group; def mnocrc : Flag<["-"], "mnocrc">, Group, HelpText<"Disallow use of CRC instructions (ARM only)">; +def mno_neg_immediates: Flag<["-"], "mno-neg-immediates">, Group, + HelpText<"Disallow converting instructions with negative immediates to their negation or inversion.">; def mgeneral_regs_only : Flag<["-"], "mgeneral-regs-only">, Group, HelpText<"Generate code which only uses the general purpose registers (AArch64 only)">; Modified: cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp?rev=298850&r1=298849&r2=298850&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp Mon Mar 27 10:34:52 2017 @@ -193,4 +193,7 @@ void aarch64::getAArch64TargetFeatures(c if (Args.hasArg(options::OPT_ffixed_x18)) Features.push_back("+reserve-x18"); + + if (Args.hasArg(options::OPT_mno_neg_immediates)) +Features.push_back("+no-neg-immediates"); } Modified: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp?rev=298850&r1=298849&r2=298850&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp Mon Mar 27 10:34:52 2017 @@ -449,6 +449,9 @@ void arm::getARMTargetFeatures(const Too // The kext linker doesn't know how to deal with movw/movt. if (KernelOrKext || Args.hasArg(options::OPT_mno_movt)) Features.push_back("+no-movt"); + + if (Args.hasArg(options::OPT_mno_neg_immediates)) +Features.push_back("+no-neg-immediates"); } const std::string arm::getARMArch(StringRef Arch, const llvm::Triple &Triple) { Added: cfe/trunk/test/Driver/arm-no-neg-immediates.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-no-neg-immediates.c?rev=298850&view=auto == --- cfe/trunk/test/Driver/arm-no-neg-immediates.c (added) +++ cfe/trunk/test/Driver/arm-no-neg-immediates.c Mon Mar 27 10:34:52 2017 @@ -0,0 +1,8 @@ +// RUN: %clang -target arm-none-gnueabi -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT +// RUN: %clang -target arm-none-gnueabi -mno-neg-immediates -### %s 2>&1 | FileCheck %s + +// RUN: %clang -target aarch64-none-gnueabi -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT +// RUN: %clang -target aarch64-none-gnueabi -mno-neg-immediates -### %s 2>&1 | FileCheck %s + +// CHECK: "-target-feature" "+no-neg-immediates" +// CHECK-DEFAULT-NOT: "+no-neg-immediates" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31004: [Objective-C] Fix __weak type traits with -fobjc-weak
bkelley added a comment. Thank you @rjmccall for the approval. I don't have commit access; would someone be willing to commit this path for me please? Thanks! https://reviews.llvm.org/D31004 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31005: [Objective-C] Fix "repeated use of weak" warning with -fobjc-weak
bkelley added a comment. Thank you @rjmccall for the approval. I don't have commit access; would someone be willing to commit this path for me please? Thanks! https://reviews.llvm.org/D31005 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31003: [Objective-C] C++ Classes with __weak Members non-POD Types when using -fobjc-weak
bkelley added a comment. Thank you @rjmccall for the approval. I don't have commit access; would someone be willing to commit this path for me please? Thanks! https://reviews.llvm.org/D31003 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31006: [Objective-C] Fix "weak-unavailable" warning with -fobjc-weak
bkelley added a comment. Thank you @rjmccall for the approval. I don't have commit access; would someone be willing to commit this path for me please? Thanks! https://reviews.llvm.org/D31006 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31007: [Objective-C] Miscellaneous -fobjc-weak Fixes
bkelley added a comment. Thank you @rjmccall for the approval. I don't have commit access; would someone be willing to commit this path for me please? Thanks! https://reviews.llvm.org/D31007 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r298853 - Look through CXXBindTemporaryExprs when checking CXXFunctionCastExprs
Author: djasper Date: Mon Mar 27 11:29:41 2017 New Revision: 298853 URL: http://llvm.org/viewvc/llvm-project?rev=298853&view=rev Log: Look through CXXBindTemporaryExprs when checking CXXFunctionCastExprs for unused values. This fixes a regression caused by r298676, where constructor calls to classes with non-trivial dtor were marked as unused if the first argument is an initializer list. This is inconsistent (as the test shows) and also warns on a reasonbly common code pattern where people just call constructors to create and immediately destroy an object. Modified: cfe/trunk/lib/Sema/SemaStmt.cpp cfe/trunk/test/SemaCXX/warn-unused-value.cpp Modified: cfe/trunk/lib/Sema/SemaStmt.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=298853&r1=298852&r2=298853&view=diff == --- cfe/trunk/lib/Sema/SemaStmt.cpp (original) +++ cfe/trunk/lib/Sema/SemaStmt.cpp Mon Mar 27 11:29:41 2017 @@ -290,9 +290,15 @@ void Sema::DiagnoseUnusedExprResult(cons DiagID = diag::warn_unused_property_expr; } else if (const CXXFunctionalCastExpr *FC = dyn_cast(E)) { -if (isa(FC->getSubExpr()) || -isa(FC->getSubExpr())) +const Expr *E = FC->getSubExpr(); +if (const CXXBindTemporaryExpr *TE = dyn_cast(E)) + E = TE->getSubExpr(); +if (isa(E)) return; +if (const CXXConstructExpr *CE = dyn_cast(E)) + if (const CXXRecordDecl *RD = CE->getType()->getAsCXXRecordDecl()) +if (!RD->getAttr()) + return; } // Diagnose "(void*) blah" as a typo for "(void) blah". else if (const CStyleCastExpr *CE = dyn_cast(E)) { Modified: cfe/trunk/test/SemaCXX/warn-unused-value.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-value.cpp?rev=298853&r1=298852&r2=298853&view=diff == --- cfe/trunk/test/SemaCXX/warn-unused-value.cpp (original) +++ cfe/trunk/test/SemaCXX/warn-unused-value.cpp Mon Mar 27 11:29:41 2017 @@ -59,11 +59,13 @@ struct Used { Used(); Used(int); Used(int, int); + ~Used() {} }; struct __attribute__((warn_unused)) Unused { Unused(); Unused(int); Unused(int, int); + ~Unused() {} }; void f() { Used(); @@ -72,6 +74,10 @@ void f() { Unused(); // expected-warning {{expression result unused}} Unused(1);// expected-warning {{expression result unused}} Unused(1, 1); // expected-warning {{expression result unused}} +#if __cplusplus >= 201103L // C++11 or later + Used({}); + Unused({}); // expected-warning {{expression result unused}} +#endif } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31399: [coroutines] Handle get_return_object_on_allocation_failure
GorNishanov created this revision. Herald added a subscriber: mehdi_amini. If promise_type has get_return_object_on_allocation_failure defined, check if an allocation function returns nullptr, and if so, return the result of get_return_object_on_allocation_failure(). https://reviews.llvm.org/D31399 Files: include/clang/AST/StmtCXX.h lib/AST/StmtCXX.cpp lib/CodeGen/CGCoroutine.cpp lib/Sema/SemaCoroutine.cpp test/CodeGenCoroutines/coro-alloc.cpp Index: test/CodeGenCoroutines/coro-alloc.cpp === --- test/CodeGenCoroutines/coro-alloc.cpp +++ test/CodeGenCoroutines/coro-alloc.cpp @@ -40,7 +40,7 @@ }; }; -// CHECK-LABEL: f0( +// CHECK-LABEL: f0( extern "C" void f0(global_new_delete_tag) { // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16 // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64() @@ -65,7 +65,7 @@ }; }; -// CHECK-LABEL: f1( +// CHECK-LABEL: f1( extern "C" void f1(promise_new_tag ) { // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16 // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64() @@ -90,7 +90,7 @@ }; }; -// CHECK-LABEL: f2( +// CHECK-LABEL: f2( extern "C" void f2(promise_delete_tag) { // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16 // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64() @@ -127,3 +127,30 @@ // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJv24promise_sized_delete_tagEE12promise_typedlEPvm(i8* %[[MEM]], i64 %[[SIZE2]]) co_return; } + +struct promise_on_alloc_failure_tag {}; + +template<> +struct std::experimental::coroutine_traits { + struct promise_type { +int get_return_object() {} +suspend_always initial_suspend() { return {}; } +suspend_always final_suspend() { return {}; } +void return_void() {} +static int get_return_object_on_allocation_failure() { return -1; } + }; +}; + +// CHECK-LABEL: f4( +extern "C" int f4(promise_on_alloc_failure_tag) { + // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16 + // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64() + // CHECK: %[[MEM:.+]] = call i8* @_Znwm(i64 %[[SIZE]]) + // CHECK: %[[OK:.+]] = icmp ne i8* %[[MEM]], null + // CHECK: br i1 %[[OK]], label %[[OKBB:.+]], label %[[ERRBB:.+]] + + // CHECK: [[ERRBB]]: + // CHECK: %[[RETVAL:.+]] = call i32 @_ZNSt12experimental16coroutine_traitsIJi28promise_on_alloc_failure_tagEE12promise_type39get_return_object_on_allocation_failureEv( + // CHECK: ret i32 %[[RETVAL]] + co_return; +} Index: lib/Sema/SemaCoroutine.cpp === --- lib/Sema/SemaCoroutine.cpp +++ lib/Sema/SemaCoroutine.cpp @@ -708,8 +708,8 @@ } this->IsValid = makePromiseStmt() && makeInitialAndFinalSuspend() && makeOnException() && makeOnFallthrough() && -makeNewAndDeleteExpr() && makeReturnObject() && -makeParamMoves(); +makeReturnOnAllocFailure() && makeNewAndDeleteExpr() && +makeReturnObject() && makeParamMoves(); } bool isInvalid() const { return !this->IsValid; } @@ -720,6 +720,7 @@ bool makeOnFallthrough(); bool makeOnException(); bool makeReturnObject(); + bool makeReturnOnAllocFailure(); bool makeParamMoves(); }; } @@ -777,6 +778,40 @@ return true; } +bool SubStmtBuilder::makeReturnOnAllocFailure() { + if (!PromiseRecordDecl) return true; + + // [dcl.fct.def.coroutine]/8 + // The unqualified-id get_return_object_on_allocation_failure is looked up in + // the scope of class P by class member access lookup (3.4.5). ... + // If an allocation function returns nullptr, ... the coroutine return value + // is obtained by a call to ... get_return_object_on_allocation_failure(). + + DeclarationName DN = + S.PP.getIdentifierInfo("get_return_object_on_allocation_failure"); + LookupResult Found(S, DN, Loc, Sema::LookupMemberName); + // Suppress diagnostics when a private member is selected. The same warnings + // will be produced again when building the call. + Found.suppressDiagnostics(); + if (!S.LookupQualifiedName(Found, PromiseRecordDecl)) return true; + + CXXScopeSpec SS; + ExprResult DeclNameExpr = + S.BuildDeclarationNameExpr(SS, Found, /*NeedsADL=*/false); + if (DeclNameExpr.isInvalid()) return false; + + ExprResult ReturnObjectOnAllocationFailure = + S.ActOnCallExpr(nullptr, DeclNameExpr.get(), Loc, {}, Loc); + if (ReturnObjectOnAllocationFailure.isInvalid()) return false; + + StmtResult ReturnStmt = S.ActOnReturnStmt( + Loc, ReturnObjectOnAllocationFailure.get(), S.getCurScope()); + if (ReturnStmt.isInvalid()) return false; + + this->ReturnStmtOnAllocFailure = ReturnStmt.get(); + return true; +} + bool SubStmtBuilder::makeNewAndDeleteExpr() { // Form and check allocation and deallocation calls. QualType PromiseType = Fn.CoroutinePromise->getType(); @@ -786,7 +821,8 @@ if (S.RequireComplet
[PATCH] D31308: [clang-tidy] new check readability-no-alternative-tokens
alexfh added inline comments. Comment at: clang-tidy/readability/OperatorsRepresentationCheck.cpp:34 + + if (const auto *B = Result.Nodes.getNodeAs("binary")) { +switch (B->getOpcode()) { aaron.ballman wrote: > I think this would make more sense lifted into an AST matcher -- there are > bound to be a *lot* of binary operators, so letting the matcher memoize > things is likely to give better performance. Any reasons not to do this on the lexer level? https://reviews.llvm.org/D31308 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31308: [clang-tidy] new check readability-no-alternative-tokens
aaron.ballman added inline comments. Comment at: clang-tidy/readability/OperatorsRepresentationCheck.cpp:34 + + if (const auto *B = Result.Nodes.getNodeAs("binary")) { +switch (B->getOpcode()) { alexfh wrote: > aaron.ballman wrote: > > I think this would make more sense lifted into an AST matcher -- there are > > bound to be a *lot* of binary operators, so letting the matcher memoize > > things is likely to give better performance. > Any reasons not to do this on the lexer level? Technical reasons? None. User-experience reasons? We wouldn't want this to be on by default (I don't think) and we usually don't implement off-by-default diagnostics in Clang. I think a case could be made for doing it in the Lexer if the performance is really that bad with a clang-tidy check and we couldn't improve it here, though. https://reviews.llvm.org/D31308 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI
ahatanak added a comment. Is it possible to enable cantunwind for one function and enable for another? If so, does this have to be a function attribute? https://reviews.llvm.org/D31140 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31397: [Bug 25404] Fix crash on typedef in OpenCL 2.0
ahatanak added inline comments. Comment at: lib/Sema/SemaDecl.cpp:2157 if (getDiagnostics().getSuppressSystemWarnings() && - (Context.getSourceManager().isInSystemHeader(Old->getLocation()) || + // Some standard types are defined implicitly in Clang (e.g. OpenCL). + (Old->isImplicit() || New->isImplicit() || Is it necessary to check whether New is implicit? I was just wondering when or how an implicit definition would redefine a typedef. https://reviews.llvm.org/D31397 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31153: Add the ability to use the children() range API in a const-correct manner
aaron.ballman added a comment. In https://reviews.llvm.org/D31153#711287, @dblaikie wrote: > As I mentioned to Craig Topper recently on another review, generally when > implementing const and non-const overloads the non-const is implemented in > terms of the const overload (& const_casts away const on the result). This > ensures no UB if the const overload is called on a truly const object. Even > if there aren't any truly const Stmts today, I'd still prefer the code be > written so as not to assume they couldn't exist. In practice, this is really hard to do because there's no such thing as a const_iterator_cast operation to convert a const_iterator into an iterator, unless you have the underlying container handy. Since many of these uses do not have an underlying container (they're often trailing objects), I'm not certain this is practical (though I agree with the reasoning). Suggestions welcome, however. https://reviews.llvm.org/D31153 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31401: [clangd] Extract FsPath from file:// uri
stanionascu created this revision. rfc8089#appendix-E.2 specifies that paths can begin with a drive letter e.g. as file:///c:/. In this case just consuming front file:// is not enough and the 3rd slash must be consumed to produce a valid path on windows. The patch introduce a generic way of converting an uri to a filesystem path and back. https://reviews.llvm.org/D31401 Files: clangd/ASTManager.cpp clangd/Protocol.cpp clangd/Protocol.h clangd/clients/clangd-vscode/src/extension.ts Index: clangd/clients/clangd-vscode/src/extension.ts === --- clangd/clients/clangd-vscode/src/extension.ts +++ clangd/clients/clangd-vscode/src/extension.ts @@ -23,7 +23,12 @@ const clientOptions: vscodelc.LanguageClientOptions = { // Register the server for C/C++ files -documentSelector: ['c', 'cc', 'cpp', 'h', 'hh', 'hpp'] +documentSelector: ['c', 'cc', 'cpp', 'h', 'hh', 'hpp'], +uriConverters: { +// FIXME: implement percent decoding in clangd +code2Protocol: (uri: vscode.Uri) : string => uri.toString(true), +protocol2Code: (file: string) : vscode.Uri => vscode.Uri.file(file) +} }; const clangdClient = new vscodelc.LanguageClient('Clang Language Server', serverOptions, clientOptions); Index: clangd/Protocol.h === --- clangd/Protocol.h +++ clangd/Protocol.h @@ -29,6 +29,11 @@ namespace clang { namespace clangd { +struct Uri { + static std::string parse(llvm::StringRef uri); + static std::string unparse(llvm::StringRef file); +}; + struct TextDocumentIdentifier { /// The text document's URI. std::string uri; Index: clangd/Protocol.cpp === --- clangd/Protocol.cpp +++ clangd/Protocol.cpp @@ -17,8 +17,30 @@ #include "llvm/ADT/SmallString.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/Path.h" using namespace clang::clangd; +std::string Uri::parse(llvm::StringRef uri) { + uri.consume_front("file://"); + // For Windows paths e.g. /X: + if (uri.size() > 2 && uri[0] == '/' && uri[2] == ':') +uri.consume_front("/"); + // Make sure that file paths are in native separators + std::string Result = llvm::sys::path::convert_to_slash(uri); + return Result; +} + +std::string Uri::unparse(llvm::StringRef file) { + using namespace llvm::sys; + std::string Result = "file://"; + // For Windows paths e.g. X: + if (file.size() > 1 && file[1] == ':') +Result += "/"; + // Make sure that uri paths are with posix separators + Result += path::convert_to_slash(file, path::Style::posix); + return Result; +} + llvm::Optional TextDocumentIdentifier::parse(llvm::yaml::MappingNode *Params) { TextDocumentIdentifier Result; @@ -36,7 +58,7 @@ llvm::SmallString<10> Storage; if (KeyValue == "uri") { - Result.uri = Value->getValue(Storage); + Result.uri = Uri::parse(Value->getValue(Storage)); } else if (KeyValue == "version") { // FIXME: parse version, but only for VersionedTextDocumentIdentifiers. } else { @@ -142,7 +164,7 @@ llvm::SmallString<10> Storage; if (KeyValue == "uri") { - Result.uri = Value->getValue(Storage); + Result.uri = Uri::parse(Value->getValue(Storage)); } else if (KeyValue == "languageId") { Result.languageId = Value->getValue(Storage); } else if (KeyValue == "version") { Index: clangd/ASTManager.cpp === --- clangd/ASTManager.cpp +++ clangd/ASTManager.cpp @@ -28,7 +28,6 @@ std::vector RemappedFiles; for (const auto &P : Docs.getAllDocuments()) { StringRef FileName = P.first; -FileName.consume_front("file://"); RemappedFiles.push_back(ASTUnit::RemappedFile( FileName, llvm::MemoryBuffer::getMemBufferCopy(P.second, FileName).release())); @@ -138,7 +137,7 @@ Diagnostics.pop_back(); // Drop trailing comma. Output.writeMessage( R"({"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":")" + - File + R"(","diagnostics":[)" + Diagnostics + R"(]}})"); + Uri::unparse(File) + R"(","diagnostics":[)" + Diagnostics + R"(]}})"); } ASTManager::~ASTManager() { @@ -169,8 +168,6 @@ if (I) return I.get(); - Uri.consume_front("file://"); - std::string Error; I = tooling::CompilationDatabase::autoDetectFromSource(Uri, Error); Output.log("Failed to load compilation database: " + Twine(Error) + "\n"); @@ -182,7 +179,6 @@ tooling::CompilationDatabase *CDB = getOrCreateCompilationDatabaseForFile(Uri); - Uri.consume_front("file://"); std::vector Commands; if (CDB) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-c
[PATCH] D29599: Clang Changes for alloc_align
erichkeane marked 15 inline comments as done. erichkeane added a comment. Comments on 2 cases, otherwise a Patch incoming that fixes the rest of Aaron's comments. Comment at: include/clang/Basic/Attr.td:1224 +def AllocAlign : InheritableAttr { + let Spellings = [ GCC<"alloc_align"> ]; + let Subjects = SubjectList<[Function]>; aaron.ballman wrote: > Extra spaces in the declaration that do not match the style of the rest of > the file (same happens below). Strangely, this is ClangFormat at work :/ Comment at: include/clang/Basic/Attr.td:1225 + let Spellings = [ GCC<"alloc_align"> ]; + let Subjects = SubjectList<[Function]>; + let Args = [ IntArgument<"ParamIndex"> ]; aaron.ballman wrote: > Is this subject line correct, or should it be using `HasFunctionProto` > instead? How does GCC handle something like `void *blah() > __attribute__((alloc_align(1)));` in C code? I'm not sure what HasFunctionProto means in this case. Either way, GCC does basically ZERO SEMA here, so GCC would allow that to happen, then simply ignore the attribute. We're enforcing that in the SEMA changes below. Comment at: lib/CodeGen/CGCall.cpp:4374 +} else if (const auto *AA = TargetDecl->getAttr()) { + llvm::Value *ParamVal = IRCallArgs[AA->getParamIndex() - 1]; + EmitAlignmentAssumption(Ret.getScalarVal(), ParamVal); aaron.ballman wrote: > Instead of hoping all of the callers of `getParamIndex()` will remember that > this is a weird one-based thing, why not give the semantic attribute the > correct index when attaching the attribute to the declaration? I played with this for a while, and the difficulty is that AddAllocAlignAttr requires the 1-based index, since it needs to error based on that number. Additionally, decrementing the value BEFORE that function becomes difficult, since it is an Expr object at that time (which would get messy in the template case). I cannot alter it in the AddAllocAlignAttr function, since that function actually gets called TWICE in the template instantiation case, so I'd likely need some sort of flag that told whether to treat it as decremented or not. In general, this gets really ugly really quickly. Basically, I don't see a good place to decrement the value anywhere without causing a much more significant change. Comment at: lib/Sema/SemaDeclAttr.cpp:806 +/// \brief Checks to be sure that the given parameter number is inbounds, and is +/// an some integral type. Will emit appropriate diagnostics if this returns +/// false. aaron.ballman wrote: > Remove the "some". This is what I get for just C&P'ing the existing comment :) Comment at: lib/Sema/SemaDeclAttr.cpp:1599 + int IndexVal; + if (!checkPositiveIntArgument(*this, TmpAttr, ParamExpr, IndexVal, +/*Index=*/1)) aaron.ballman wrote: > It seems strange to me that you check that it's a positive integer argument > before checking the param is an integer type. > > Why not use `checkFunctionOrMethodParameterIndex()`? I'm unaware of checkFunctionOrMethodParameterIndex, there are a ton of odd free fucntions around here, I just copied from some of the surrounding functions. That said, these two poorly named functions are actually checking 2 different pieces of data. So in the case of: void func(int foo) __attribute__((alloc_align(1)); The "checkPositiveIntArgument" checks to ensure that '1' is a positive integer. "checkParamIsIntegerType" checks that "foo" (the corresponding parameter) is an integer, and that '1' is in range. https://reviews.llvm.org/D29599 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29599: Clang Changes for alloc_align
erichkeane updated this revision to Diff 93158. erichkeane marked 2 inline comments as done. https://reviews.llvm.org/D29599 Files: include/clang/Basic/Attr.td include/clang/Basic/AttrDocs.td include/clang/Sema/Sema.h lib/CodeGen/CGCall.cpp lib/CodeGen/CodeGenFunction.h lib/Sema/SemaDeclAttr.cpp lib/Sema/SemaTemplateInstantiateDecl.cpp test/CodeGen/alloc-align-attr.c test/Sema/alloc-align-attr.c test/SemaCXX/alloc-align-attr.cpp Index: lib/CodeGen/CGCall.cpp === --- lib/CodeGen/CGCall.cpp +++ lib/CodeGen/CGCall.cpp @@ -4348,6 +4348,9 @@ llvm::ConstantInt *AlignmentCI = cast(Alignment); EmitAlignmentAssumption(Ret.getScalarVal(), AlignmentCI->getZExtValue(), OffsetValue); +} else if (const auto *AA = TargetDecl->getAttr()) { + llvm::Value *ParamVal = IRCallArgs[AA->getParamIndex() - 1]; + EmitAlignmentAssumption(Ret.getScalarVal(), ParamVal); } } Index: lib/CodeGen/CodeGenFunction.h === --- lib/CodeGen/CodeGenFunction.h +++ lib/CodeGen/CodeGenFunction.h @@ -2465,6 +2465,12 @@ PeepholeProtection protectFromPeepholes(RValue rvalue); void unprotectFromPeepholes(PeepholeProtection protection); + void EmitAlignmentAssumption(llvm::Value *PtrValue, llvm::Value *Alignment, + llvm::Value *OffsetValue = nullptr) { +Builder.CreateAlignmentAssumption(CGM.getDataLayout(), PtrValue, Alignment, + OffsetValue); + } + //======// // Statement Emission //======// Index: lib/Sema/SemaTemplateInstantiateDecl.cpp === --- lib/Sema/SemaTemplateInstantiateDecl.cpp +++ lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -168,6 +168,16 @@ Aligned->getSpellingListIndex()); } +static void instantiateDependentAllocAlignAttr( +Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, +const AllocAlignAttr *Align, Decl *New) { + Expr *Param = IntegerLiteral::Create( + S.getASTContext(), llvm::APInt(64, Align->getParamIndex()), + S.getASTContext().UnsignedLongLongTy, Align->getLocation()); + S.AddAllocAlignAttr(Align->getLocation(), New, Param, + Align->getSpellingListIndex()); +} + static Expr *instantiateDependentFunctionAttrCondition( Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const Attr *A, Expr *OldCond, const Decl *Tmpl, FunctionDecl *New) { @@ -380,6 +390,12 @@ continue; } +if (const auto *AllocAlign = dyn_cast(TmplAttr)) { + instantiateDependentAllocAlignAttr(*this, TemplateArgs, AllocAlign, New); + continue; +} + + if (const auto *EnableIf = dyn_cast(TmplAttr)) { instantiateDependentEnableIfAttr(*this, TemplateArgs, EnableIf, Tmpl, cast(New)); Index: lib/Sema/SemaDeclAttr.cpp === --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -218,21 +218,45 @@ std::greater()); } +/// \brief A helper function to provide Attribute Location for the Attr types +/// AND the AttributeList. +template +static typename std::enable_if::value, + SourceLocation>::type +getAttrLoc(const AttrInfo &Attr) { + return Attr.getLocation(); +} +static SourceLocation getAttrLoc(const clang::AttributeList &Attr) { + return Attr.getLoc(); +} + +/// \brief A helper function to provide Attribute Name for the Attr types +/// AND the AttributeList. +template +static typename std::enable_if::value, + const AttrInfo *>::type +getAttrName(const AttrInfo &Attr) { + return &Attr; +} +const IdentifierInfo *getAttrName(const clang::AttributeList &Attr) { + return Attr.getName(); +} + /// \brief If Expr is a valid integer constant, get the value of the integer /// expression and return success or failure. May output an error. -static bool checkUInt32Argument(Sema &S, const AttributeList &Attr, -const Expr *Expr, uint32_t &Val, -unsigned Idx = UINT_MAX) { +template +static bool checkUInt32Argument(Sema &S, const AttrInfo& Attr, const Expr *Expr, +uint32_t &Val, unsigned Idx = UINT_MAX) { llvm::APSInt I(32); if (Expr->isTypeDependent() || Expr->isValueDependent() || !Expr->isIntegerConstantExpr(I, S.Context)) { if (Idx != UINT_MAX) - S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type) -<< Attr.getName() << Idx << AANT_ArgumentIntegerConstant + S.Diag(getAttrLoc(
[PATCH] D29923: PPCallbacks::MacroUndefined, change signature and add test.
bruno accepted this revision. bruno added a comment. This revision is now accepted and ready to land. LGTM! https://reviews.llvm.org/D29923 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30415: Fix -mno-altivec cannot overwrite -maltivec option
sfertile added a comment. Thanks Eric. Kuang, commit r298449 contained this fix so you can close the review now. https://reviews.llvm.org/D30415 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25866: [Sema] Support implicit scalar to vector conversions
bruno added inline comments. Comment at: test/Sema/vector-gcc-compat.c:61 + //match. + v2i64_r = v2i64_a == 1; // expected-warning {{incompatible vector types assigning to 'v2i64' (vector of 2 'long long' values) from 'long __attribute__((ext_vector_type(2)))' (vector of 2 'long' values)}} + v2i64_r = v2i64_a != 1; // expected-warning {{incompatible vector types assigning to 'v2i64' (vector of 2 'long long' values) from 'long __attribute__((ext_vector_type(2)))' (vector of 2 'long' values)}} sdardis wrote: > bruno wrote: > > Can you double check where 'long __attribute__((ext_vector_type(2)))' comes > > from? > > > > We have regressed in the past year in the way ext-vector interacts with > > non-ext-vectors, and I don't wanna make it worse until we actually have > > time to fix that; there's a lot of code out there relying on bitcasts > > between ext-vectors and non-ext-vectors to bridge between intrinsics > > headers and ext-vector code. > Sema::CheckVectorCompareOperands calls Sema::GetSignedVectorType which only > returns ext-vector types. I presume that is now incorrect if we're producing > vectors from literal scalars in the non OpenCL case. Nice catch, can you please submit these specific changes as a separated patch and mark it as a prerequisite of this one? https://reviews.llvm.org/D25866 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31269: [Modules] Allow modules specified by -fmodule-map-file to shadow implicitly found ones
bruno added a comment. Ping! https://reviews.llvm.org/D31269 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31126: Do not run tests for crash recovery if libstdc++ safe mode is enabled
sepavloff added a comment. Any feedback? https://reviews.llvm.org/D31126 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30415: Fix -mno-altivec cannot overwrite -maltivec option
kuang_he abandoned this revision. kuang_he added a comment. In https://reviews.llvm.org/D30415#703652, @uweigand wrote: > In https://reviews.llvm.org/D30415#703442, @hfinkel wrote: > > > In https://reviews.llvm.org/D30415#703398, @echristo wrote: > > > > > Different suggestion: > > > > > > Remove the faltivec option. Even gcc doesn't support it anymore afaict. > > > > > > What are you suggesting? Always having the language extensions on? Or > > explicitly tying the language extensions to the underlying target feature? > > > I'm a bit confused by this discussion. -faltivec and -maltivec are simply > aliases, they do exactly the same thing; the clang-internal variable > OPT_faltivec indicates the use of either -faltivec or -maltivec. > > Is the suggestion to remove that flag completely, i.e. both -maltivec and > -faltivec? This seems strange to me since -maltivec is used in many > Makefiles etc. that would break if clang suddenly refused to accept the > option. > > Or is the suggestion to simply remove the alias -faltivec, and leave > -maltivec as-is? I'd be less opposed to this since it probably breaks fewer > users ... but I'm still not quite sure what it actually buys us. And in any > case the patch currently under discussion here would still be necessary then, > to fix -maltivec -mno-altivec ... https://reviews.llvm.org/D30415 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer
yaxunl created this revision. Herald added subscribers: nhaehnle, wdng. There is an incoming change in LLVM allowing alloca to return a private pointer which does not pointing to address space 0: https://reviews.llvm.org/D31042#03b9d490 After this change is committed, alloca will return a pointer pointing to an address space specified by the data layout (so called alloca addr space, which is the last component of the data layout, e.g. A5 indicating alloca address space is 5). A data layout not specifying alloca address space will assume it is 0, therefore keeping the original behaviour. Clang codegen needs to make corresponding changes to account for the API change of alloca. The change is straightforward. Basically when creating alloca, use the alloca address space specified by the data layout. For OpenCL, the private address space qualifier is 0 in AST. Before this change, 0 address space qualifier is always mapped to target address space 0. As now target private address space is specified by alloca address space in data layout, address space qualifier 0 needs to be mapped to alloca addr space specified by the data layout. This change has no impact on targets whose alloca addr space is 0. https://reviews.llvm.org/D31404 Files: include/clang/AST/ASTContext.h lib/AST/ASTContext.cpp lib/Basic/Targets.cpp lib/CodeGen/CGBuiltin.cpp lib/CodeGen/CGCall.cpp lib/CodeGen/CGDecl.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CGObjCGNU.cpp test/CodeGenOpenCL/address-spaces.cl test/CodeGenOpenCL/amdgpu-env-amdgiz.cl test/CodeGenOpenCL/vla.cl Index: test/CodeGenOpenCL/vla.cl === --- test/CodeGenOpenCL/vla.cl +++ test/CodeGenOpenCL/vla.cl @@ -1,18 +1,26 @@ -// RUN: %clang_cc1 -emit-llvm -triple "spir-unknown-unknown" -O0 -cl-std=CL2.0 -o - %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -triple "spir-unknown-unknown" -O0 -cl-std=CL2.0 -o - %s | FileCheck -check-prefixes=CHECK,SPIR %s +// RUN: %clang_cc1 -emit-llvm -triple amdgcn-amd-amdhsa-opencl -O0 -cl-std=CL2.0 -o - %s | FileCheck -check-prefixes=CHECK,SPIR %s +// RUN: %clang_cc1 -emit-llvm -triple amdgcn-amd-amdhsa-amdgizcl -O0 -cl-std=CL2.0 -o - %s | FileCheck -check-prefixes=CHECK,GIZ %s constant int sz0 = 5; -// CHECK: @sz0 = addrspace(2) constant i32 5 +// SPIR: @sz0 = addrspace(2) constant i32 5 +// GIZ: @sz0 = addrspace(4) constant i32 5 const global int sz1 = 16; // CHECK: @sz1 = addrspace(1) constant i32 16 const constant int sz2 = 8; -// CHECK: @sz2 = addrspace(2) constant i32 8 +// SPIR: @sz2 = addrspace(2) constant i32 8 +// GIZ: @sz2 = addrspace(4) constant i32 8 // CHECK: @testvla.vla2 = internal addrspace(3) global [8 x i16] undef kernel void testvla() { int vla0[sz0]; -// CHECK: %vla0 = alloca [5 x i32] +// SPIR: %vla0 = alloca [5 x i32] +// SPIR-NOT: %vla0 = alloca [5 x i32]{{.*}}addrspace +// GIZ: %vla0 = alloca [5 x i32]{{.*}}addrspace(5) char vla1[sz1]; -// CHECK: %vla1 = alloca [16 x i8] +// SPIR: %vla1 = alloca [16 x i8] +// SPIR-NOT: %vla1 = alloca [16 x i8]{{.*}}addrspace +// GIZ: %vla1 = alloca [16 x i8]{{.*}}addrspace(5) local short vla2[sz2]; } Index: test/CodeGenOpenCL/amdgpu-env-amdgiz.cl === --- test/CodeGenOpenCL/amdgpu-env-amdgiz.cl +++ test/CodeGenOpenCL/amdgpu-env-amdgiz.cl @@ -4,6 +4,6 @@ // RUN: %clang_cc1 %s -O0 -triple amdgcn---amdgizcl -emit-llvm -o - | FileCheck -check-prefix=GIZ %s // CHECK: target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" -// GIZ: target datalayout = "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" +// GIZ: target datalayout = "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5" void foo(void) {} Index: test/CodeGenOpenCL/address-spaces.cl === --- test/CodeGenOpenCL/address-spaces.cl +++ test/CodeGenOpenCL/address-spaces.cl @@ -1,44 +1,57 @@ -// RUN: %clang_cc1 %s -O0 -ffake-address-space-map -emit-llvm -o - | FileCheck %s -// RUN: %clang_cc1 %s -O0 -DCL20 -cl-std=CL2.0 -ffake-address-space-map -emit-llvm -o - | FileCheck %s --check-prefix=CL20 - -// CHECK: i32* %arg +// RUN: %clang_cc1 %s -O0 -ffake-address-space-map -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,SPIR +// RUN: %clang_cc1 %s -O0 -DCL20 -cl-std=CL2.0 -ffake-address-space-map -emit-llvm -o - | FileCheck %s --check-prefixes=CL20,CL20SPIR +// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa-opencl -emit-llvm -o - | FileCheck --check-prefixes=CHECK,SPIR %s +// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa-opencl -DCL20 -cl-std=CL2.0 -emit-llvm -o - | F
r298877 - Encapsulate FPOptions and use it consistently
Author: anemet Date: Mon Mar 27 14:17:25 2017 New Revision: 298877 URL: http://llvm.org/viewvc/llvm-project?rev=298877&view=rev Log: Encapsulate FPOptions and use it consistently Sema holds the current FPOptions which is adjusted by 'pragma STDC FP_CONTRACT'. This then gets propagated into expression nodes as they are built. This encapsulates FPOptions so that this propagation happens opaquely rather than directly with the fp_contractable on/off bit. This allows controlled transitioning of fp_contractable to a ternary value (off, on, fast). It will also allow adding more fast-math flags later. This is toward moving fp-contraction=fast from an LLVM TargetOption to a FastMathFlag in order to fix PR25721. Differential Revision: https://reviews.llvm.org/D31166 Modified: cfe/trunk/include/clang/AST/Expr.h cfe/trunk/include/clang/AST/ExprCXX.h cfe/trunk/include/clang/Basic/LangOptions.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/AST/ASTImporter.cpp cfe/trunk/lib/Analysis/BodyFarm.cpp cfe/trunk/lib/CodeGen/CGExprScalar.cpp cfe/trunk/lib/CodeGen/CGObjC.cpp cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp cfe/trunk/lib/Sema/SemaAttr.cpp cfe/trunk/lib/Sema/SemaDeclCXX.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/lib/Sema/SemaPseudoObject.cpp cfe/trunk/lib/Sema/TreeTransform.h cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/lib/Serialization/ASTReaderStmt.cpp cfe/trunk/lib/Serialization/ASTWriter.cpp cfe/trunk/lib/Serialization/ASTWriterStmt.cpp Modified: cfe/trunk/include/clang/AST/Expr.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=298877&r1=298876&r2=298877&view=diff == --- cfe/trunk/include/clang/AST/Expr.h (original) +++ cfe/trunk/include/clang/AST/Expr.h Mon Mar 27 14:17:25 2017 @@ -2918,11 +2918,9 @@ public: private: unsigned Opc : 6; - // Records the FP_CONTRACT pragma status at the point that this binary - // operator was parsed. This bit is only meaningful for operations on - // floating point types. For all other types it should default to - // false. - unsigned FPContractable : 1; + // This is only meaningful for operations on floating point types and 0 + // otherwise. + unsigned FPFeatures : 1; SourceLocation OpLoc; enum { LHS, RHS, END_EXPR }; @@ -2931,7 +2929,7 @@ public: BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, - SourceLocation opLoc, bool fpContractable) + SourceLocation opLoc, FPOptions FPFeatures) : Expr(BinaryOperatorClass, ResTy, VK, OK, lhs->isTypeDependent() || rhs->isTypeDependent(), lhs->isValueDependent() || rhs->isValueDependent(), @@ -2939,7 +2937,7 @@ public: rhs->isInstantiationDependent()), (lhs->containsUnexpandedParameterPack() || rhs->containsUnexpandedParameterPack())), - Opc(opc), FPContractable(fpContractable), OpLoc(opLoc) { + Opc(opc), FPFeatures(FPFeatures.getInt()), OpLoc(opLoc) { SubExprs[LHS] = lhs; SubExprs[RHS] = rhs; assert(!isCompoundAssignmentOp() && @@ -3074,16 +3072,20 @@ public: // Set the FP contractability status of this operator. Only meaningful for // operations on floating point types. - void setFPContractable(bool FPC) { FPContractable = FPC; } + void setFPFeatures(FPOptions F) { FPFeatures = F.getInt(); } + + FPOptions getFPFeatures() const { return FPOptions(FPFeatures); } // Get the FP contractability status of this operator. Only meaningful for // operations on floating point types. - bool isFPContractable() const { return FPContractable; } + bool isFPContractable() const { +return FPOptions(FPFeatures).isFPContractable(); + } protected: BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, - SourceLocation opLoc, bool fpContractable, bool dead2) + SourceLocation opLoc, FPOptions FPFeatures, bool dead2) : Expr(CompoundAssignOperatorClass, ResTy, VK, OK, lhs->isTypeDependent() || rhs->isTypeDependent(), lhs->isValueDependent() || rhs->isValueDependent(), @@ -3091,7 +3093,7 @@ protected: rhs->isInstantiationDependent()), (lhs->containsUnexpandedParameterPack() || rhs->containsUnexpandedParameterPack())), - Opc(opc), FPContractable(fpContractable), OpLoc(opLoc) { + Opc(opc), FPFeatures(FPFeatures.getInt()), OpLoc(opLoc) { SubExprs[LHS] = lhs; SubExprs[RHS] = rhs; } @@ -3113,8 +3115,8 @@ public: CompoundAssignOperator(Expr *lhs, Expr *rhs, O
[PATCH] D31166: Encapsulate FPOptions and use it consistently
This revision was automatically updated to reflect the committed changes. Closed by commit rL298877: Encapsulate FPOptions and use it consistently (authored by anemet). Changed prior to commit: https://reviews.llvm.org/D31166?vs=92898&id=93166#toc Repository: rL LLVM https://reviews.llvm.org/D31166 Files: cfe/trunk/include/clang/AST/Expr.h cfe/trunk/include/clang/AST/ExprCXX.h cfe/trunk/include/clang/Basic/LangOptions.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/AST/ASTImporter.cpp cfe/trunk/lib/Analysis/BodyFarm.cpp cfe/trunk/lib/CodeGen/CGExprScalar.cpp cfe/trunk/lib/CodeGen/CGObjC.cpp cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp cfe/trunk/lib/Sema/SemaAttr.cpp cfe/trunk/lib/Sema/SemaDeclCXX.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/lib/Sema/SemaPseudoObject.cpp cfe/trunk/lib/Sema/TreeTransform.h cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/lib/Serialization/ASTReaderStmt.cpp cfe/trunk/lib/Serialization/ASTWriter.cpp cfe/trunk/lib/Serialization/ASTWriterStmt.cpp Index: cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp === --- cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp +++ cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp @@ -7500,7 +7500,7 @@ BinaryOperator *addExpr = new (Context) BinaryOperator(castExpr, DRE, BO_Add, Context->getPointerType(Context->CharTy), - VK_RValue, OK_Ordinary, SourceLocation(), false); + VK_RValue, OK_Ordinary, SourceLocation(), FPOptions()); // Don't forget the parens to enforce the proper binding. ParenExpr *PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), Index: cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp === --- cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp +++ cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp @@ -2992,7 +2992,7 @@ BinaryOperator *lessThanExpr = new (Context) BinaryOperator(sizeofExpr, limit, BO_LE, Context->IntTy, VK_RValue, OK_Ordinary, SourceLocation(), - false); + FPOptions()); // (sizeof(returnType) <= 8 ? objc_msgSend(...) : objc_msgSend_stret(...)) ConditionalOperator *CondExpr = new (Context) ConditionalOperator(lessThanExpr, Index: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp === --- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp +++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp @@ -670,7 +670,7 @@ E->setRHS(Record.readSubExpr()); E->setOpcode((BinaryOperator::Opcode)Record.readInt()); E->setOperatorLoc(ReadSourceLocation()); - E->setFPContractable((bool)Record.readInt()); + E->setFPFeatures(FPOptions(Record.readInt())); } void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) { @@ -1225,7 +1225,7 @@ VisitCallExpr(E); E->Operator = (OverloadedOperatorKind)Record.readInt(); E->Range = Record.readSourceRange(); - E->setFPContractable((bool)Record.readInt()); + E->setFPFeatures(FPOptions(Record.readInt())); } void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) { Index: cfe/trunk/lib/Serialization/ASTReader.cpp === --- cfe/trunk/lib/Serialization/ASTReader.cpp +++ cfe/trunk/lib/Serialization/ASTReader.cpp @@ -7378,7 +7378,7 @@ // FIXME: What happens if these are changed by a module import? if (!FPPragmaOptions.empty()) { assert(FPPragmaOptions.size() == 1 && "Wrong number of FP_PRAGMA_OPTIONS"); -SemaObj->FPFeatures.fp_contract = FPPragmaOptions[0]; +SemaObj->FPFeatures = FPOptions(FPPragmaOptions[0]); } SemaObj->OpenCLFeatures.copy(OpenCLExtensions); Index: cfe/trunk/lib/Serialization/ASTWriterStmt.cpp === --- cfe/trunk/lib/Serialization/ASTWriterStmt.cpp +++ cfe/trunk/lib/Serialization/ASTWriterStmt.cpp @@ -650,7 +650,7 @@ Record.AddStmt(E->getRHS()); Record.push_back(E->getOpcode()); // FIXME: stable encoding Record.AddSourceLocation(E->getOperatorLoc()); - Record.push_back(E->isFPContractable()); + Record.push_back(E->getFPFeatures().getInt()); Code = serialization::EXPR_BINARY_OPERATOR; } @@ -1218,7 +1218,7 @@ VisitCallExpr(E); Record.push_back(E->getOperator()); Record.AddSourceRange(E->Range); - Record.push_back(E->isFPContractable()); + Record.push_back(E->getFPFeatures().getInt()); Code = serialization::EXPR_CXX_OPERATOR_CALL; }
[PATCH] D31399: [coroutines] Handle get_return_object_on_allocation_failure
EricWF accepted this revision. EricWF added a comment. This revision is now accepted and ready to land. This LGTM minus inline comments. Comment at: lib/Sema/SemaCoroutine.cpp:793 + LookupResult Found(S, DN, Loc, Sema::LookupMemberName); + // Suppress diagnostics when a private member is selected. The same warnings + // will be produced again when building the call. Maybe add a test for this in `SemaCXX/coroutines.cpp`? Comment at: test/CodeGenCoroutines/coro-alloc.cpp:131 + +struct promise_on_alloc_failure_tag {}; + FYI this test doesn't merge with trunk seemingly due to whitespace issues. https://reviews.llvm.org/D31399 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r298880 - Add [[clang::suppress(rule, ...)]] attribute
Author: mgehre Date: Mon Mar 27 14:45:24 2017 New Revision: 298880 URL: http://llvm.org/viewvc/llvm-project?rev=298880&view=rev Log: Add [[clang::suppress(rule, ...)]] attribute Summary: This patch implements parsing of [[clang::suppress(rule, ...)]] and [[gsl::suppress(rule, ...)]] attributes. C++ Core Guidelines depend heavily on tool support for rule enforcement. They also propose a way to suppress warnings [1] which is by annotating any ancestor in AST with the C++11 attribute [[gsl::suppress(rule1,...)]]. To have a mechanism to suppress non-C++ Core Guidelines specific, an additional spelling of [[clang::suppress]] is defined. For example, to suppress the warning cppcoreguidelines-slicing, one could do ``` [[clang::suppress("cppcoreguidelines-slicing")]] void f() { ... code that does slicing ... } ``` or ``` void g() { Derived b; [[clang::suppress("cppcoreguidelines-slicing")]] Base a{b}; [[clang::suppress("cppcoreguidelines-slicing")]] { doSomething(); Base a2{b}; } } ``` This parsing can then be used by clang-tidy, which includes multiple C++ Core Guidelines rules, to suppress warnings (see https://reviews.llvm.org/D24888). For the exact naming of the rule in the attribute, there are different possibilities, which will be defined in the corresponding clang-tidy patch. Currently, clang-tidy supports suppressing of warnings through "// NOLINT" comments. There are some advantages that the attribute has: - Suppressing specific warnings instead of all warnings - Suppressing warnings in a block (namespace, function, compound statement) - Code formatting may split a statement into multiple lines, thus a "// NOLINT" comment may be on the wrong line I'm looking forward to your comments! [1] https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#inforce-enforcement Reviewers: alexfh, aaron.ballman, rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24886 Added: cfe/trunk/test/SemaCXX/suppress.cpp Modified: cfe/trunk/include/clang/Basic/Attr.td cfe/trunk/include/clang/Basic/AttrDocs.td cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/lib/Sema/SemaStmtAttr.cpp cfe/trunk/test/Misc/ast-dump-attr.cpp Modified: cfe/trunk/include/clang/Basic/Attr.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=298880&r1=298879&r2=298880&view=diff == --- cfe/trunk/include/clang/Basic/Attr.td (original) +++ cfe/trunk/include/clang/Basic/Attr.td Mon Mar 27 14:45:24 2017 @@ -1545,6 +1545,12 @@ def SwiftIndirectResult : ParameterABIAt let Documentation = [SwiftIndirectResultDocs]; } +def Suppress : StmtAttr { + let Spellings = [CXX11<"gsl", "suppress">]; + let Args = [VariadicStringArgument<"DiagnosticIdentifiers">]; + let Documentation = [SuppressDocs]; +} + def SysVABI : InheritableAttr { let Spellings = [GCC<"sysv_abi">]; // let Subjects = [Function, ObjCMethod]; Modified: cfe/trunk/include/clang/Basic/AttrDocs.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=298880&r1=298879&r2=298880&view=diff == --- cfe/trunk/include/clang/Basic/AttrDocs.td (original) +++ cfe/trunk/include/clang/Basic/AttrDocs.td Mon Mar 27 14:45:24 2017 @@ -2771,6 +2771,32 @@ optimizations like C++'s named return va }]; } +def SuppressDocs : Documentation { + let Category = DocCatStmt; + let Content = [{ +The ``[[gsl::suppress]]`` attribute suppresses specific +clang-tidy diagnostics for rules of the `C++ Core Guidelines`_ in a portable +way. The attribute can be attached to declarations, statements, and at +namespace scope. + +.. code-block:: c++ + + [[gsl::suppress("Rh-public")]] + void f_() { +int *p; +[[gsl::suppress("type")]] { + p = reinterpret_cast(7); +} + } + namespace N { +[[clang::suppress("type", "bounds")]]; +... + } + +.. _`C++ Core Guidelines`: https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#inforce-enforcement + }]; +} + def AbiTagsDocs : Documentation { let Category = DocCatFunction; let Content = [{ Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=298880&r1=298879&r2=298880&view=diff == --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Mar 27 14:45:24 2017 @@ -4097,6 +4097,26 @@ static void handleCallConvAttr(Sema &S, } } +static void handleSuppressAttr(Sema &S, Decl *D, const AttributeList &Attr) { + if (!checkAttributeAtLeastNumArgs(S, Attr, 1)) +return; + + std::vector DiagnosticIdentifiers; + for (unsigned I = 0, E = Attr.getNumArgs(); I != E; ++I) { +StringRef RuleName; + +if (!S.checkStringLiteral
[PATCH] D24886: Add [[clang::suppress(rule, ...)]] attribute
This revision was automatically updated to reflect the committed changes. Closed by commit rL298880: Add [[clang::suppress(rule, ...)]] attribute (authored by mgehre). Changed prior to commit: https://reviews.llvm.org/D24886?vs=93055&id=93168#toc Repository: rL LLVM https://reviews.llvm.org/D24886 Files: cfe/trunk/include/clang/Basic/Attr.td cfe/trunk/include/clang/Basic/AttrDocs.td cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/lib/Sema/SemaStmtAttr.cpp cfe/trunk/test/Misc/ast-dump-attr.cpp cfe/trunk/test/SemaCXX/suppress.cpp Index: cfe/trunk/include/clang/Basic/AttrDocs.td === --- cfe/trunk/include/clang/Basic/AttrDocs.td +++ cfe/trunk/include/clang/Basic/AttrDocs.td @@ -2771,6 +2771,32 @@ }]; } +def SuppressDocs : Documentation { + let Category = DocCatStmt; + let Content = [{ +The ``[[gsl::suppress]]`` attribute suppresses specific +clang-tidy diagnostics for rules of the `C++ Core Guidelines`_ in a portable +way. The attribute can be attached to declarations, statements, and at +namespace scope. + +.. code-block:: c++ + + [[gsl::suppress("Rh-public")]] + void f_() { +int *p; +[[gsl::suppress("type")]] { + p = reinterpret_cast(7); +} + } + namespace N { +[[clang::suppress("type", "bounds")]]; +... + } + +.. _`C++ Core Guidelines`: https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#inforce-enforcement + }]; +} + def AbiTagsDocs : Documentation { let Category = DocCatFunction; let Content = [{ Index: cfe/trunk/include/clang/Basic/Attr.td === --- cfe/trunk/include/clang/Basic/Attr.td +++ cfe/trunk/include/clang/Basic/Attr.td @@ -1545,6 +1545,12 @@ let Documentation = [SwiftIndirectResultDocs]; } +def Suppress : StmtAttr { + let Spellings = [CXX11<"gsl", "suppress">]; + let Args = [VariadicStringArgument<"DiagnosticIdentifiers">]; + let Documentation = [SuppressDocs]; +} + def SysVABI : InheritableAttr { let Spellings = [GCC<"sysv_abi">]; // let Subjects = [Function, ObjCMethod]; Index: cfe/trunk/test/Misc/ast-dump-attr.cpp === --- cfe/trunk/test/Misc/ast-dump-attr.cpp +++ cfe/trunk/test/Misc/ast-dump-attr.cpp @@ -179,3 +179,25 @@ __attribute__((external_source_symbol(generated_declaration, defined_in="module", language="Swift"))); // CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr5 // CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "Swift" "module" GeneratedDeclaration + +namespace TestSuppress { + [[gsl::suppress("at-namespace")]]; + // CHECK: NamespaceDecl{{.*}} TestSuppress + // CHECK-NEXT: EmptyDecl{{.*}} + // CHECK-NEXT: SuppressAttr{{.*}} at-namespace + [[gsl::suppress("on-decl")]] + void TestSuppressFunction(); + // CHECK: FunctionDecl{{.*}} TestSuppressFunction + // CHECK-NEXT SuppressAttr{{.*}} on-decl + + void f() { + int *i; + + [[gsl::suppress("on-stmt")]] { + // CHECK: AttributedStmt + // CHECK-NEXT: SuppressAttr{{.*}} on-stmt + // CHECK-NEXT: CompoundStmt +i = reinterpret_cast(7); + } +} +} Index: cfe/trunk/test/SemaCXX/suppress.cpp === --- cfe/trunk/test/SemaCXX/suppress.cpp +++ cfe/trunk/test/SemaCXX/suppress.cpp @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -verify + +[[gsl::suppress("globally")]]; + +namespace N { + [[gsl::suppress("in-a-namespace")]]; +} + +[[gsl::suppress("readability-identifier-naming")]] +void f_() { + int *p; + [[gsl::suppress("type", "bounds")]] { +p = reinterpret_cast(7); + } + + [[gsl::suppress]] int x; // expected-error {{'suppress' attribute takes at least 1 argument}} + [[gsl::suppress()]] int y; // expected-error {{'suppress' attribute takes at least 1 argument}} + int [[gsl::suppress("r")]] z; // expected-error {{'suppress' attribute cannot be applied to types}} + [[gsl::suppress(f_)]] float f; // expected-error {{'suppress' attribute requires a string}} +} + +union [[gsl::suppress("type.1")]] U { + int i; + float f; +}; Index: cfe/trunk/lib/Sema/SemaStmtAttr.cpp === --- cfe/trunk/lib/Sema/SemaStmtAttr.cpp +++ cfe/trunk/lib/Sema/SemaStmtAttr.cpp @@ -53,6 +53,31 @@ return ::new (S.Context) auto(Attr); } +static Attr *handleSuppressAttr(Sema &S, Stmt *St, const AttributeList &A, +SourceRange Range) { + if (A.getNumArgs() < 1) { +S.Diag(A.getLoc(), diag::err_attribute_too_few_arguments) +<< A.getName() << 1; +return nullptr; + } + + std::vector DiagnosticIdentifiers; + for (unsigned I = 0, E = A.getNumArgs(); I != E; ++I) { +StringRef RuleName; + +if (!S.checkStringLiteralArgumentAttr(A, I, RuleName, nullptr)) + return nullptr; + +// FIXME: Warn if the rule name is unknown. This i
[PATCH] D30837: [libcxx] Support for shared_ptr
EricWF added a comment. This patch seems to support constructing a `shared_ptr` without providing a non-default deleter. I don't think this should work because the default deleter will attempt to free a function pointer, which is never valid. (Although I think this case will still cause a compile error). Comment at: include/memory:3896 + +template struct __shared_ptr_default_allocator<_Tp, false> +{ I would just handle this case with the primary template rather than a complete specialization. Comment at: include/memory:3903 +{ +typedef allocator type; +}; Using an arbitrary and unrelated allocator type `std::allocator` still makes me nervous. I would rather use a custom allocator type written only for this use case. https://reviews.llvm.org/D30837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31130: B32239 clang-tidy should not warn about array to pointer decay on system macros
mgehre added inline comments. Comment at: clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp:83 + unless(hasSourceExpression(stringLiteral())), + unless(sysSymbolDecayInSysHeader())) .bind("cast"), I would say that the check can ignore PredefinedExpr such as `__PRETTY_FUNCTION__` by ``` unless(hasSourceExpression(predefinedExpr ())), ``` https://reviews.llvm.org/D31130 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29339: [OpenMP] Add support for auxiliary triple specification
gtbercea updated this revision to Diff 93171. gtbercea added a comment. Herald added a subscriber: rengolin. Update patch to reflect latest source code changes. Repository: rL LLVM https://reviews.llvm.org/D29339 Files: lib/Driver/ToolChains/Clang.cpp lib/Frontend/CompilerInstance.cpp lib/Frontend/CompilerInvocation.cpp lib/Frontend/InitPreprocessor.cpp test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -248,32 +248,32 @@ // // Compile for the powerpc device. // -// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" " +// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-aux-triple" "powerpc64le--linux" "-emit-obj" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" " // CHK-COMMANDS-SAME: [[T1OBJ:[^\\/]+\.o]]" "-x" "c" "{{.*}}[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "{{.*}}[[HOSTBC]]" // CHK-COMMANDS: ld{{(\.exe)?}}" {{.*}}"-o" " // CHK-COMMANDS-SAME: [[T1BIN:[^\\/]+\.out]]" {{.*}}"{{.*}}[[T1OBJ]]" -// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" " +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-aux-triple" "powerpc64le--linux" "-E" {{.*}}"-fopenmp" {{.*}}"-o" " // CHK-COMMANDS-ST-SAME: [[T1PP:[^\\/]+\.i]]" "-x" "c" "{{.*}}[[INPUT]]" -// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" " +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-aux-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" " // CHK-COMMANDS-ST-SAME: [[T1BC:[^\\/]+\.bc]]" "-x" "cpp-output" "{{.*}}[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "{{.*}}[[HOSTBC]]" -// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" " +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-aux-triple" "powerpc64le--linux" "-S" {{.*}}"-fopenmp" {{.*}}"-o" " // CHK-COMMANDS-ST-SAME: [[T1ASM:[^\\/]+\.s]]" "-x" "ir" "{{.*}}[[T1BC]]" // CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le-ibm-linux-gnu" "-filetype" "obj" {{.*}}"-o" " // CHK-COMMANDS-ST-SAME: [[T1OBJ:[^\\/]+\.o]]" "{{.*}}[[T1ASM]]" // CHK-COMMANDS-ST: ld{{(\.exe)?}}" {{.*}}"-shared" {{.*}}"-o" " // CHK-COMMANDS-ST-SAME: [[T1BIN:[^\\/]+\.out-openmp-powerpc64le-ibm-linux-gnu]]" {{.*}}"{{.*}}[[T1OBJ]]" // // Compile for the x86 device. // -// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" " +// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-aux-triple" "powerpc64le--linux" "-emit-obj" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" " // CHK-COMMANDS-SAME: [[T2OBJ:[^\\/]+\.o]]" "-x" "c" "{{.*}}[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "{{.*}}[[HOSTBC]]" // CHK-COMMANDS: ld{{(\.exe)?}}" {{.*}}"-o" " // CHK-COMMANDS-SAME: [[T2BIN:[^\\/]+\.out]]" {{.*}}"{{.*}}[[T2OBJ]]" -// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" " +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-aux-triple" "powerpc64le--linux" "-E" {{.*}}"-fopenmp" {{.*}}"-o" " // CHK-COMMANDS-ST-SAME: [[T2PP:[^\\/]+\.i]]" "-x" "c" "{{.*}}[[INPUT]]" -// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" " +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-aux-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" " // CHK-COMMANDS-ST-SAME: [[T2BC:[^\\/]+\.bc]]" "-x" "cpp-output" "{{.*}}[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "{{.*}}[[HOSTBC]]" -// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" " +// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-aux-triple" "powerpc64le--linux" "-S" {{.*}}"-fopenmp" {{.*}}"-o" " // CHK-COMMANDS-ST-SAME: [[T2ASM:[^\\/]+\.s]]" "-x" "ir" "{{.*}}[[T2BC]]" // CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "x86_64-pc-linux-gnu" "-filetype" "obj" {{.*}}"-o" " // CHK-COMMANDS-ST-SAME: [[T2OBJ:[^\\/]+\.o]]" "{{.*}}[[T2ASM]]" @@ -396,25 +396,25 @@ // CHK-BUJOBS-ST-SAME: [[HOSTBC:[^\\/]+\.bc]]" "-x" "cpp-output" "{{.*}}[[HOSTPP]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" // Create target 1 object. -// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" " +// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64l
[PATCH] D29642: [OpenMP] Make OpenMP generated code for the NVIDIA device relocatable by default
gtbercea updated this revision to Diff 93172. gtbercea added a comment. Herald added a subscriber: rengolin. Update patch to reflect latest source code changes. Repository: rL LLVM https://reviews.llvm.org/D29642 Files: lib/Driver/ToolChains/Cuda.cpp test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -587,3 +587,12 @@ // CHK-UBUJOBS-ST-SAME: [[HOSTOBJ:[^\\/]+\.o]]" "{{.*}}[[HOSTASM]]" // CHK-UBUJOBS-ST: clang-offload-bundler{{.*}}" "-type=o" "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs= // CHK-UBUJOBS-ST-SAME: [[RES:[^\\/]+\.o]]" "-inputs={{.*}}[[T1OBJ]],{{.*}}[[T2OBJ]],{{.*}}[[HOSTOBJ]]" + +/// ### + +/// Check PTXAS is passed -c flag when offloading to an NVIDIA device using OpenMP. +// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-PTXAS %s + +// CHK-PTXAS: ptxas{{.*}}" "-c" +// CHK-PTXAS-NEXT: /bin/cp Index: lib/Driver/ToolChains/Cuda.cpp === --- lib/Driver/ToolChains/Cuda.cpp +++ lib/Driver/ToolChains/Cuda.cpp @@ -272,6 +272,10 @@ for (const auto& A : Args.getAllArgValues(options::OPT_Xcuda_ptxas)) CmdArgs.push_back(Args.MakeArgString(A)); + // In OpenMP we need to generate relocatable code. + if (JA.isOffloading(Action::OFK_OpenMP)) +CmdArgs.push_back("-c"); + const char *Exec; if (Arg *A = Args.getLastArg(options::OPT_ptxas_path_EQ)) Exec = A->getValue(); Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -587,3 +587,12 @@ // CHK-UBUJOBS-ST-SAME: [[HOSTOBJ:[^\\/]+\.o]]" "{{.*}}[[HOSTASM]]" // CHK-UBUJOBS-ST: clang-offload-bundler{{.*}}" "-type=o" "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs= // CHK-UBUJOBS-ST-SAME: [[RES:[^\\/]+\.o]]" "-inputs={{.*}}[[T1OBJ]],{{.*}}[[T2OBJ]],{{.*}}[[HOSTOBJ]]" + +/// ### + +/// Check PTXAS is passed -c flag when offloading to an NVIDIA device using OpenMP. +// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-PTXAS %s + +// CHK-PTXAS: ptxas{{.*}}" "-c" +// CHK-PTXAS-NEXT: /bin/cp Index: lib/Driver/ToolChains/Cuda.cpp === --- lib/Driver/ToolChains/Cuda.cpp +++ lib/Driver/ToolChains/Cuda.cpp @@ -272,6 +272,10 @@ for (const auto& A : Args.getAllArgValues(options::OPT_Xcuda_ptxas)) CmdArgs.push_back(Args.MakeArgString(A)); + // In OpenMP we need to generate relocatable code. + if (JA.isOffloading(Action::OFK_OpenMP)) +CmdArgs.push_back("-c"); + const char *Exec; if (Arg *A = Args.getLastArg(options::OPT_ptxas_path_EQ)) Exec = A->getValue(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29644: [OpenMP] Pass -v to PTXAS if it was passed to the driver.
gtbercea updated this revision to Diff 93176. gtbercea added a comment. Herald added a subscriber: rengolin. Update patch to reflect latest source code changes. Repository: rL LLVM https://reviews.llvm.org/D29644 Files: lib/Driver/ToolChains/Cuda.cpp test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -596,3 +596,12 @@ // CHK-PTXAS: ptxas{{.*}}" "-c" // CHK-PTXAS-NEXT: /bin/cp + +/// ### + +/// Check that CLANG forwards the -v flag to PTXAS. +// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes -v %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-VERBOSE %s + +// CHK-VERBOSE: ptxas{{.*}}" "-v" +// CHK-VERBOSE-NEXT: /bin/cp Index: lib/Driver/ToolChains/Cuda.cpp === --- lib/Driver/ToolChains/Cuda.cpp +++ lib/Driver/ToolChains/Cuda.cpp @@ -262,6 +262,10 @@ CmdArgs.push_back("-O0"); } + // Pass -v to ptxas if it was passed to the driver. + if (Args.hasArg(options::OPT_v)) +CmdArgs.push_back("-v"); + CmdArgs.push_back("--gpu-name"); CmdArgs.push_back(Args.MakeArgString(CudaArchToString(gpu_arch))); CmdArgs.push_back("--output-file"); Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -596,3 +596,12 @@ // CHK-PTXAS: ptxas{{.*}}" "-c" // CHK-PTXAS-NEXT: /bin/cp + +/// ### + +/// Check that CLANG forwards the -v flag to PTXAS. +// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes -v %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-VERBOSE %s + +// CHK-VERBOSE: ptxas{{.*}}" "-v" +// CHK-VERBOSE-NEXT: /bin/cp Index: lib/Driver/ToolChains/Cuda.cpp === --- lib/Driver/ToolChains/Cuda.cpp +++ lib/Driver/ToolChains/Cuda.cpp @@ -262,6 +262,10 @@ CmdArgs.push_back("-O0"); } + // Pass -v to ptxas if it was passed to the driver. + if (Args.hasArg(options::OPT_v)) +CmdArgs.push_back("-v"); + CmdArgs.push_back("--gpu-name"); CmdArgs.push_back(Args.MakeArgString(CudaArchToString(gpu_arch))); CmdArgs.push_back("--output-file"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31399: [coroutines] Handle get_return_object_on_allocation_failure
GorNishanov updated this revision to Diff 93177. GorNishanov added a comment. Added diagnostic test to SemaCXX/coroutines.cpp Preparing to Land https://reviews.llvm.org/D31399 Files: include/clang/AST/StmtCXX.h include/clang/Basic/DiagnosticSemaKinds.td lib/AST/StmtCXX.cpp lib/CodeGen/CGCoroutine.cpp lib/Sema/SemaCoroutine.cpp test/CodeGenCoroutines/coro-alloc.cpp test/SemaCXX/coroutines.cpp Index: test/SemaCXX/coroutines.cpp === --- test/SemaCXX/coroutines.cpp +++ test/SemaCXX/coroutines.cpp @@ -634,3 +634,21 @@ //expected-note@-1 {{call to 'initial_suspend' implicitly required by the initial suspend point}} co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}} } + +struct promise_on_alloc_failure_tag {}; + +template<> +struct std::experimental::coroutine_traits { + struct promise_type { +int get_return_object() {} +suspend_always initial_suspend() { return {}; } +suspend_always final_suspend() { return {}; } +void return_void() {} +int get_return_object_on_allocation_failure(); // expected-error{{'promise_type': 'get_return_object_on_allocation_failure()' must be a static member function}} +void unhandled_exception(); + }; +}; + +extern "C" int f(promise_on_alloc_failure_tag) { + co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}} +} Index: test/CodeGenCoroutines/coro-alloc.cpp === --- test/CodeGenCoroutines/coro-alloc.cpp +++ test/CodeGenCoroutines/coro-alloc.cpp @@ -40,7 +40,7 @@ }; }; -// CHECK-LABEL: f0( +// CHECK-LABEL: f0( extern "C" void f0(global_new_delete_tag) { // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16 // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64() @@ -65,7 +65,7 @@ }; }; -// CHECK-LABEL: f1( +// CHECK-LABEL: f1( extern "C" void f1(promise_new_tag ) { // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16 // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64() @@ -90,7 +90,7 @@ }; }; -// CHECK-LABEL: f2( +// CHECK-LABEL: f2( extern "C" void f2(promise_delete_tag) { // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16 // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64() @@ -127,3 +127,30 @@ // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJv24promise_sized_delete_tagEE12promise_typedlEPvm(i8* %[[MEM]], i64 %[[SIZE2]]) co_return; } + +struct promise_on_alloc_failure_tag {}; + +template<> +struct std::experimental::coroutine_traits { + struct promise_type { +int get_return_object() {} +suspend_always initial_suspend() { return {}; } +suspend_always final_suspend() { return {}; } +void return_void() {} +static int get_return_object_on_allocation_failure() { return -1; } + }; +}; + +// CHECK-LABEL: f4( +extern "C" int f4(promise_on_alloc_failure_tag) { + // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16 + // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64() + // CHECK: %[[MEM:.+]] = call i8* @_Znwm(i64 %[[SIZE]]) + // CHECK: %[[OK:.+]] = icmp ne i8* %[[MEM]], null + // CHECK: br i1 %[[OK]], label %[[OKBB:.+]], label %[[ERRBB:.+]] + + // CHECK: [[ERRBB]]: + // CHECK: %[[RETVAL:.+]] = call i32 @_ZNSt12experimental16coroutine_traitsIJi28promise_on_alloc_failure_tagEE12promise_type39get_return_object_on_allocation_failureEv( + // CHECK: ret i32 %[[RETVAL]] + co_return; +} Index: lib/Sema/SemaCoroutine.cpp === --- lib/Sema/SemaCoroutine.cpp +++ lib/Sema/SemaCoroutine.cpp @@ -708,8 +708,8 @@ } this->IsValid = makePromiseStmt() && makeInitialAndFinalSuspend() && makeOnException() && makeOnFallthrough() && -makeNewAndDeleteExpr() && makeReturnObject() && -makeParamMoves(); +makeReturnOnAllocFailure() && makeNewAndDeleteExpr() && +makeReturnObject() && makeParamMoves(); } bool isInvalid() const { return !this->IsValid; } @@ -720,6 +720,7 @@ bool makeOnFallthrough(); bool makeOnException(); bool makeReturnObject(); + bool makeReturnOnAllocFailure(); bool makeParamMoves(); }; } @@ -777,6 +778,66 @@ return true; } +static bool diagReturnOnAllocFailure(Sema &S, Expr *E, + CXXRecordDecl *PromiseRecordDecl, + FunctionScopeInfo &Fn) { + auto Loc = E->getExprLoc(); + if (auto *DeclRef = dyn_cast_or_null(E)) { +auto *Decl = DeclRef->getDecl(); +if (CXXMethodDecl *Method = dyn_cast_or_null(Decl)) { + if (Method->isStatic()) +return true; + else +Loc = Decl->getLocation(); +} + } + + S.Diag( + Loc, + diag::err_coroutine_promise_get_return_object_on_allocation_failure) + << PromiseRecordDecl; + S.Diag(Fn.FirstCoroutineStmtLoc,
Re: [PATCH] D31153: Add the ability to use the children() range API in a const-correct manner
On Mon, Mar 27, 2017 at 10:20 AM Aaron Ballman via Phabricator < revi...@reviews.llvm.org> wrote: > aaron.ballman added a comment. > > In https://reviews.llvm.org/D31153#711287, @dblaikie wrote: > > > As I mentioned to Craig Topper recently on another review, generally > when implementing const and non-const overloads the non-const is > implemented in terms of the const overload (& const_casts away const on the > result). This ensures no UB if the const overload is called on a truly > const object. Even if there aren't any truly const Stmts today, I'd still > prefer the code be written so as not to assume they couldn't exist. > > > In practice, this is really hard to do because there's no such thing as a > const_iterator_cast operation to convert a const_iterator into an iterator, > unless you have the underlying container handy. Seems like it might be feasible to implement. Something along the lines of: struct StmtIterator : ... { private: StmtIterator(const ConstStmtIterator& RHS) : StmtIteratorImpl(RHS) { } friend StmtIterator const_cast(const ConstStmtIterator& RHS) { return RHS; } Something along those lines, I think? (StmtIteratorImpl has a protected ctor that takes a StmtIteratorBase - const or non-const, it doesn't seem to care - so StmtIterator can call that with a ConstStmtIterator and do the conversion?) > Since many of these uses do not have an underlying container (they're > often trailing objects), I'm not certain this is practical (though I agree > with the reasoning). Suggestions welcome, however. > > > https://reviews.llvm.org/D31153 > > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30837: [libcxx] Support for shared_ptr
Quuxplusone added inline comments. Comment at: include/memory:3933 +typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, _AllocT > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), _AllocT()); __hold.release(); EricWF wrote: > This patch seems to support constructing a shared_ptr without > providing a non-default deleter. I don't think this should work because the > default deleter will attempt to free a function pointer, which is never > valid. (Although I think this case will still cause a compile error). Good point. But then are you suggesting that this constructor should be SFINAEd in that case, or just static_assert, or leave the existing behavior (which is indeed a hard compile error *inside* a static-assert)? ``` /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2514:27: error: invalid application of 'sizeof' to a function type static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type"); ^~~ x.cc:6:2: note: in instantiation of member function 'std::__1::default_delete::operator()' requested here ``` (Technically-technically, arguably the user is allowed to fully specialize `std::default_delete` for some user-defined type `T`, right? Not that libc++ ought to be catering to such people.) https://reviews.llvm.org/D30837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D23418: [analyzer] Added a reusable constraint system to the CloneDetector
teemperor updated this revision to Diff 93180. teemperor added a comment. Herald added a subscriber: mgorny. Thanks for the review Artem! Changes: - No longer including the old LLVM hashing header. - Fixed the messed up comment formatting when i removed all the `\brief`s... - `CloneConstraint` is now just a collection of static methods and its no longer necessary to inherit from it. (Maybe we can just replace it in the future with a namespace in the future? I don't like free floating functions and they don't fit into the CloneDetector interface, so this felt like the least-ugly way to do it.) - Renamed Stmt to Seq to prevent that one warning Artem mentioned. - Added a example unittest that shows a bit how to use the API and how to create your own Constraint. - StmtSequence now uses Decl* instead of ASTContext. We get the ASTContext over the stored Decl, but with a Decl we can do better heuristics for StmtSequence::contains and we can do fast filtering based on function name etc. https://reviews.llvm.org/D23418 Files: include/clang/Analysis/CloneDetection.h lib/Analysis/CloneDetection.cpp lib/StaticAnalyzer/Checkers/CloneChecker.cpp unittests/Analysis/CMakeLists.txt unittests/Analysis/CloneDetectionTest.cpp Index: unittests/Analysis/CloneDetectionTest.cpp === --- /dev/null +++ unittests/Analysis/CloneDetectionTest.cpp @@ -0,0 +1,109 @@ +//===- unittests/Analysis/CloneDetectionTest.cpp - Clone detection tests --===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "clang/AST/RecursiveASTVisitor.h" +#include "clang/Analysis/CloneDetection.h" +#include "clang/Tooling/Tooling.h" +#include "gtest/gtest.h" + +namespace clang { +namespace analysis { +namespace { + +class CloneDetectionVisitor +: public RecursiveASTVisitor { + + CloneDetector &Detector; + +public: + explicit CloneDetectionVisitor(CloneDetector &D) : Detector(D) {} + + bool VisitFunctionDecl(FunctionDecl *D) { +Detector.analyzeCodeBody(D); +return true; + } +}; + +/// Example constraint for testing purposes. +/// Filters out all statements that are in a function which name starts with +/// "bar". +class NoBarFunctionConstraint { +public: + void constrain(std::vector &CloneGroups) { +CloneConstraint::splitCloneGroups(CloneGroups, [](const StmtSequence &A, + const StmtSequence &B) { + // Check if one of the sequences is in a function which name starts with + // "bar". + for (const StmtSequence &Arg : {A, B}) { +if (auto *D = dyn_cast(Arg.getContainingDecl())) { + if (D->getNameAsString().find("bar") == 0) +return false; +} + } + return true; +}); + } +}; + +TEST(CloneDetector, NoPostOrderTraversal) { + auto ASTUnit = + clang::tooling::buildASTFromCode("void foo1(int &a1) { a1++; }\n" + "void foo2(int &a2) { a2++; }\n" + "void bar1(int &a3) { a3++; }\n" + "void bar2(int &a4) { a4++; }\n"); + auto TU = ASTUnit->getASTContext().getTranslationUnitDecl(); + + CloneDetector Detector; + // Push all the function bodies into the detector. + CloneDetectionVisitor Visitor(Detector); + Visitor.TraverseTranslationUnitDecl(TU); + + // Find clones with the usual settings, but but we want to filter out + // all statements from functions which names start with "bar". + std::vector CloneGroups; + Detector.findClones(CloneGroups, NoBarFunctionConstraint(), + RecursiveCloneTypeIIConstraint(), + MinComplexityConstraint(2), MinGroupSizeConstraint(2), + OnlyLargestCloneConstraint()); + + ASSERT_EQ(CloneGroups.size(), 1u); + ASSERT_EQ(CloneGroups.front().size(), 2u); + + for (auto &Clone : CloneGroups.front()) { +auto ND = dyn_cast(Clone.getContainingDecl()); +ASSERT_TRUE(ND != nullptr); +// Check that no function name starting with "bar" is in the results... +ASSERT_TRUE(ND->getNameAsString().find("bar") != 0); + } + + // Retry above's example without the filter... + CloneGroups.clear(); + + Detector.findClones(CloneGroups, RecursiveCloneTypeIIConstraint(), + MinComplexityConstraint(2), MinGroupSizeConstraint(2), + OnlyLargestCloneConstraint()); + ASSERT_EQ(CloneGroups.size(), 1u); + ASSERT_EQ(CloneGroups.front().size(), 4u); + + // Count how many functions with the bar prefix we have in the results. + int FoundFunctionsWithBarPrefix = 0; + for (auto &Clone : CloneGroups.front()) { +auto ND = dyn_cast(Clone.getContainingDecl()); +ASSERT_TRUE(ND != nullptr);
[PATCH] D29647: [OpenMP] Extend CLANG target options with device offloading kind.
gtbercea updated this revision to Diff 93181. gtbercea marked 5 inline comments as done. gtbercea added a comment. Herald added subscribers: sbc100, dschuff, jfb, rengolin. Update patch to reflect latest source code changes. Repository: rL LLVM https://reviews.llvm.org/D29647 Files: include/clang/Driver/ToolChain.h lib/Driver/ToolChain.cpp lib/Driver/ToolChains/Clang.cpp lib/Driver/ToolChains/Cuda.cpp lib/Driver/ToolChains/Cuda.h lib/Driver/ToolChains/Fuchsia.cpp lib/Driver/ToolChains/Fuchsia.h lib/Driver/ToolChains/Gnu.cpp lib/Driver/ToolChains/Gnu.h lib/Driver/ToolChains/WebAssembly.cpp lib/Driver/ToolChains/WebAssembly.h lib/Driver/ToolChains/XCore.cpp lib/Driver/ToolChains/XCore.h Index: lib/Driver/ToolChains/XCore.h === --- lib/Driver/ToolChains/XCore.h +++ lib/Driver/ToolChains/XCore.h @@ -67,7 +67,8 @@ AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, - llvm::opt::ArgStringList &CC1Args) const override; + llvm::opt::ArgStringList &CC1Args, + Action::OffloadKind DeviceOffloadKind) const override; void AddClangCXXStdlibIncludeArgs( const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; Index: lib/Driver/ToolChains/XCore.cpp === --- lib/Driver/ToolChains/XCore.cpp +++ lib/Driver/ToolChains/XCore.cpp @@ -124,7 +124,8 @@ } void XCoreToolChain::addClangTargetOptions(const ArgList &DriverArgs, - ArgStringList &CC1Args) const { + ArgStringList &CC1Args, + Action::OffloadKind) const { CC1Args.push_back("-nostdsysteminc"); } Index: lib/Driver/ToolChains/WebAssembly.h === --- lib/Driver/ToolChains/WebAssembly.h +++ lib/Driver/ToolChains/WebAssembly.h @@ -53,7 +53,8 @@ bool SupportsProfiling() const override; bool HasNativeLLVMSupport() const override; void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, - llvm::opt::ArgStringList &CC1Args) const override; + llvm::opt::ArgStringList &CC1Args, + Action::OffloadKind DeviceOffloadKind) const override; RuntimeLibType GetDefaultRuntimeLibType() const override; CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override; void AddClangSystemIncludeArgs( Index: lib/Driver/ToolChains/WebAssembly.cpp === --- lib/Driver/ToolChains/WebAssembly.cpp +++ lib/Driver/ToolChains/WebAssembly.cpp @@ -130,7 +130,8 @@ bool WebAssembly::HasNativeLLVMSupport() const { return true; } void WebAssembly::addClangTargetOptions(const ArgList &DriverArgs, -ArgStringList &CC1Args) const { +ArgStringList &CC1Args, +Action::OffloadKind) const { if (DriverArgs.hasFlag(clang::driver::options::OPT_fuse_init_array, options::OPT_fno_use_init_array, true)) CC1Args.push_back("-fuse-init-array"); Index: lib/Driver/ToolChains/Gnu.h === --- lib/Driver/ToolChains/Gnu.h +++ lib/Driver/ToolChains/Gnu.h @@ -341,7 +341,8 @@ : Generic_GCC(D, Triple, Args) {} void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, - llvm::opt::ArgStringList &CC1Args) const override; + llvm::opt::ArgStringList &CC1Args, + Action::OffloadKind DeviceOffloadKind) const override; }; } // end namespace toolchains Index: lib/Driver/ToolChains/Gnu.cpp === --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -2411,7 +2411,8 @@ void Generic_ELF::anchor() {} void Generic_ELF::addClangTargetOptions(const ArgList &DriverArgs, -ArgStringList &CC1Args) const { +ArgStringList &CC1Args, +Action::OffloadKind) const { const Generic_GCC::GCCVersion &V = GCCInstallation.getVersion(); bool UseInitArrayDefault = getTriple().getArch() == llvm::Triple::aarch64 || Index: lib/Driver/ToolChains/Fuchsia.h === --- lib/Driver/ToolChains/Fuchsia.h +++ lib/Driver/ToolChains/Fuchsia.h @@ -55,7 +55,8 @@ GetCXXStdlib
[PATCH] D29647: [OpenMP] Extend CLANG target options with device offloading kind.
gtbercea added inline comments. Comment at: lib/Driver/ToolChains.cpp:4902 + DeviceOffloadingKind == Action::OFK_Cuda) && + "The offloading kind is not OpenMP or CUDA."); jlebar wrote: > Not sure this assertion message helps us much beyond what's already in the > code. Agreed. I've changed it to reflect that, currently, only OpenMP and CUDA offloading kinds are supported for this toolchain. Comment at: lib/Driver/ToolChains.cpp:4914 + options::OPT_fno_cuda_approx_transcendentals, + false)) + CC1Args.push_back("-fcuda-approx-transcendentals"); jlebar wrote: > Are these changes related to this patch? > > I have no problem cleaning up whitespace errors like these, but would prefer > for them to be split out separately if possible. Reverted them, since they only concern line length. Comment at: lib/Driver/ToolChains.cpp:4961 + // If this is an OpenMP device we only need to append the gpu name. + if (DeviceOffloadKind == Action::OFK_OpenMP) { jlebar wrote: > jlebar wrote: > > s/device/compilation/? > An "otherwise" would probably be helpful in this comment. Changed. Repository: rL LLVM https://reviews.llvm.org/D29647 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29647: [OpenMP] Extend CLANG target options with device offloading kind.
gtbercea added inline comments. Comment at: lib/Driver/Tools.cpp:12136 // Obtain architecture from the action. - CudaArch gpu_arch = StringToCudaArch(JA.getOffloadingArch()); assert(gpu_arch != CudaArch::UNKNOWN && jlebar wrote: > Why does JA.getOffloadingArch have the wrong value? Isn't the purpose of > JA.getOffloadingArch to have this particular value? If it's broken, can we > fix it instead of doing this hack? I have to investigate this. Thanks for pointing this out. Repository: rL LLVM https://reviews.llvm.org/D29647 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D23418: [analyzer] Added a reusable constraint system to the CloneDetector
teemperor marked 7 inline comments as done. teemperor added a comment. Hey Leslie, regarding performance: Last time I checked we spend most of the time on the verification of the hash values. We can do some tricks to make this faster (like delaying the verification to the end of the constraints where we have much less clones and therefore less overhead with this) regarding false-positives: We will do some basic stuff to reduce them soon-ish (e.g. increasing the minimum clone size default value, filtering those generated files). Afterwards we probably need some fancier way of teaching the checker what is a valid clone and what not. If you have some actual bugs that are found by the checker, please send them to me (teemperor [AT] gmail.com) that we can add them to the regression tests :) Comment at: include/clang/Analysis/CloneDetection.h:218-219 +/// +/// This class should be the base class of all constraints that are used in +/// combination with the CloneDetector class. +/// As constraints are specified in the form of template parameters, this class NoQ wrote: > While you could enforce this with `static_assert T>>` in the detector, i think we shouldn't be strictly enforcing this. > > Providing useful utility functions is pretty much the only purpose of this > class, so it intends to be useful, but this shouldn't block users from > implementing the `constrain()` method completely from scratch. > > Also, we could probably move the method that groups clones by hashes here as > the third utility method, if more than one hash function is eventually used(?) Everything done here beside the hashing, because I think we need to do a few changes there in the future that need some more discussion. For example: * Split up hashing and verifying them into different constraints. This could drastically improve performance because verification of hashes id currently the biggest time-consumer on an average code-base (at least that was the case the last time I profiled :) ). Depending on how we do this we might need to rely to a certain degree on the unique-ness property of the hash codes... * Unify the hashing we do with the hashing that we use in the AST. I think we should wait here until we are sure that this is the right thing to do and that the code is mature enough. Comment at: lib/StaticAnalyzer/Checkers/CloneChecker.cpp:81-83 + Detector.findClones(AllCloneGroups, RecursiveCloneTypeIIConstraint(), + MinComplexityConstraint(MinComplexity), + MinGroupSizeConstraint(2), OnlyLargestCloneConstraint()); NoQ wrote: > Yay. I like how it looks. \o/ https://reviews.llvm.org/D23418 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29651: [OpenMP] Consider LIBRARY_PATH when selecting library paths for NVPTX targets in OpenMP mode.
gtbercea updated this revision to Diff 93188. gtbercea added a comment. Herald added a subscriber: rengolin. Update patch to reflect latest source code changes. Repository: rL LLVM https://reviews.llvm.org/D29651 Files: lib/Driver/ToolChains/Cuda.cpp test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -615,3 +615,12 @@ // CHK-FOPENMP-IS-DEVICE: clang{{.*}}.i" {{.*}}" "-fopenmp-is-device" // CHK-FOPENMP-IS-DEVICE-NEXT: clang{{.*}}.bc" {{.*}}.i" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" // CHK-FOPENMP-IS-DEVICE-NEXT: clang{{.*}}.s" {{.*}}.bc" "-fopenmp-is-device" + +/// ### + +/// Check that the lib folder pointed to by the LIBRARY_PATH is correctly passsed to the loader script. +// RUN: LIBRARY_PATH=/a/b/c/lib %clang -### -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -save-temps -no-canonical-prefixes %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-LIB-PATH %s + +// CHK-LIB-PATH: ld{{.*}}.o" "-L/a/b/c/lib" +// CHK-LIB-PATH: ld{{.*}}.o" "-L/a/b/c/lib" Index: lib/Driver/ToolChains/Cuda.cpp === --- lib/Driver/ToolChains/Cuda.cpp +++ lib/Driver/ToolChains/Cuda.cpp @@ -401,6 +401,19 @@ // came with CUDA-7.0. CC1Args.push_back("-target-feature"); CC1Args.push_back("+ptx42"); + + if (DeviceOffloadingKind == Action::OFK_OpenMP) { +SmallVector LibraryPaths; +if (char *Env = ::getenv("LIBRARY_PATH")) { + StringRef CompilerPath = Env; + while (!CompilerPath.empty()) { +std::pair Split = +CompilerPath.split(llvm::sys::EnvPathSeparator); +LibraryPaths.push_back(Split.first); +CompilerPath = Split.second; + } +} + } } void CudaToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs, Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -615,3 +615,12 @@ // CHK-FOPENMP-IS-DEVICE: clang{{.*}}.i" {{.*}}" "-fopenmp-is-device" // CHK-FOPENMP-IS-DEVICE-NEXT: clang{{.*}}.bc" {{.*}}.i" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" // CHK-FOPENMP-IS-DEVICE-NEXT: clang{{.*}}.s" {{.*}}.bc" "-fopenmp-is-device" + +/// ### + +/// Check that the lib folder pointed to by the LIBRARY_PATH is correctly passsed to the loader script. +// RUN: LIBRARY_PATH=/a/b/c/lib %clang -### -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -save-temps -no-canonical-prefixes %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-LIB-PATH %s + +// CHK-LIB-PATH: ld{{.*}}.o" "-L/a/b/c/lib" +// CHK-LIB-PATH: ld{{.*}}.o" "-L/a/b/c/lib" Index: lib/Driver/ToolChains/Cuda.cpp === --- lib/Driver/ToolChains/Cuda.cpp +++ lib/Driver/ToolChains/Cuda.cpp @@ -401,6 +401,19 @@ // came with CUDA-7.0. CC1Args.push_back("-target-feature"); CC1Args.push_back("+ptx42"); + + if (DeviceOffloadingKind == Action::OFK_OpenMP) { +SmallVector LibraryPaths; +if (char *Env = ::getenv("LIBRARY_PATH")) { + StringRef CompilerPath = Env; + while (!CompilerPath.empty()) { +std::pair Split = +CompilerPath.split(llvm::sys::EnvPathSeparator); +LibraryPaths.push_back(Split.first); +CompilerPath = Split.second; + } +} + } } void CudaToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31408: Add more examples to clang-format configuration
sylvestre.ledru created this revision. Herald added a subscriber: klimek. https://reviews.llvm.org/D31408 Files: docs/ClangFormatStyleOptions.rst include/clang/Format/Format.h Index: include/clang/Format/Format.h === --- include/clang/Format/Format.h +++ include/clang/Format/Format.h @@ -705,6 +705,12 @@ bool BreakConstructorInitializersBeforeComma; /// \brief Break after each annotation on a field in Java files. + /// \code + ///true: false: + ///@Partial vs. @Partial @Mock DataLoad loader; + ///@Mock + ///DataLoad loader; + /// \endcode bool BreakAfterJavaFieldAnnotations; /// \brief Allow breaking string literals when formatting. @@ -760,6 +766,14 @@ unsigned ConstructorInitializerIndentWidth; /// \brief Indent width for line continuations. + /// \code + ///ContinuationIndentWidth: 2 + ///ColumnLimit: 15 + /// + ///int i = + /// longFunction( + ///arg); + /// \endcode unsigned ContinuationIndentWidth; /// \brief If ``true``, format braced lists as best suited for C++11 braced @@ -775,11 +789,25 @@ /// (e.g. a type or variable name), clang-format formats as if the ``{}`` were /// the parentheses of a function call with that name. If there is no name, /// a zero-length name is assumed. + /// \code + ///true: false: + ///vector x{1, 2, 3, 4}; vs. vector x{ 1, 2, 3, 4 }; + ///vector x{{}, {}, {}, {}}; vector x{ {}, {}, {}, {} }; + ///f(MyMap[{composite, key}]);f(MyMap[{ composite, key }]); + ///new int[3]{1, 2, 3}; new int[3]{ 1, 2, 3 }; + /// \endcode bool Cpp11BracedListStyle; /// \brief If ``true``, analyze the formatted file for the most common /// alignment of ``&`` and ``*``. ``PointerAlignment`` is then used only as /// fallback. + /// \code + ///original: vs. true: + ///int *foo = 2; int *foo = 2; + ///int &j = i;int &j = i; + ///int *k = & j; int *k = &j; + ///T* k = &j; T *k = &j; + /// \endcode bool DerivePointerAlignment; /// \brief Disables formatting completely. @@ -880,11 +908,22 @@ /// /// When ``false``, use the same indentation level as for the switch statement. /// Switch statement body is always indented one level more than case labels. + /// \code + ///false: true: + ///switch (fool) {vs. switch (fool) { + ///case 1: case 1: + /// bar(); bar(); + /// break; break; + ///default: default: + /// plop(); plop(); + ///} } + /// \endcode bool IndentCaseLabels; /// \brief The number of columns to use for indentation. /// \code ///IndentWidth: 3 + /// ///void f() { /// someFunction(); /// if (true, false) { @@ -896,6 +935,15 @@ /// \brief Indent if a function definition or declaration is wrapped after the /// type. + /// \code + ///true: + ///LngReturnType + ///LngFunctionDeclaration(); + /// + ///false: + ///LngReturnType + ///LngFunctionDeclaration(); + /// \endcode bool IndentWrappedFunctionNames; /// \brief Quotation styles for JavaScript strings. Does not affect template @@ -938,7 +986,14 @@ /// \endcode bool JavaScriptWrapImports; - /// \brief If true, empty lines at the start of blocks are kept. + /// \brief If true, the empty line at the start of blocks is kept. + /// \code + ///true: false: + ///if (foo) { vs. if (foo) { + /// bar(); + /// bar(); } + ///} + /// \endcode bool KeepEmptyLinesAtTheStartOfBlocks; /// \brief Supported languages. @@ -1050,6 +1105,13 @@ NamespaceIndentationKind NamespaceIndentation; /// \brief The number of characters to use for indentation of ObjC blocks. + /// \code + ///ObjCBlockIndentWidth: 4 + /// + ///[operation setCompletionBlock:^{ + ///[self onOperationDone]; + ///}]; + /// \endcode unsigned ObjCBlockIndentWidth; /// \brief Add a space after ``@property`` in Objective-C, i.e. use Index: docs/ClangFormatStyleOptions.rst === --- docs/C
[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary
gtbercea updated this revision to Diff 93192. gtbercea added a comment. Herald added a subscriber: rengolin. Update patch to reflect latest source code changes. Repository: rL LLVM https://reviews.llvm.org/D29654 Files: lib/Driver/ToolChains/CommonArgs.cpp lib/Driver/ToolChains/CommonArgs.h lib/Driver/ToolChains/Cuda.cpp lib/Driver/ToolChains/Gnu.cpp test/Driver/openmp-offload.c Index: test/Driver/openmp-offload.c === --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -590,6 +590,17 @@ /// ### +/// Check cubin file generation and usage by nvlink +// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-CUBIN %s + +// CHK-CUBIN: clang{{.*}}" "-o" "{{.*}}-openmp-nvptx64-nvidia-cuda.s" +// CHK-CUBIN-NEXT: ptxas{{.*}}" "--output-file" "{{.*}}-openmp-nvptx64-nvidia-cuda.o" "{{.*}}-openmp-nvptx64-nvidia-cuda.s" +// CHK-CUBIN-NEXT: cp{{.*}}-openmp-nvptx64-nvidia-cuda.o" "{{.*}}-openmp-nvptx64-nvidia-cuda-{{.*}}.cubin" +// CHK-CUBIN-NEXT: nvlink" "-o" "{{.*}}-openmp-nvptx64-nvidia-cuda" "{{.*}}" "{{.*}}-openmp-nvptx64-nvidia-cuda-{{.*}}.cubin" + +/// ### + /// Check PTXAS is passed -c flag when offloading to an NVIDIA device using OpenMP. // RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-PTXAS %s Index: lib/Driver/ToolChains/Gnu.cpp === --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -203,131 +203,6 @@ // The types are (hopefully) good enough. } -/// Add OpenMP linker script arguments at the end of the argument list so that -/// the fat binary is built by embedding each of the device images into the -/// host. The linker script also defines a few symbols required by the code -/// generation so that the images can be easily retrieved at runtime by the -/// offloading library. This should be used only in tool chains that support -/// linker scripts. -static void AddOpenMPLinkerScript(const ToolChain &TC, Compilation &C, - const InputInfo &Output, - const InputInfoList &Inputs, - const ArgList &Args, ArgStringList &CmdArgs, - const JobAction &JA) { - - // If this is not an OpenMP host toolchain, we don't need to do anything. - if (!JA.isHostOffloading(Action::OFK_OpenMP)) -return; - - // Create temporary linker script. Keep it if save-temps is enabled. - const char *LKS; - SmallString<256> Name = llvm::sys::path::filename(Output.getFilename()); - if (C.getDriver().isSaveTempsEnabled()) { -llvm::sys::path::replace_extension(Name, "lk"); -LKS = C.getArgs().MakeArgString(Name.c_str()); - } else { -llvm::sys::path::replace_extension(Name, ""); -Name = C.getDriver().GetTemporaryPath(Name, "lk"); -LKS = C.addTempFile(C.getArgs().MakeArgString(Name.c_str())); - } - - // Add linker script option to the command. - CmdArgs.push_back("-T"); - CmdArgs.push_back(LKS); - - // Create a buffer to write the contents of the linker script. - std::string LksBuffer; - llvm::raw_string_ostream LksStream(LksBuffer); - - // Get the OpenMP offload tool chains so that we can extract the triple - // associated with each device input. - auto OpenMPToolChains = C.getOffloadToolChains(); - assert(OpenMPToolChains.first != OpenMPToolChains.second && - "No OpenMP toolchains??"); - - // Track the input file name and device triple in order to build the script, - // inserting binaries in the designated sections. - SmallVector, 8> InputBinaryInfo; - - // Add commands to embed target binaries. We ensure that each section and - // image is 16-byte aligned. This is not mandatory, but increases the - // likelihood of data to be aligned with a cache block in several main host - // machines. - LksStream << "/*\n"; - LksStream << " OpenMP Offload Linker Script\n"; - LksStream << " *** Automatically generated by Clang ***\n"; - LksStream << "*/\n"; - LksStream << "TARGET(binary)\n"; - auto DTC = OpenMPToolChains.first; - for (auto &II : Inputs) { -const Action *A = II.getAction(); -// Is this a device linking action? -if (A && isa(A) && -A->isDeviceOffloading(Action::OFK_OpenMP)) { - assert(DTC != OpenMPToolChains.second && - "More device inputs than device toolchains??"); - InputBinaryInfo.push_back(std::make_pair( - DTC->second->getTriple().normalize(), II.getFilename())); - ++DTC; - LksStream << "INPUT(" << II.getFilename() << ")\n"; -} - } - -
[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary
jlebar added a comment. With your latest set of updates, I am not sure which, if any, patches you need me to take another look at. Unfortunately I don't have a ton of time for CUDA stuff these days, so where possible I'd prefer to shunt reviews over to hfinkel or chandlerc. But do let me know. Repository: rL LLVM https://reviews.llvm.org/D29654 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31328: [clangd] Add code completion support
malaperle-ericsson added inline comments. Comment at: test/clangd/formatting.test:14 +# CHECK: "codeActionProvider": true, +# CHECK: "completionProvider": {"resolveProvider": false, "triggerCharacters": [".",">"]} # CHECK: }}} It would be good eventually to trigger on "::" (static members, etc) https://reviews.llvm.org/D31328 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31328: [clangd] Add code completion support
malaperle-ericsson added a comment. Ideas/Observations: - One thing I has done in my version is to introduce "ASTUnitRunnable", a lambda function type that has an ASTUnit as parameter and is executed by the ASTManager. So the ASTManager takes care of locking the AST but the actual code using the AST is kept in the ProtocolHandlers. I think this can be refactored later if this is seen as a good approach. - I have noticed while testing that there is some wrong escaping happening. I had typed "ù" by mistake (french keyboard layout!) and it threw an error about unexpected \x. I think using yaml::escape is not entirely correct. This can be addressed in a different patch because it affects other protocol handlers as well (diagnostics, etc). - I noticed that "file://" is stripped from file:///path but not "file:" in file:/path, I think it's the Eclipse client that's wrong here. But I don't see any immediate need to change anything in this patch. https://reviews.llvm.org/D31328 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31408: Add more examples to clang-format configuration
Eugene.Zelenko added inline comments. Comment at: docs/ClangFormatStyleOptions.rst:644 + .. code-block:: c++ + Shouldn't it be java? Comment at: docs/ClangFormatStyleOptions.rst:1293 + .. code-block:: c++ + Shouldn't it be objective-c? https://reviews.llvm.org/D31408 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31408: Add more examples to clang-format configuration
sylvestre.ledru updated this revision to Diff 93195. sylvestre.ledru added a comment. Thanks, indeed! :) https://reviews.llvm.org/D31408 Files: docs/ClangFormatStyleOptions.rst include/clang/Format/Format.h Index: include/clang/Format/Format.h === --- include/clang/Format/Format.h +++ include/clang/Format/Format.h @@ -177,7 +177,7 @@ SFS_Empty, /// \brief Only merge functions defined inside a class. Implies "empty". /// \code -/// class { +/// class Foo { /// void f() { foo(); } /// }; /// \endcode @@ -184,7 +184,7 @@ SFS_Inline, /// \brief Merge all functions fitting on a single line. /// \code -/// class { +/// class Foo { /// void f() { foo(); } /// }; /// void f() { bar(); } @@ -705,6 +705,12 @@ bool BreakConstructorInitializersBeforeComma; /// \brief Break after each annotation on a field in Java files. + /// \code{.java} + ///true: false: + ///@Partial vs. @Partial @Mock DataLoad loader; + ///@Mock + ///DataLoad loader; + /// \endcode bool BreakAfterJavaFieldAnnotations; /// \brief Allow breaking string literals when formatting. @@ -720,7 +726,7 @@ /// \brief A regular expression that describes comments with special meaning, /// which should not be split into lines or otherwise changed. /// \code - ///CommentPragmas: '^ FOOBAR pragma:' + ///// CommentPragmas: '^ FOOBAR pragma:' ///// Will leave the following line unaffected ///#include // FOOBAR pragma: keep /// \endcode @@ -760,6 +766,14 @@ unsigned ConstructorInitializerIndentWidth; /// \brief Indent width for line continuations. + /// \code + ///ContinuationIndentWidth: 2 + ///ColumnLimit: 15 + /// + ///int i = + /// longFunction( + ///arg); + /// \endcode unsigned ContinuationIndentWidth; /// \brief If ``true``, format braced lists as best suited for C++11 braced @@ -775,11 +789,25 @@ /// (e.g. a type or variable name), clang-format formats as if the ``{}`` were /// the parentheses of a function call with that name. If there is no name, /// a zero-length name is assumed. + /// \code + ///true: false: + ///vector x{1, 2, 3, 4}; vs. vector x{ 1, 2, 3, 4 }; + ///vector x{{}, {}, {}, {}}; vector x{ {}, {}, {}, {} }; + ///f(MyMap[{composite, key}]);f(MyMap[{ composite, key }]); + ///new int[3]{1, 2, 3}; new int[3]{ 1, 2, 3 }; + /// \endcode bool Cpp11BracedListStyle; /// \brief If ``true``, analyze the formatted file for the most common /// alignment of ``&`` and ``*``. ``PointerAlignment`` is then used only as /// fallback. + /// \code + ///original: vs. true: + ///int *foo = 2; int *foo = 2; + ///int &j = i;int &j = i; + ///int *k = & j; int *k = &j; + ///T* k = &j; T *k = &j; + /// \endcode bool DerivePointerAlignment; /// \brief Disables formatting completely. @@ -880,11 +908,22 @@ /// /// When ``false``, use the same indentation level as for the switch statement. /// Switch statement body is always indented one level more than case labels. + /// \code + ///false: true: + ///switch (fool) {vs. switch (fool) { + ///case 1: case 1: + /// bar(); bar(); + /// break; break; + ///default: default: + /// plop(); plop(); + ///} } + /// \endcode bool IndentCaseLabels; /// \brief The number of columns to use for indentation. /// \code ///IndentWidth: 3 + /// ///void f() { /// someFunction(); /// if (true, false) { @@ -896,6 +935,15 @@ /// \brief Indent if a function definition or declaration is wrapped after the /// type. + /// \code + ///true: + ///LngReturnType + ///LngFunctionDeclaration(); + /// + ///false: + ///LngReturnType + ///LngFunctionDeclaration(); + /// \endcode bool IndentWrappedFunctionNames; /// \brief Quotation styles for JavaScript strings. Does not affect template @@ -938,7 +986,14 @@ /// \endcode bool JavaScriptWrapImports; - /// \brief If true, empty lines at the start of blocks are kept. + /// \brief If true, the empty line at the start of blocks i
r298891 - [coroutines] Handle get_return_object_on_allocation_failure
Author: gornishanov Date: Mon Mar 27 18:36:59 2017 New Revision: 298891 URL: http://llvm.org/viewvc/llvm-project?rev=298891&view=rev Log: [coroutines] Handle get_return_object_on_allocation_failure Summary: If promise_type has get_return_object_on_allocation_failure defined, check if an allocation function returns nullptr, and if so, return the result of get_return_object_on_allocation_failure(). Reviewers: rsmith, EricWF Reviewed By: EricWF Subscribers: mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D31399 Modified: cfe/trunk/include/clang/AST/StmtCXX.h cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/AST/StmtCXX.cpp cfe/trunk/lib/CodeGen/CGCoroutine.cpp cfe/trunk/lib/Sema/SemaCoroutine.cpp cfe/trunk/test/CodeGenCoroutines/coro-alloc.cpp cfe/trunk/test/SemaCXX/coroutines.cpp Modified: cfe/trunk/include/clang/AST/StmtCXX.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtCXX.h?rev=298891&r1=298890&r2=298891&view=diff == --- cfe/trunk/include/clang/AST/StmtCXX.h (original) +++ cfe/trunk/include/clang/AST/StmtCXX.h Mon Mar 27 18:36:59 2017 @@ -309,6 +309,7 @@ class CoroutineBodyStmt final Allocate, ///< Coroutine frame memory allocation. Deallocate,///< Coroutine frame memory deallocation. ReturnValue, ///< Return value for thunk function. +ReturnStmtOnAllocFailure, ///< Return statement if allocation failed. FirstParamMove ///< First offset for move construction of parameter copies. }; unsigned NumParams; @@ -332,6 +333,7 @@ public: Expr *Allocate = nullptr; Expr *Deallocate = nullptr; Stmt *ReturnValue = nullptr; +Stmt *ReturnStmtOnAllocFailure = nullptr; ArrayRef ParamMoves; }; @@ -379,6 +381,9 @@ public: Expr *getReturnValueInit() const { return cast_or_null(getStoredStmts()[SubStmt::ReturnValue]); } + Stmt *getReturnStmtOnAllocFailure() const { +return getStoredStmts()[SubStmt::ReturnStmtOnAllocFailure]; + } ArrayRef getParamMoves() const { return {getStoredStmts() + SubStmt::FirstParamMove, NumParams}; } Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=298891&r1=298890&r2=298891&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Mar 27 18:36:59 2017 @@ -8878,6 +8878,8 @@ def err_coroutine_promise_unhandled_exce def warn_coroutine_promise_unhandled_exception_required_with_exceptions : Warning< "%0 is required to declare the member 'unhandled_exception()' when exceptions are enabled">, InGroup; +def err_coroutine_promise_get_return_object_on_allocation_failure : Error< + "%0: 'get_return_object_on_allocation_failure()' must be a static member function">; } let CategoryName = "Documentation Issue" in { Modified: cfe/trunk/lib/AST/StmtCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtCXX.cpp?rev=298891&r1=298890&r2=298891&view=diff == --- cfe/trunk/lib/AST/StmtCXX.cpp (original) +++ cfe/trunk/lib/AST/StmtCXX.cpp Mon Mar 27 18:36:59 2017 @@ -108,6 +108,8 @@ CoroutineBodyStmt::CoroutineBodyStmt(Cor SubStmts[CoroutineBodyStmt::Allocate] = Args.Allocate; SubStmts[CoroutineBodyStmt::Deallocate] = Args.Deallocate; SubStmts[CoroutineBodyStmt::ReturnValue] = Args.ReturnValue; + SubStmts[CoroutineBodyStmt::ReturnStmtOnAllocFailure] = + Args.ReturnStmtOnAllocFailure; std::copy(Args.ParamMoves.begin(), Args.ParamMoves.end(), const_cast(getParamMoves().data())); } \ No newline at end of file Modified: cfe/trunk/lib/CodeGen/CGCoroutine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCoroutine.cpp?rev=298891&r1=298890&r2=298891&view=diff == --- cfe/trunk/lib/CodeGen/CGCoroutine.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCoroutine.cpp Mon Mar 27 18:36:59 2017 @@ -229,7 +229,24 @@ void CodeGenFunction::EmitCoroutineBody( createCoroData(*this, CurCoro, CoroId); CurCoro.Data->SuspendBB = RetBB; - EmitScalarExpr(S.getAllocate()); + auto *AllocateCall = EmitScalarExpr(S.getAllocate()); + + // Handle allocation failure if 'ReturnStmtOnAllocFailure' was provided. + if (auto *RetOnAllocFailure = S.getReturnStmtOnAllocFailure()) { +auto *RetOnFailureBB = createBasicBlock("coro.ret.on.failure"); +auto *InitBB = createBasicBlock("coro.init"); + +// See if allocation was successful. +auto *NullPtr = llvm::ConstantPointerNull::get(Int8PtrTy); +auto *Cond = Builder.CreateICmpNE(AllocateCall, NullPtr); +Builde
[PATCH] D31399: [coroutines] Handle get_return_object_on_allocation_failure
This revision was automatically updated to reflect the committed changes. GorNishanov marked an inline comment as done. Closed by commit rL298891: [coroutines] Handle get_return_object_on_allocation_failure (authored by GorNishanov). Changed prior to commit: https://reviews.llvm.org/D31399?vs=93177&id=93196#toc Repository: rL LLVM https://reviews.llvm.org/D31399 Files: cfe/trunk/include/clang/AST/StmtCXX.h cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/AST/StmtCXX.cpp cfe/trunk/lib/CodeGen/CGCoroutine.cpp cfe/trunk/lib/Sema/SemaCoroutine.cpp cfe/trunk/test/CodeGenCoroutines/coro-alloc.cpp cfe/trunk/test/SemaCXX/coroutines.cpp Index: cfe/trunk/test/SemaCXX/coroutines.cpp === --- cfe/trunk/test/SemaCXX/coroutines.cpp +++ cfe/trunk/test/SemaCXX/coroutines.cpp @@ -634,3 +634,21 @@ //expected-note@-1 {{call to 'initial_suspend' implicitly required by the initial suspend point}} co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}} } + +struct promise_on_alloc_failure_tag {}; + +template<> +struct std::experimental::coroutine_traits { + struct promise_type { +int get_return_object() {} +suspend_always initial_suspend() { return {}; } +suspend_always final_suspend() { return {}; } +void return_void() {} +int get_return_object_on_allocation_failure(); // expected-error{{'promise_type': 'get_return_object_on_allocation_failure()' must be a static member function}} +void unhandled_exception(); + }; +}; + +extern "C" int f(promise_on_alloc_failure_tag) { + co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}} +} Index: cfe/trunk/test/CodeGenCoroutines/coro-alloc.cpp === --- cfe/trunk/test/CodeGenCoroutines/coro-alloc.cpp +++ cfe/trunk/test/CodeGenCoroutines/coro-alloc.cpp @@ -40,7 +40,7 @@ }; }; -// CHECK-LABEL: f0( +// CHECK-LABEL: f0( extern "C" void f0(global_new_delete_tag) { // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16 // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64() @@ -65,7 +65,7 @@ }; }; -// CHECK-LABEL: f1( +// CHECK-LABEL: f1( extern "C" void f1(promise_new_tag ) { // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16 // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64() @@ -90,7 +90,7 @@ }; }; -// CHECK-LABEL: f2( +// CHECK-LABEL: f2( extern "C" void f2(promise_delete_tag) { // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16 // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64() @@ -127,3 +127,30 @@ // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJv24promise_sized_delete_tagEE12promise_typedlEPvm(i8* %[[MEM]], i64 %[[SIZE2]]) co_return; } + +struct promise_on_alloc_failure_tag {}; + +template<> +struct std::experimental::coroutine_traits { + struct promise_type { +int get_return_object() {} +suspend_always initial_suspend() { return {}; } +suspend_always final_suspend() { return {}; } +void return_void() {} +static int get_return_object_on_allocation_failure() { return -1; } + }; +}; + +// CHECK-LABEL: f4( +extern "C" int f4(promise_on_alloc_failure_tag) { + // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16 + // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64() + // CHECK: %[[MEM:.+]] = call i8* @_Znwm(i64 %[[SIZE]]) + // CHECK: %[[OK:.+]] = icmp ne i8* %[[MEM]], null + // CHECK: br i1 %[[OK]], label %[[OKBB:.+]], label %[[ERRBB:.+]] + + // CHECK: [[ERRBB]]: + // CHECK: %[[RETVAL:.+]] = call i32 @_ZNSt12experimental16coroutine_traitsIJi28promise_on_alloc_failure_tagEE12promise_type39get_return_object_on_allocation_failureEv( + // CHECK: ret i32 %[[RETVAL]] + co_return; +} Index: cfe/trunk/lib/CodeGen/CGCoroutine.cpp === --- cfe/trunk/lib/CodeGen/CGCoroutine.cpp +++ cfe/trunk/lib/CodeGen/CGCoroutine.cpp @@ -229,7 +229,24 @@ createCoroData(*this, CurCoro, CoroId); CurCoro.Data->SuspendBB = RetBB; - EmitScalarExpr(S.getAllocate()); + auto *AllocateCall = EmitScalarExpr(S.getAllocate()); + + // Handle allocation failure if 'ReturnStmtOnAllocFailure' was provided. + if (auto *RetOnAllocFailure = S.getReturnStmtOnAllocFailure()) { +auto *RetOnFailureBB = createBasicBlock("coro.ret.on.failure"); +auto *InitBB = createBasicBlock("coro.init"); + +// See if allocation was successful. +auto *NullPtr = llvm::ConstantPointerNull::get(Int8PtrTy); +auto *Cond = Builder.CreateICmpNE(AllocateCall, NullPtr); +Builder.CreateCondBr(Cond, InitBB, RetOnFailureBB); + +// If not, return OnAllocFailure object. +EmitBlock(RetOnFailureBB); +EmitStmt(RetOnAllocFailure); + +EmitBlock(InitBB); + } // FIXME: Setup cleanup scopes. Index: cfe/trunk/lib/AST/StmtCXX.cpp ===
[PATCH] D30837: [libcxx] Support for shared_ptr
EricWF added inline comments. Comment at: include/memory:3933 +typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, _AllocT > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), _AllocT()); __hold.release(); Quuxplusone wrote: > EricWF wrote: > > > This patch seems to support constructing a shared_ptr without > > providing a non-default deleter. I don't think this should work because the > > default deleter will attempt to free a function pointer, which is never > > valid. (Although I think this case will still cause a compile error). > > Good point. But then are you suggesting that this constructor should be > SFINAEd in that case, or just static_assert, or leave the existing behavior > (which is indeed a hard compile error *inside* a static-assert)? > > ``` > /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2514:27: > error: invalid application of > 'sizeof' to a function type > static_assert(sizeof(_Tp) > 0, "default_delete can not delete > incomplete type"); > ^~~ > x.cc:6:2: note: in instantiation of member function > 'std::__1::default_delete::operator()' requested here > ``` > > (Technically-technically, arguably the user is allowed to fully specialize > `std::default_delete` for some user-defined type `T`, right? Not that > libc++ ought to be catering to such people.) SFINAE is definitely the wrong approach, since we don't want to affect overload resolution. On second thought it's probably better to fix the allocator type here anyway, since the instantiation of `default_delete` will lead to a more readable compile error. Also you're right about user defined specializations of default_delete, you're also right that libc++ ought not care about such craziness. https://reviews.llvm.org/D30837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31003: [Objective-C] C++ Classes with __weak Members non-POD Types when using -fobjc-weak
rjmccall added a comment. In https://reviews.llvm.org/D31003#711359, @bkelley wrote: > Thank you @rjmccall for the approval. I don't have commit access; would > someone be willing to commit this path for me please? Thanks! You have a lot of patches here. :) I would encourage you to just ask for commit access; it's not a strenuous process. http://llvm.org/docs/DeveloperPolicy.html John. https://reviews.llvm.org/D31003 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31363: [libc++] Remove cmake glob for source files
EricWF added a comment. Thanks for fixing this. Sucks that we have to manually enumerate source files but this is the correct solution according to CMake. Would it be easy to still use `glob` to verify that none of the source files have accidentally been forgotten? Comment at: lib/CMakeLists.txt:304 if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY) file(GLOB LIBCXX_EXPERIMENTAL_SOURCES ../src/experimental/*.cpp) if (LIBCXX_ENABLE_FILESYSTEM) These globs should be fixed as well. https://reviews.llvm.org/D31363 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31399: [coroutines] Handle get_return_object_on_allocation_failure
alekseyshl added a comment. Seems like this bot is not happy about this change: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/3771 Repository: rL LLVM https://reviews.llvm.org/D31399 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29818: [libcxx] Threading support: Attempt to externalize system_clock::now() and steady_clock::now() implementations
EricWF added a comment. I really dislike that `__libcpp_clock_monotonic` and `__libcpp_clock_realtime` are never declared, and are expected to be magically defined by the external threading header. This makes the configuration seem incorrect and unused. Also the previous threading support changes were beneficial to libc++ because they cleaned up and centralized the threading interface, making it easier to port libc++ to different threading environments. This change has no such benefit. Why should libc++ upstream this ARM specific configuration need? https://reviews.llvm.org/D29818 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31178: [libcxxabi] Fix exception address alignment test for EHABI
EricWF added a comment. For the most part this LGTM other than the nits mentioned. Comment at: test/libcxxabi/test/config.py:34 +'libunwind_src', +os.path.join(self.libcxxabi_src_root, '/../libunwind/src')) I think the correct default here is `None`, not `../libunwind/src`, since we might not be using libunwind at all. Comment at: test/libcxxabi/test/config.py:93 + 'libunwind_headers', + os.path.join(self.libunwind_src, '/../include')) +if self.get_lit_bool('llvm_unwinder', False): I'm not sure if this is default is optimal. I think None might be less surprising. Comment at: test/lit.site.cfg.in:9 config.cxx_headers = "@LIBCXXABI_LIBCXX_INCLUDES@" +config.libunwind_src= "@LIBCXXABI_LIBUNWIND_SOURCES@" +config.libunwind_headers= "@LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL@" I don't think we need the unwind sources anywhere within the test suite. I would remove this option all together and simply depend on `libunwind_headers`. Comment at: test/lit.site.cfg.in:10 +config.libunwind_src= "@LIBCXXABI_LIBUNWIND_SOURCES@" +config.libunwind_headers= "@LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL@" config.cxx_library_root = "@LIBCXXABI_LIBCXX_LIBRARY_PATH@" I think `libunwind_headers` should be the empty string when LIBCXXABI_LIBUNWIND_INCLUDE_INTERNAL has not been found, instead of expanding to "LIBCXXABI_LIBUNWIND_INCLUDE_INTERNAL-NOTFOUND" Comment at: test/test_exception_address_alignment.pass.cpp:30 +// Itanium: Largest supported alignment for the system +#if _LIBUNWIND_ARM_EHABI +# define EXPECTED_ALIGNMENT 8 Shouldn't this be an `#ifdef`? https://reviews.llvm.org/D31178 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31272: Do not pass an explicit reexported symbol list when building libc++ dylib if also defining new/delete
EricWF added a comment. I'm a bit confused by the description of this change. Libc++ has been enabling the new/delete definitions in its dylib since forever and I've never experienced a link error. Did you mean to say the link error occurs only when libc++abi doesn't define them? https://reviews.llvm.org/D31272 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28462: clang-format: Add new style option AlignConsecutiveMacros
enyquist marked 8 inline comments as done. enyquist added inline comments. Comment at: lib/Format/WhitespaceManager.cpp:287 SmallVector &Changes, +bool ConsiderScope, bool ConsiderCommas, unsigned StartAt) { djasper wrote: > I don't find it intuitive what "consider" means in this case. Can you add a > comment? Are the two parameters ever set independently? If not, I'd prefer to > keep one parameter for now as we have test coverage only for that. Currently, they are never set independently, no. I will combine them and add an explanatory comment. Comment at: lib/Format/WhitespaceManager.cpp:413 + + while (Param && !Param->is(tok::l_paren)) { +if (!Param->is(tok::identifier) && !Param->is(tok::comma)) djasper wrote: > I think you should be able to use Current.MatchingParen here. Hmm, I couldn't make this work... I just replaced this line with while (Param && Param != Current->MatchingParen) But it must not be doing what I think it's doing, since it made some tests fail. Mind you, my C-brain might be taking over here, please let me know if I'm using MatchingParen incorrectly Comment at: unittests/Format/FormatTest.cpp:7733 - verifyFormat("auto lambda = []() {\n" + verifyFormat("#define a 5\n" + "#define foo(x, y) (x + y)\n" djasper wrote: > Why this change? This seems to be tested above. I wanted to ensure this option didn't break other alignment options while I was developing-- this is a remnant. I will remove it. Comment at: unittests/Format/FormatTest.cpp:8010 Alignment.AlignConsecutiveAssignments = true; - verifyFormat("auto lambda = []() {\n" + verifyFormat("#define a 5\n" + "#define foo(x, y) (x + y)\n" djasper wrote: > Same here? Yes. Repository: rL LLVM https://reviews.llvm.org/D28462 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30268: Avoid copy of __atoms when char_type is char
EricWF added a comment. OK, so ABI wise this seems good. I'll need a fresh head to review the locale changes for correctness. I'll get around to that tomorrow. Comment at: libcxx/include/locale:891 +#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE // signed Would it be possible to reduce the amount of duplicate code between the two implementations? Currently it seems like there is a lot. https://reviews.llvm.org/D30268 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28462: clang-format: Add new style option AlignConsecutiveMacros
enyquist updated this revision to Diff 93204. enyquist marked 3 inline comments as done. enyquist added a comment. Addressed all comments, except for the one about FormatToken.MatchingParen (see reply comment) https://reviews.llvm.org/D28462 Files: docs/ClangFormatStyleOptions.rst include/clang/Format/Format.h lib/Format/Format.cpp lib/Format/WhitespaceManager.cpp lib/Format/WhitespaceManager.h unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -7518,8 +7518,104 @@ verifyFormat("a or_eq 8;", Spaces); } +TEST_F(FormatTest, AlignConsecutiveMacros) { + FormatStyle Style = getLLVMStyle(); + Style.AlignConsecutiveAssignments = true; + Style.AlignConsecutiveDeclarations = true; + Style.AlignConsecutiveMacros = false; + + verifyFormat("#define a 3\n" + "#define 4\n" + "#define ccc (5)", + Style); + + verifyFormat("#define f(x) (x * x)\n" + "#define fff(x, y, z) (x * y + z)\n" + "#define (x, y) (x - y)", + Style); + + verifyFormat("#define foo(x, y) (x + y)\n" + "#define bar (5, 6)(2 + 2)", + Style); + + verifyFormat("#define a 3\n" + "#define 4\n" + "#define ccc (5)\n" + "#define f(x) (x * x)\n" + "#define fff(x, y, z) (x * y + z)\n" + "#define (x, y) (x - y)", + Style); + + Style.AlignConsecutiveMacros = true; + verifyFormat("#define a3\n" + "#define 4\n" + "#define ccc (5)", + Style); + + verifyFormat("#define f(x) (x * x)\n" + "#define fff(x, y, z) (x * y + z)\n" + "#define (x, y) (x - y)", + Style); + + verifyFormat("#define foo(x, y) (x + y)\n" + "#define bar (5, 6)(2 + 2)", + Style); + + verifyFormat("#define a3\n" + "#define 4\n" + "#define ccc (5)\n" + "#define f(x) (x * x)\n" + "#define fff(x, y, z) (x * y + z)\n" + "#define (x, y) (x - y)", + Style); + + verifyFormat("#define a 5\n" + "#define foo(x, y) (x + y)\n" + "#define CCC (6)\n" + "auto lambda = []() {\n" + " auto ii = 0;\n" + " float j = 0;\n" + " return 0;\n" + "};\n" + "int i = 0;\n" + "float i2 = 0;\n" + "auto v = type{\n" + "i = 1, //\n" + "(i = 2), //\n" + "i = 3//\n" + "};", + Style); + + Style.AlignConsecutiveMacros = false; + Style.ColumnLimit = 20; + + verifyFormat("#define a \\\n" + " \"aa\"\n" + "#define D \\\n" + " \"aa\" \\\n" + " \"ccdde\"\n" + "#define B \\\n" + " \"Q\" \\\n" + " \"F\" \\\n" + " \"\"\n", + Style); + + Style.AlignConsecutiveMacros = true; + verifyFormat("#define a \\\n" + " \"aa\"\n" + "#define D \\\n" + " \"aa\" \\\n" + " \"ccdde\"\n" + "#define B \\\n" + " \"Q\" \\\n" + " \"F\" \\\n" + " \"\"\n", + Style); +} + TEST_F(FormatTest, AlignConsecutiveAssignments) { FormatStyle Alignment = getLLVMStyle(); + Alignment.AlignConsecutiveMacros = true; Alignment.AlignConsecutiveAssignments = false; verifyFormat("int a = 5;\n" "int oneTwoThree = 123;", @@ -7702,6 +7798,7 @@ TEST_F(FormatTest, AlignConsecutiveDeclarations) { FormatStyle Alignment = getLLVMStyle(); + Alignment.AlignConsecutiveMacros = true; Alignment.AlignConsecutiveDeclarations = false; verifyFormat("float const a = 5;\n" "int oneTwoThree = 123;", @@ -8659,6 +8756,7 @@ CHECK_PARSE_BOOL(AlignEscapedNewlinesLeft); CHECK_PARSE_BOOL(AlignOperands); CHECK_PARSE_BOOL(AlignTrailingComments); + CHECK_PARSE_BOOL(AlignConsecutiveMacros); CHECK_PARSE_BOOL(AlignConsecutiveAssignments); CHECK_PARSE_BOOL(AlignConsecutiveDeclarations); CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine); Index: lib/Format/WhitespaceManager.h === --- lib/Format/WhitespaceManager.h +++ lib/Format/WhitespaceManager.h @@ -165,6 +165,9 @@ /// \c EscapedNewlineColumn for the first
[PATCH] D31413: [libc++] Use __attribute__((init_priority(101))) to ensure streams get initialized early
EricWF created this revision. This patch fixes http://llvm.org/PR28954 using the `init_priority` attribute. All supported compilers accept this attribute, including clang-cl. I'm only putting this up for review because IDK how to write a test for it. Can anybody suggest a way to test this? https://reviews.llvm.org/D31413 Files: src/iostream.cpp Index: src/iostream.cpp === --- src/iostream.cpp +++ src/iostream.cpp @@ -73,7 +73,7 @@ #endif ; -ios_base::Init __start_std_streams; +ios_base::Init __start_std_streams __attribute__((init_priority(101))); ios_base::Init::Init() { Index: src/iostream.cpp === --- src/iostream.cpp +++ src/iostream.cpp @@ -73,7 +73,7 @@ #endif ; -ios_base::Init __start_std_streams; +ios_base::Init __start_std_streams __attribute__((init_priority(101))); ios_base::Init::Init() { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r298893 - Use BuildReturnStmt in SemaCoroutine to unbreak sanitizer tests.
Author: gornishanov Date: Mon Mar 27 21:51:45 2017 New Revision: 298893 URL: http://llvm.org/viewvc/llvm-project?rev=298893&view=rev Log: Use BuildReturnStmt in SemaCoroutine to unbreak sanitizer tests. FIXME: ActOnReturnStmt expects a scope that is inside of the function, due to CheckJumpOutOfSEHFinally(*this, ReturnLoc, *CurScope->getFnParent()); S.getCurScope()->getFnParent() == nullptr at ActOnFinishFunctionBody when CoroutineBodyStmt is built. Figure it out and fix it. Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=298893&r1=298892&r2=298893&view=diff == --- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original) +++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Mon Mar 27 21:51:45 2017 @@ -830,8 +830,13 @@ bool SubStmtBuilder::makeReturnOnAllocFa S.ActOnCallExpr(nullptr, DeclNameExpr.get(), Loc, {}, Loc); if (ReturnObjectOnAllocationFailure.isInvalid()) return false; - StmtResult ReturnStmt = S.ActOnReturnStmt( - Loc, ReturnObjectOnAllocationFailure.get(), S.getCurScope()); + // FIXME: ActOnReturnStmt expects a scope that is inside of the function, due + // to CheckJumpOutOfSEHFinally(*this, ReturnLoc, *CurScope->getFnParent()); + // S.getCurScope()->getFnParent() == nullptr at ActOnFinishFunctionBody when + // CoroutineBodyStmt is built. Figure it out and fix it. + // Use BuildReturnStmt here to unbreak sanitized tests. (Gor:3/27/2017) + StmtResult ReturnStmt = + S.BuildReturnStmt(Loc, ReturnObjectOnAllocationFailure.get()); if (ReturnStmt.isInvalid()) return false; this->ReturnStmtOnAllocFailure = ReturnStmt.get(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29930: Add `__reference_binds_to_temporary` trait for checking safe reference initialization.
EricWF added a comment. @rsmith gentle ping. https://reviews.llvm.org/D29930 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31078: [libunwind] Clean up macro usage.
EricWF accepted this revision. EricWF added a comment. This revision is now accepted and ready to land. LGTM minus the suggested cleanup. Comment at: include/__libunwind_config.h:15 !defined(__ARM_DWARF_EH__) #define _LIBUNWIND_ARM_EHABI 1 #endif This should have an empty definition to avoid people depending on the value `1`. Comment at: include/__libunwind_config.h:20 # if defined(__i386__) # define _LIBUNWIND_TARGET_I386 1 # define _LIBUNWIND_CONTEXT_SIZE 8 This should have an empty definition to avoid people depending on the value `1`. Comment at: src/config.h:35 #if defined(FOR_DYLD) #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 1 #else This should have an empty definition to avoid people depending on the value `1`. Comment at: src/config.h:52 #if (defined(__APPLE__) && defined(__arm__)) || defined(__USING_SJLJ_EXCEPTIONS__) #define _LIBUNWIND_BUILD_SJLJ_APIS 1 #endif This should have an empty definition to avoid people depending on the value `1`. Comment at: src/config.h:56 #if defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || defined(__ppc64__) #define _LIBUNWIND_SUPPORT_FRAME_APIS 1 #endif This should have an empty definition to avoid people depending on the value `1`. Comment at: src/config.h:64 (defined(__APPLE__) && defined(__mips__)) #define _LIBUNWIND_BUILD_ZERO_COST_APIS 1 #endif This should have an empty definition to avoid people depending on the value `1`. https://reviews.llvm.org/D31078 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31375: Add docs for libunwind
EricWF accepted this revision. EricWF added a comment. This revision is now accepted and ready to land. This LGTM. We should also get a bot setup to build it. https://reviews.llvm.org/D31375 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31375: Add docs for libunwind
EricWF added a comment. In https://reviews.llvm.org/D31375#710897, @jroelofs wrote: > In https://reviews.llvm.org/D31375#710891, @compnerd wrote: > > > What happens when you try building it in tree? > > > The docs-libunwind-html target is missing, and the docs don't get built. Shouldn't that be what happens when libunwind is built "out-of-tree"/standalone, not the other way around? https://reviews.llvm.org/D31375 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31414: [NFC, Refactor] Modernize TemplateIdAnnotation using TrailingObjects
faisalv created this revision. faisalv added a project: clang-c. Refactor TemplateIdAnnotation to use TrailingObjects and add assorted comments. Repository: rL LLVM https://reviews.llvm.org/D31414 Files: include/clang/Basic/TemplateKinds.h include/clang/Sema/ParsedTemplate.h lib/Parse/ParseExprCXX.cpp lib/Parse/ParseTemplate.cpp Index: lib/Parse/ParseTemplate.cpp === --- lib/Parse/ParseTemplate.cpp +++ lib/Parse/ParseTemplate.cpp @@ -1023,25 +1023,21 @@ // Build a template-id annotation token that can be processed // later. Tok.setKind(tok::annot_template_id); -TemplateIdAnnotation *TemplateId - = TemplateIdAnnotation::Allocate(TemplateArgs.size(), TemplateIds); -TemplateId->TemplateNameLoc = TemplateNameLoc; -if (TemplateName.getKind() == UnqualifiedId::IK_Identifier) { - TemplateId->Name = TemplateName.Identifier; - TemplateId->Operator = OO_None; -} else { - TemplateId->Name = nullptr; - TemplateId->Operator = TemplateName.OperatorFunctionId.Operator; -} -TemplateId->SS = SS; -TemplateId->TemplateKWLoc = TemplateKWLoc; -TemplateId->Template = Template; -TemplateId->Kind = TNK; -TemplateId->LAngleLoc = LAngleLoc; -TemplateId->RAngleLoc = RAngleLoc; -ParsedTemplateArgument *Args = TemplateId->getTemplateArgs(); -for (unsigned Arg = 0, ArgEnd = TemplateArgs.size(); Arg != ArgEnd; ++Arg) - Args[Arg] = ParsedTemplateArgument(TemplateArgs[Arg]); + +IdentifierInfo *TemplateII = +TemplateName.getKind() == UnqualifiedId::IK_Identifier +? TemplateName.Identifier +: nullptr; + +OverloadedOperatorKind OpKind = +TemplateName.getKind() == UnqualifiedId::IK_Identifier +? OO_None +: TemplateName.OperatorFunctionId.Operator; + +TemplateIdAnnotation *TemplateId = TemplateIdAnnotation::Create( + SS, TemplateKWLoc, TemplateNameLoc, TemplateII, OpKind, Template, TNK, + LAngleLoc, RAngleLoc, TemplateArgs, TemplateIds); + Tok.setAnnotationValue(TemplateId); if (TemplateKWLoc.isValid()) Tok.setLocation(TemplateKWLoc); Index: lib/Parse/ParseExprCXX.cpp === --- lib/Parse/ParseExprCXX.cpp +++ lib/Parse/ParseExprCXX.cpp @@ -2124,31 +2124,18 @@ Id.getKind() == UnqualifiedId::IK_LiteralOperatorId) { // Form a parsed representation of the template-id to be stored in the // UnqualifiedId. -TemplateIdAnnotation *TemplateId - = TemplateIdAnnotation::Allocate(TemplateArgs.size(), TemplateIds); // FIXME: Store name for literal operator too. -if (Id.getKind() == UnqualifiedId::IK_Identifier) { - TemplateId->Name = Id.Identifier; - TemplateId->Operator = OO_None; - TemplateId->TemplateNameLoc = Id.StartLocation; -} else { - TemplateId->Name = nullptr; - TemplateId->Operator = Id.OperatorFunctionId.Operator; - TemplateId->TemplateNameLoc = Id.StartLocation; -} +IdentifierInfo *TemplateII = +Id.getKind() == UnqualifiedId::IK_Identifier ? Id.Identifier : nullptr; +OverloadedOperatorKind OpKind = Id.getKind() == UnqualifiedId::IK_Identifier +? OO_None +: Id.OperatorFunctionId.Operator; -TemplateId->SS = SS; -TemplateId->TemplateKWLoc = TemplateKWLoc; -TemplateId->Template = Template; -TemplateId->Kind = TNK; -TemplateId->LAngleLoc = LAngleLoc; -TemplateId->RAngleLoc = RAngleLoc; -ParsedTemplateArgument *Args = TemplateId->getTemplateArgs(); -for (unsigned Arg = 0, ArgEnd = TemplateArgs.size(); - Arg != ArgEnd; ++Arg) - Args[Arg] = TemplateArgs[Arg]; - +TemplateIdAnnotation *TemplateId = TemplateIdAnnotation::Create( +SS, TemplateKWLoc, Id.StartLocation, TemplateII, OpKind, Template, TNK, +LAngleLoc, RAngleLoc, TemplateArgs, TemplateIds); + Id.setTemplateId(TemplateId); return false; } Index: include/clang/Sema/ParsedTemplate.h === --- include/clang/Sema/ParsedTemplate.h +++ include/clang/Sema/ParsedTemplate.h @@ -145,12 +145,15 @@ /// expressions, or template names, and the source locations for important /// tokens. All of the information about template arguments is allocated /// directly after this structure. - struct TemplateIdAnnotation { + struct TemplateIdAnnotation final + : private llvm::TrailingObjects { +friend TrailingObjects; /// \brief The nested-name-specifier that precedes the template name. CXXScopeSpec SS; -/// TemplateKWLoc - The location of the template keyword within the -/// source. +/// TemplateKWLoc - The location of the template keyword. +/// For e.g. typename T::template Y SourceLocation TemplateKWLoc;
[PATCH] D31414: [NFC, Refactor] Modernize TemplateIdAnnotation using TrailingObjects
faisalv updated this revision to Diff 93207. faisalv added a comment. Don't forget to destroy the trailing objects. https://reviews.llvm.org/D31414 Files: include/clang/Basic/TemplateKinds.h include/clang/Sema/ParsedTemplate.h lib/Parse/ParseExprCXX.cpp lib/Parse/ParseTemplate.cpp Index: lib/Parse/ParseTemplate.cpp === --- lib/Parse/ParseTemplate.cpp +++ lib/Parse/ParseTemplate.cpp @@ -1023,25 +1023,21 @@ // Build a template-id annotation token that can be processed // later. Tok.setKind(tok::annot_template_id); -TemplateIdAnnotation *TemplateId - = TemplateIdAnnotation::Allocate(TemplateArgs.size(), TemplateIds); -TemplateId->TemplateNameLoc = TemplateNameLoc; -if (TemplateName.getKind() == UnqualifiedId::IK_Identifier) { - TemplateId->Name = TemplateName.Identifier; - TemplateId->Operator = OO_None; -} else { - TemplateId->Name = nullptr; - TemplateId->Operator = TemplateName.OperatorFunctionId.Operator; -} -TemplateId->SS = SS; -TemplateId->TemplateKWLoc = TemplateKWLoc; -TemplateId->Template = Template; -TemplateId->Kind = TNK; -TemplateId->LAngleLoc = LAngleLoc; -TemplateId->RAngleLoc = RAngleLoc; -ParsedTemplateArgument *Args = TemplateId->getTemplateArgs(); -for (unsigned Arg = 0, ArgEnd = TemplateArgs.size(); Arg != ArgEnd; ++Arg) - Args[Arg] = ParsedTemplateArgument(TemplateArgs[Arg]); + +IdentifierInfo *TemplateII = +TemplateName.getKind() == UnqualifiedId::IK_Identifier +? TemplateName.Identifier +: nullptr; + +OverloadedOperatorKind OpKind = +TemplateName.getKind() == UnqualifiedId::IK_Identifier +? OO_None +: TemplateName.OperatorFunctionId.Operator; + +TemplateIdAnnotation *TemplateId = TemplateIdAnnotation::Create( + SS, TemplateKWLoc, TemplateNameLoc, TemplateII, OpKind, Template, TNK, + LAngleLoc, RAngleLoc, TemplateArgs, TemplateIds); + Tok.setAnnotationValue(TemplateId); if (TemplateKWLoc.isValid()) Tok.setLocation(TemplateKWLoc); Index: lib/Parse/ParseExprCXX.cpp === --- lib/Parse/ParseExprCXX.cpp +++ lib/Parse/ParseExprCXX.cpp @@ -2124,31 +2124,18 @@ Id.getKind() == UnqualifiedId::IK_LiteralOperatorId) { // Form a parsed representation of the template-id to be stored in the // UnqualifiedId. -TemplateIdAnnotation *TemplateId - = TemplateIdAnnotation::Allocate(TemplateArgs.size(), TemplateIds); // FIXME: Store name for literal operator too. -if (Id.getKind() == UnqualifiedId::IK_Identifier) { - TemplateId->Name = Id.Identifier; - TemplateId->Operator = OO_None; - TemplateId->TemplateNameLoc = Id.StartLocation; -} else { - TemplateId->Name = nullptr; - TemplateId->Operator = Id.OperatorFunctionId.Operator; - TemplateId->TemplateNameLoc = Id.StartLocation; -} +IdentifierInfo *TemplateII = +Id.getKind() == UnqualifiedId::IK_Identifier ? Id.Identifier : nullptr; +OverloadedOperatorKind OpKind = Id.getKind() == UnqualifiedId::IK_Identifier +? OO_None +: Id.OperatorFunctionId.Operator; -TemplateId->SS = SS; -TemplateId->TemplateKWLoc = TemplateKWLoc; -TemplateId->Template = Template; -TemplateId->Kind = TNK; -TemplateId->LAngleLoc = LAngleLoc; -TemplateId->RAngleLoc = RAngleLoc; -ParsedTemplateArgument *Args = TemplateId->getTemplateArgs(); -for (unsigned Arg = 0, ArgEnd = TemplateArgs.size(); - Arg != ArgEnd; ++Arg) - Args[Arg] = TemplateArgs[Arg]; - +TemplateIdAnnotation *TemplateId = TemplateIdAnnotation::Create( +SS, TemplateKWLoc, Id.StartLocation, TemplateII, OpKind, Template, TNK, +LAngleLoc, RAngleLoc, TemplateArgs, TemplateIds); + Id.setTemplateId(TemplateId); return false; } Index: include/clang/Sema/ParsedTemplate.h === --- include/clang/Sema/ParsedTemplate.h +++ include/clang/Sema/ParsedTemplate.h @@ -145,12 +145,15 @@ /// expressions, or template names, and the source locations for important /// tokens. All of the information about template arguments is allocated /// directly after this structure. - struct TemplateIdAnnotation { + struct TemplateIdAnnotation final + : private llvm::TrailingObjects { +friend TrailingObjects; /// \brief The nested-name-specifier that precedes the template name. CXXScopeSpec SS; -/// TemplateKWLoc - The location of the template keyword within the -/// source. +/// TemplateKWLoc - The location of the template keyword. +/// For e.g. typename T::template Y SourceLocation TemplateKWLoc; /// TemplateNameLoc - The location of the template
[PATCH] D31399: [coroutines] Handle get_return_object_on_allocation_failure
EricWF added a comment. Woops. this patch also needed changes to `TreeTransform.h`. I'll add those tonight. Repository: rL LLVM https://reviews.llvm.org/D31399 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31272: Do not pass an explicit reexported symbol list when building libc++ dylib if also defining new/delete
mehdi_amini added a comment. In https://reviews.llvm.org/D31272#711804, @EricWF wrote: > I'm a bit confused by the description of this change. Libc++ has been > enabling the new/delete definitions in its dylib since forever and I've never > experienced a link error. Did you mean to say the link error occurs only when > libc++abi doesn't define them? Most people have the "command line tools" package installed on macOS, and it means that you're taking this condition: `if (DEFINED CMAKE_OSX_SYSROOT AND NOT CMAKE_OSX_SYSROOT STREQUAL "")` which leads you to: `-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib` While the GreenDragon bots don't have the command line tools, so CMAKE_OSX_SYSROOT is defined by cmake and then this is used instead: `set(OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")` https://reviews.llvm.org/D31272 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31272: Do not pass an explicit reexported symbol list when building libc++ dylib if also defining new/delete
mehdi_amini added a comment. Not that I'm claiming to understand why we're changing strategy when we have the command line tools installed or not in this case ;) (CC @beanz if he know by any chance!) https://reviews.llvm.org/D31272 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31272: Do not pass an explicit reexported symbol list when building libc++ dylib if also defining new/delete
EricWF added a comment. In https://reviews.llvm.org/D31272#711860, @mehdi_amini wrote: > In https://reviews.llvm.org/D31272#711804, @EricWF wrote: > > > I'm a bit confused by the description of this change. Libc++ has been > > enabling the new/delete definitions in its dylib since forever and I've > > never experienced a link error. Did you mean to say the link error occurs > > only when libc++abi doesn't define them? > > > Most people have the "command line tools" package installed on macOS, and it > means that you're taking this condition: > > `if (DEFINED CMAKE_OSX_SYSROOT AND NOT CMAKE_OSX_SYSROOT STREQUAL "")` > > which leads you to: > > `-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib` > > While the GreenDragon bots don't have the command line tools, so > CMAKE_OSX_SYSROOT is defined by cmake and then this is used instead: > > `set(OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib > -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")` I think you have that reversed. I have command line tools installed and `CMAKE_OSX_SYSROOT` isn't defined. Therefore the `else()` branch is taken and libc++abi is exported via the ABI list. https://reviews.llvm.org/D31272 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27387: [libc++] Add a key function for bad_function_call
EricWF accepted this revision. EricWF added a comment. This revision is now accepted and ready to land. This LGTM, but I have a question: Should we add these dylib definitions right away so that it's easier to adopt the ABI change in future? This will allow legacy dylibs to support this ABI change in future. If you agree we can make that change as a follow up commit. https://reviews.llvm.org/D27387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26830: [libcxx] Add string_view literals
EricWF added a comment. @AntonBikineev when will you be able to make he requested changes? I would like to land this ASAP. https://reviews.llvm.org/D26830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24371: Add diagnostics to require_constant_initialization
EricWF added a comment. @rsmith ping. Repository: rL LLVM https://reviews.llvm.org/D24371 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D11781: Refactored pthread usage in libcxx
EricWF resigned from this revision. EricWF added a comment. This revision is no longer relevant after. The `__threading_support` changes have applied changes similar to this. Repository: rL LLVM https://reviews.llvm.org/D11781 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits