Re: r338165 - [Sema] Use a TreeTransform to extract deduction guide parameter types
Thank you Erik! Thanks Galina On Fri, Jul 27, 2018 at 7:35 PM, Erik Pilkington wrote: > Okay, the bot can now compile this file, but it looks like somebody else > broke it again in the meantime... > > > FAIL: LLVM :: CodeGen/AArch64/arm64-opt-remarks-lazy-bfi.ll (17518 of 39837) > TEST 'LLVM :: > CodeGen/AArch64/arm64-opt-remarks-lazy-bfi.ll' FAILED > Script: > -- > : 'RUN: at line 1'; > C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\build\bin\llc.EXE < > C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\test\CodeGen\AArch64\arm64-opt-remarks-lazy-bfi.ll > -mtriple=arm64-apple-ios7.0 -pass-remarks-analysis=asm-printer > -pass-remarks-with-hotness=1 -asm-verbose=0 > -debug-only=lazy-machine-block-freq,block-freq-debug-pass=Executions > 2>&1 | > C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\build\bin\FileCheck.EXE > > C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\test\CodeGen\AArch64\arm64-opt-remarks-lazy-bfi.ll > -check-prefix=HOTNESS > : 'RUN: at line 6'; > C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\build\bin\llc.EXE < > C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\test\CodeGen\AArch64\arm64-opt-remarks-lazy-bfi.ll > -mtriple=arm64-apple-ios7.0 -pass-remarks-analysis=asm-printer > -pass-remarks-with-hotness=0 -asm-verbose=0 > -debug-only=lazy-machine-block-freq,block-freq-debug-pass=Executions > 2>&1 | > C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\build\bin\FileCheck.EXE > > C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\test\CodeGen\AArch64\arm64-opt-remarks-lazy-bfi.ll > -check-prefix=NO_HOTNESS > -- > Exit Code: 1 > > Command Output (stdout): > -- > $ ":" "RUN: at line 1" > $ > "C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\build\bin\llc.EXE" > "-mtriple=arm64-apple-ios7.0" "-pass-remarks-analysis=asm-printer" > "-pass-remarks-with-hotness=1" "-asm-verbose=0" > "-debug-only=lazy-machine-block-freq,block-freq" "-debug-pass=Executions" > $ > "C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\build\bin\FileCheck.EXE" > > "C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\test\CodeGen\AArch64\arm64-opt-remarks-lazy-bfi.ll" > "-check-prefix=HOTNESS" > # command stderr: > C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\test\CodeGen\AArch64\arm64-opt-remarks-lazy-bfi.ll:31:17: > error: HOTNESS-NEXT: is not on the line after the previous match > > ; HOTNESS-NEXT: Executing Pass 'Lazy Machine Block Frequency Analysis' > > ^ > > :698:47: note: 'next' match was here > > [2018-07-27 19:10:50.080587200] 0x1d4105a1760 Executing Pass 'Lazy Machine > Block Frequency Analysis' on Function 'empty_func'... > > ^ > > :695:85: note: previous match ended here > > [2018-07-27 19:10:50.079779100] 0x1d410527f90 Executing Pass 'Function Pass > Manager' on Module ''... > > > ^ > > :696:1: note: non-matching line after previous match is here > > [2018-07-27 19:10:50.079879300] 0x1d4105a1760 Executing Pass 'Verify > generated machine code' on Function 'empty_func'... > > ^ > > > error: command failed with exit status: 1 > > -- > > > On 2018-07-27 6:30 PM, Erik Pilkington wrote: > > This should be fixed by r338186. I'll keep an eye on this bot to make sure > that this is the case. > Thanks! > Erik > > On 2018-07-27 5:46 PM, Galina Kistanova wrote: > > C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\ > llvm\tools\clang\lib\Sema\SemaTemplate.cpp : fatal error C1128: number of > sections exceeded object file format limit: compile with /bigobj > > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49119: [Sema][ObjC] Issue a warning when a method declared in a protocol is non-escaping but the corresponding method in the implementation is escaping.
This revision was automatically updated to reflect the committed changes. Closed by commit rC338189: [Sema][ObjC] Warn when a method declared in a protocol takes a (authored by ahatanak, committed by ). Repository: rC Clang https://reviews.llvm.org/D49119 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDeclObjC.cpp test/SemaObjCXX/noescape.mm Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -1733,6 +1733,8 @@ "__attribute__((noescape))">, InGroup; def note_overridden_marked_noescape : Note< "parameter of overridden method is annotated with __attribute__((noescape))">; +def note_cat_conform_to_noescape_prot : Note< + "%select{category|class extension}0 conforms to protocol %1 which defines method %2">; def err_covariant_return_inaccessible_base : Error< "invalid covariant return for virtual function: %1 is a " Index: test/SemaObjCXX/noescape.mm === --- test/SemaObjCXX/noescape.mm +++ test/SemaObjCXX/noescape.mm @@ -88,3 +88,42 @@ S5<> ne1; } + +@protocol NoescapeProt +-(void) m0:(int*)__attribute__((noescape)) p; // expected-note 2 {{parameter of overridden method is annotated with __attribute__((noescape))}} ++(void) m1:(int*)__attribute__((noescape)) p; +-(void) m1:(int*) p; +@end + +__attribute__((objc_root_class)) +@interface C3 +-(void) m0:(int*) p; ++(void) m1:(int*)__attribute__((noescape)) p; +-(void) m1:(int*) p; +@end + +@interface C3 () // expected-note {{class extension conforms to protocol 'NoescapeProt' which defines method 'm0:'}} +@end + +@implementation C3 +-(void) m0:(int*) p { // expected-warning {{parameter of overriding method should be annotated with __attribute__((noescape))}} +} ++(void) m1:(int*)__attribute__((noescape)) p { +} +-(void) m1:(int*) p { +} +@end + +__attribute__((objc_root_class)) +@interface C4 +-(void) m0:(int*) p; // expected-warning {{parameter of overriding method should be annotated with __attribute__((noescape))}} +@end + +@implementation C4 +-(void) m0:(int*) p { +} ++(void) m1:(int*)__attribute__((noescape)) p { +} +-(void) m1:(int*) p { +} +@end Index: lib/Sema/SemaDeclObjC.cpp === --- lib/Sema/SemaDeclObjC.cpp +++ lib/Sema/SemaDeclObjC.cpp @@ -109,6 +109,30 @@ return true; } +/// Issue a warning if the parameter of the overridden method is non-escaping +/// but the parameter of the overriding method is not. +static bool diagnoseNoescape(const ParmVarDecl *NewD, const ParmVarDecl *OldD, + Sema ) { + if (OldD->hasAttr() && !NewD->hasAttr()) { +S.Diag(NewD->getLocation(), diag::warn_overriding_method_missing_noescape); +S.Diag(OldD->getLocation(), diag::note_overridden_marked_noescape); +return false; + } + + return true; +} + +/// Produce additional diagnostics if a category conforms to a protocol that +/// defines a method taking a non-escaping parameter. +static void diagnoseNoescape(const ParmVarDecl *NewD, const ParmVarDecl *OldD, + const ObjCCategoryDecl *CD, + const ObjCProtocolDecl *PD, Sema ) { + if (!diagnoseNoescape(NewD, OldD, S)) +S.Diag(CD->getLocation(), diag::note_cat_conform_to_noescape_prot) +<< CD->IsClassExtension() << PD +<< cast(NewD->getDeclContext()); +} + void Sema::CheckObjCMethodOverride(ObjCMethodDecl *NewMethod, const ObjCMethodDecl *Overridden) { if (Overridden->hasRelatedResultType() && @@ -192,13 +216,7 @@ Diag(oldDecl->getLocation(), diag::note_previous_decl) << "parameter"; } -// A parameter of the overriding method should be annotated with noescape -// if the corresponding parameter of the overridden method is annotated. -if (oldDecl->hasAttr() && !newDecl->hasAttr()) { - Diag(newDecl->getLocation(), - diag::warn_overriding_method_missing_noescape); - Diag(oldDecl->getLocation(), diag::note_overridden_marked_noescape); -} +diagnoseNoescape(newDecl, oldDecl, *this); } } @@ -4643,6 +4661,22 @@ << ObjCMethod->getDeclName(); } } + + // Warn if a method declared in a protocol to which a category or + // extension conforms is non-escaping and the implementation's method is + // escaping. + for (auto *C : IDecl->visible_categories()) +for (auto : C->protocols()) + if (auto *IMD = P->lookupMethod(ObjCMethod->getSelector(), + ObjCMethod->isInstanceMethod())) { +assert(ObjCMethod->parameters().size() == + IMD->parameters().size() && + "Methods have different number of parameters"); +auto OI =
[libcxxabi] r338190 - [demangler] Fix an oss-fuzz bug from r338138
Author: epilk Date: Fri Jul 27 21:06:30 2018 New Revision: 338190 URL: http://llvm.org/viewvc/llvm-project?rev=338190=rev Log: [demangler] Fix an oss-fuzz bug from r338138 Stack overflow on invalid. While collapsing references, we were skipping over a cycle check in ForwardTemplateReference leading to a stack overflow. This commit fixes the problem by duplicating the cycle check in ReferenceType. Modified: libcxxabi/trunk/src/cxa_demangle.cpp Modified: libcxxabi/trunk/src/cxa_demangle.cpp URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=338190=338189=338190=diff == --- libcxxabi/trunk/src/cxa_demangle.cpp (original) +++ libcxxabi/trunk/src/cxa_demangle.cpp Fri Jul 27 21:06:30 2018 @@ -461,6 +461,8 @@ class ReferenceType : public Node { const Node *Pointee; ReferenceKind RK; + mutable bool Printing = false; + // Dig through any refs to refs, collapsing the ReferenceTypes as we go. The // rule here is rvalue ref to rvalue ref collapses to a rvalue ref, and any // other combination collapses to a lvalue ref. @@ -487,6 +489,9 @@ public: } void printLeft(OutputStream ) const override { +if (Printing) + return; +SwapAndRestore SavePrinting(Printing, true); std::pair Collapsed = collapse(s); Collapsed.second->printLeft(s); if (Collapsed.second->hasArray(s)) @@ -497,6 +502,9 @@ public: s += (Collapsed.first == ReferenceKind::LValue ? "&" : "&&"); } void printRight(OutputStream ) const override { +if (Printing) + return; +SwapAndRestore SavePrinting(Printing, true); std::pair Collapsed = collapse(s); if (Collapsed.second->hasArray(s) || Collapsed.second->hasFunction(s)) s += ")"; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338189 - [Sema][ObjC] Warn when a method declared in a protocol takes a
Author: ahatanak Date: Fri Jul 27 21:06:13 2018 New Revision: 338189 URL: http://llvm.org/viewvc/llvm-project?rev=338189=rev Log: [Sema][ObjC] Warn when a method declared in a protocol takes a non-escaping parameter but the implementation's method takes an escaping parameter. rdar://problem/39548196 Differential Revision: https://reviews.llvm.org/D49119 Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaDeclObjC.cpp cfe/trunk/test/SemaObjCXX/noescape.mm Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=338189=338188=338189=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jul 27 21:06:13 2018 @@ -1733,6 +1733,8 @@ def warn_overriding_method_missing_noesc "__attribute__((noescape))">, InGroup; def note_overridden_marked_noescape : Note< "parameter of overridden method is annotated with __attribute__((noescape))">; +def note_cat_conform_to_noescape_prot : Note< + "%select{category|class extension}0 conforms to protocol %1 which defines method %2">; def err_covariant_return_inaccessible_base : Error< "invalid covariant return for virtual function: %1 is a " Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=338189=338188=338189=diff == --- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri Jul 27 21:06:13 2018 @@ -109,6 +109,30 @@ bool Sema::checkInitMethod(ObjCMethodDec return true; } +/// Issue a warning if the parameter of the overridden method is non-escaping +/// but the parameter of the overriding method is not. +static bool diagnoseNoescape(const ParmVarDecl *NewD, const ParmVarDecl *OldD, + Sema ) { + if (OldD->hasAttr() && !NewD->hasAttr()) { +S.Diag(NewD->getLocation(), diag::warn_overriding_method_missing_noescape); +S.Diag(OldD->getLocation(), diag::note_overridden_marked_noescape); +return false; + } + + return true; +} + +/// Produce additional diagnostics if a category conforms to a protocol that +/// defines a method taking a non-escaping parameter. +static void diagnoseNoescape(const ParmVarDecl *NewD, const ParmVarDecl *OldD, + const ObjCCategoryDecl *CD, + const ObjCProtocolDecl *PD, Sema ) { + if (!diagnoseNoescape(NewD, OldD, S)) +S.Diag(CD->getLocation(), diag::note_cat_conform_to_noescape_prot) +<< CD->IsClassExtension() << PD +<< cast(NewD->getDeclContext()); +} + void Sema::CheckObjCMethodOverride(ObjCMethodDecl *NewMethod, const ObjCMethodDecl *Overridden) { if (Overridden->hasRelatedResultType() && @@ -192,13 +216,7 @@ void Sema::CheckObjCMethodOverride(ObjCM Diag(oldDecl->getLocation(), diag::note_previous_decl) << "parameter"; } -// A parameter of the overriding method should be annotated with noescape -// if the corresponding parameter of the overridden method is annotated. -if (oldDecl->hasAttr() && !newDecl->hasAttr()) { - Diag(newDecl->getLocation(), - diag::warn_overriding_method_missing_noescape); - Diag(oldDecl->getLocation(), diag::note_overridden_marked_noescape); -} +diagnoseNoescape(newDecl, oldDecl, *this); } } @@ -4643,6 +4661,22 @@ Decl *Sema::ActOnMethodDeclaration( << ObjCMethod->getDeclName(); } } + + // Warn if a method declared in a protocol to which a category or + // extension conforms is non-escaping and the implementation's method is + // escaping. + for (auto *C : IDecl->visible_categories()) +for (auto : C->protocols()) + if (auto *IMD = P->lookupMethod(ObjCMethod->getSelector(), + ObjCMethod->isInstanceMethod())) { +assert(ObjCMethod->parameters().size() == + IMD->parameters().size() && + "Methods have different number of parameters"); +auto OI = IMD->param_begin(), OE = IMD->param_end(); +auto NI = ObjCMethod->param_begin(); +for (; OI != OE; ++OI, ++NI) + diagnoseNoescape(*NI, *OI, C, P, *this); + } } } else { cast(ClassDecl)->addDecl(ObjCMethod); Modified: cfe/trunk/test/SemaObjCXX/noescape.mm URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/noescape.mm?rev=338189=338188=338189=diff == --- cfe/trunk/test/SemaObjCXX/noescape.mm (original) +++ cfe/trunk/test/SemaObjCXX/noescape.mm
[PATCH] D49930: [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL
yaxunl added a comment. LGTM. Thanks. Repository: rC Clang https://reviews.llvm.org/D49930 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49953: [compiler-rt] Add a routine to specify the mode used when creating profile dirs.
mattd created this revision. mattd added a reviewer: void. Herald added a subscriber: dberris. This patch introduces `llvm_profile_set_dir_mode` and `llvm_profile_get_dir_mode` to the compiler-rt profile API. Originally, profile data was placed into a directory that was created with a hard-coded mode value of 0755 (for non-win32 builds). In certain cases, it can be helpful to create directories with a different mode other than 0755. This patch introduces set/get routines to allow users to specify a desired mode. The default remains at 0755. https://reviews.llvm.org/D49953 Files: lib/profile/InstrProfilingUtil.c lib/profile/InstrProfilingUtil.h test/profile/instrprof-set-dir-mode.c Index: test/profile/instrprof-set-dir-mode.c === --- /dev/null +++ test/profile/instrprof-set-dir-mode.c @@ -0,0 +1,17 @@ +// RUN: %clang_pgogen -o %t %s +// RUN: %run %t + +void __llvm_profile_set_dir_mode(unsigned Mode); +unsigned __llvm_profile_get_dir_mode(void); + +int main(void) { + __llvm_profile_set_dir_mode(0777); + if (__llvm_profile_get_dir_mode() != 0777) +return -1; + + __llvm_profile_set_dir_mode(0666); + if (__llvm_profile_get_dir_mode() != 0666) +return -1; + + return 0; +} Index: lib/profile/InstrProfilingUtil.h === --- lib/profile/InstrProfilingUtil.h +++ lib/profile/InstrProfilingUtil.h @@ -16,6 +16,12 @@ /*! \brief Create a directory tree. */ void __llvm_profile_recursive_mkdir(char *Pathname); +/*! Set the mode used when creating profile directories. */ +void __llvm_profile_set_dir_mode(unsigned Mode); + +/*! Return the directory creation mode. */ +unsigned __llvm_profile_get_dir_mode(void); + int lprofLockFd(int fd); int lprofUnlockFd(int fd); Index: lib/profile/InstrProfilingUtil.c === --- lib/profile/InstrProfilingUtil.c +++ lib/profile/InstrProfilingUtil.c @@ -35,6 +35,8 @@ #include "InstrProfiling.h" #include "InstrProfilingUtil.h" +COMPILER_RT_WEAK unsigned lprofDirMode = 0755; + COMPILER_RT_VISIBILITY void __llvm_profile_recursive_mkdir(char *path) { int i; @@ -47,12 +49,19 @@ #ifdef _WIN32 _mkdir(path); #else -mkdir(path, 0755); /* Some of these will fail, ignore it. */ +/* Some of these will fail, ignore it. */ +mkdir(path, __llvm_profile_get_dir_mode()); #endif path[i] = save; } } +COMPILER_RT_VISIBILITY +void __llvm_profile_set_dir_mode(unsigned Mode) { lprofDirMode = Mode; } + +COMPILER_RT_VISIBILITY +unsigned __llvm_profile_get_dir_mode(void) { return lprofDirMode; } + #if COMPILER_RT_HAS_ATOMICS != 1 COMPILER_RT_VISIBILITY uint32_t lprofBoolCmpXchg(void **Ptr, void *OldV, void *NewV) { Index: test/profile/instrprof-set-dir-mode.c === --- /dev/null +++ test/profile/instrprof-set-dir-mode.c @@ -0,0 +1,17 @@ +// RUN: %clang_pgogen -o %t %s +// RUN: %run %t + +void __llvm_profile_set_dir_mode(unsigned Mode); +unsigned __llvm_profile_get_dir_mode(void); + +int main(void) { + __llvm_profile_set_dir_mode(0777); + if (__llvm_profile_get_dir_mode() != 0777) +return -1; + + __llvm_profile_set_dir_mode(0666); + if (__llvm_profile_get_dir_mode() != 0666) +return -1; + + return 0; +} Index: lib/profile/InstrProfilingUtil.h === --- lib/profile/InstrProfilingUtil.h +++ lib/profile/InstrProfilingUtil.h @@ -16,6 +16,12 @@ /*! \brief Create a directory tree. */ void __llvm_profile_recursive_mkdir(char *Pathname); +/*! Set the mode used when creating profile directories. */ +void __llvm_profile_set_dir_mode(unsigned Mode); + +/*! Return the directory creation mode. */ +unsigned __llvm_profile_get_dir_mode(void); + int lprofLockFd(int fd); int lprofUnlockFd(int fd); Index: lib/profile/InstrProfilingUtil.c === --- lib/profile/InstrProfilingUtil.c +++ lib/profile/InstrProfilingUtil.c @@ -35,6 +35,8 @@ #include "InstrProfiling.h" #include "InstrProfilingUtil.h" +COMPILER_RT_WEAK unsigned lprofDirMode = 0755; + COMPILER_RT_VISIBILITY void __llvm_profile_recursive_mkdir(char *path) { int i; @@ -47,12 +49,19 @@ #ifdef _WIN32 _mkdir(path); #else -mkdir(path, 0755); /* Some of these will fail, ignore it. */ +/* Some of these will fail, ignore it. */ +mkdir(path, __llvm_profile_get_dir_mode()); #endif path[i] = save; } } +COMPILER_RT_VISIBILITY +void __llvm_profile_set_dir_mode(unsigned Mode) { lprofDirMode = Mode; } + +COMPILER_RT_VISIBILITY +unsigned __llvm_profile_get_dir_mode(void) { return lprofDirMode; } + #if COMPILER_RT_HAS_ATOMICS != 1 COMPILER_RT_VISIBILITY uint32_t lprofBoolCmpXchg(void **Ptr, void *OldV, void *NewV) { ___ cfe-commits mailing
[PATCH] D49723: [OpenCL] Check for invalid kernel arguments in array types
yaxunl accepted this revision. yaxunl added a comment. LGTM. Thanks. Repository: rC Clang https://reviews.llvm.org/D49723 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338188 - [CUDA][HIP] Allow function-scope static const variable
Author: yaxunl Date: Fri Jul 27 20:05:25 2018 New Revision: 338188 URL: http://llvm.org/viewvc/llvm-project?rev=338188=rev Log: [CUDA][HIP] Allow function-scope static const variable CUDA 8.0 E.3.9.4 says: Within the body of a __device__ or __global__ function, only __shared__ variables or variables without any device memory qualifiers may be declared with static storage class. It is unclear how a function-scope non-const static variable without device memory qualifier is implemented, therefore only static const variable without device memory qualifier is allowed, which can be emitted as a global variable in constant address space. Currently clang only allows function-scope static variable with __shared__ qualifier. This patch also allows function-scope static const variable without device memory qualifier and emits it as a global variable in constant address space. Differential Revision: https://reviews.llvm.org/D49931 Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/test/CodeGenCUDA/device-var-init.cu cfe/trunk/test/SemaCUDA/device-var-init.cu Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=338188=338187=338188=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jul 27 20:05:25 2018 @@ -7129,7 +7129,8 @@ def err_shared_var_init : Error< "initialization is not supported for __shared__ variables.">; def err_device_static_local_var : Error< "within a %select{__device__|__global__|__host__|__host__ __device__}0 " -"function, only __shared__ variables may be marked 'static'">; +"function, only __shared__ variables or const variables without device " +"memory qualifier may be marked 'static'">; def err_cuda_vla : Error< "cannot use variable-length arrays in " "%select{__device__|__global__|__host__|__host__ __device__}0 functions">; Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=338188=338187=338188=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Jul 27 20:05:25 2018 @@ -3176,6 +3176,10 @@ LangAS CodeGenModule::GetGlobalVarAddres return LangAS::cuda_constant; else if (D && D->hasAttr()) return LangAS::cuda_shared; +else if (D && D->hasAttr()) + return LangAS::cuda_device; +else if (D && D->getType().isConstQualified()) + return LangAS::cuda_constant; else return LangAS::cuda_device; } Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=338188=338187=338188=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Jul 27 20:05:25 2018 @@ -11914,14 +11914,25 @@ void Sema::FinalizeDeclaration(Decl *Thi NewAttr->setInherited(true); VD->addAttr(NewAttr); } - // CUDA E.2.9.4: Within the body of a __device__ or __global__ - // function, only __shared__ variables may be declared with - // static storage class. - if (getLangOpts().CUDA && !VD->hasAttr() && - CUDADiagIfDeviceCode(VD->getLocation(), - diag::err_device_static_local_var) - << CurrentCUDATarget()) -VD->setInvalidDecl(); + // CUDA 8.0 E.3.9.4: Within the body of a __device__ or __global__ + // function, only __shared__ variables or variables without any device + // memory qualifiers may be declared with static storage class. + // Note: It is unclear how a function-scope non-const static variable + // without device memory qualifier is implemented, therefore only static + // const variable without device memory qualifier is allowed. + [&]() { +if (!getLangOpts().CUDA) + return; +if (VD->hasAttr()) + return; +if (VD->getType().isConstQualified() && +!(VD->hasAttr() || VD->hasAttr())) + return; +if (CUDADiagIfDeviceCode(VD->getLocation(), + diag::err_device_static_local_var) +<< CurrentCUDATarget()) + VD->setInvalidDecl(); + }(); } } Modified: cfe/trunk/test/CodeGenCUDA/device-var-init.cu URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/device-var-init.cu?rev=338188=338187=338188=diff == ---
[PATCH] D49931: [CUDA][HIP] Allow function-scope static const variable
This revision was automatically updated to reflect the committed changes. Closed by commit rC338188: [CUDA][HIP] Allow function-scope static const variable (authored by yaxunl, committed by ). Repository: rC Clang https://reviews.llvm.org/D49931 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/CodeGen/CodeGenModule.cpp lib/Sema/SemaDecl.cpp test/CodeGenCUDA/device-var-init.cu test/SemaCUDA/device-var-init.cu Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -7129,7 +7129,8 @@ "initialization is not supported for __shared__ variables.">; def err_device_static_local_var : Error< "within a %select{__device__|__global__|__host__|__host__ __device__}0 " -"function, only __shared__ variables may be marked 'static'">; +"function, only __shared__ variables or const variables without device " +"memory qualifier may be marked 'static'">; def err_cuda_vla : Error< "cannot use variable-length arrays in " "%select{__device__|__global__|__host__|__host__ __device__}0 functions">; Index: test/CodeGenCUDA/device-var-init.cu === --- test/CodeGenCUDA/device-var-init.cu +++ test/CodeGenCUDA/device-var-init.cu @@ -112,6 +112,9 @@ // CHECK: @_ZZ2dfvE4s_ec = internal addrspace(3) global %struct.EC undef // CHECK: @_ZZ2dfvE5s_etc = internal addrspace(3) global %struct.ETC undef +// CHECK: @_ZZ2dfvE11const_array = internal addrspace(4) constant [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5] +// CHECK: @_ZZ2dfvE9const_int = internal addrspace(4) constant i32 123 + // We should not emit global initializers for device-side variables. // CHECK-NOT: @__cxx_global_var_init @@ -234,6 +237,9 @@ static __shared__ ETC s_etc; // CHECK-NOT: call void @_ZN3ETCC1IJEEEDpT_(%struct.ETC* addrspacecast (%struct.ETC addrspace(3)* @_ZZ2dfvE5s_etc to %struct.ETC*)) + static const int const_array[] = {1, 2, 3, 4, 5}; + static const int const_int = 123; + // anchor point separating constructors and destructors df(); // CHECK: call void @_Z2dfv() Index: test/SemaCUDA/device-var-init.cu === --- test/SemaCUDA/device-var-init.cu +++ test/SemaCUDA/device-var-init.cu @@ -207,17 +207,22 @@ // expected-error@-1 {{initialization is not supported for __shared__ variables.}} static __device__ int ds; - // expected-error@-1 {{within a __device__ function, only __shared__ variables may be marked 'static'}} + // expected-error@-1 {{within a __device__ function, only __shared__ variables or const variables without device memory qualifier may be marked 'static'}} static __constant__ int dc; - // expected-error@-1 {{within a __device__ function, only __shared__ variables may be marked 'static'}} + // expected-error@-1 {{within a __device__ function, only __shared__ variables or const variables without device memory qualifier may be marked 'static'}} static int v; - // expected-error@-1 {{within a __device__ function, only __shared__ variables may be marked 'static'}} + // expected-error@-1 {{within a __device__ function, only __shared__ variables or const variables without device memory qualifier may be marked 'static'}} + static const int cv = 1; + static const __device__ int cds = 1; + // expected-error@-1 {{within a __device__ function, only __shared__ variables or const variables without device memory qualifier may be marked 'static'}} + static const __constant__ int cdc = 1; + // expected-error@-1 {{within a __device__ function, only __shared__ variables or const variables without device memory qualifier may be marked 'static'}} } __host__ __device__ void hd_sema() { static int x = 42; #ifdef __CUDA_ARCH__ - // expected-error@-2 {{within a __host__ __device__ function, only __shared__ variables may be marked 'static'}} + // expected-error@-2 {{within a __host__ __device__ function, only __shared__ variables or const variables without device memory qualifier may be marked 'static'}} #endif } Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -3176,6 +3176,10 @@ return LangAS::cuda_constant; else if (D && D->hasAttr()) return LangAS::cuda_shared; +else if (D && D->hasAttr()) + return LangAS::cuda_device; +else if (D && D->getType().isConstQualified()) + return LangAS::cuda_constant; else return LangAS::cuda_device; } Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -11914,14 +11914,25 @@ NewAttr->setInherited(true); VD->addAttr(NewAttr); } - // CUDA
[PATCH] D49952: Check for NULL Destination-Type when creating ArrayConstant
erik.pilkington added inline comments. Comment at: test/CodeGenCXX/empty-struct-init-list.cpp:1-4 +// RUN: %clang_cc1 -std=c++11 %s +// RUN: %clang_cc1 -std=c++14 %s +// RUN: %clang_cc1 -std=c++17 %s +// expected-no-diagnostics You should add -emit-llvm, or else CodeGen won't even run. Also, expected-no-diagnostics only means anything when -verify is included on the run line. Repository: rC Clang https://reviews.llvm.org/D49952 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r338165 - [Sema] Use a TreeTransform to extract deduction guide parameter types
Okay, the bot can now compile this file, but it looks like somebody else broke it again in the meantime... FAIL: LLVM :: CodeGen/AArch64/arm64-opt-remarks-lazy-bfi.ll (17518 of 39837) TEST 'LLVM :: CodeGen/AArch64/arm64-opt-remarks-lazy-bfi.ll' FAILED Script: -- : 'RUN: at line 1'; C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\build\bin\llc.EXE < C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\test\CodeGen\AArch64\arm64-opt-remarks-lazy-bfi.ll -mtriple=arm64-apple-ios7.0 -pass-remarks-analysis=asm-printer -pass-remarks-with-hotness=1 -asm-verbose=0 -debug-only=lazy-machine-block-freq,block-freq -debug-pass=Executions 2>&1 | C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\build\bin\FileCheck.EXE C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\test\CodeGen\AArch64\arm64-opt-remarks-lazy-bfi.ll -check-prefix=HOTNESS : 'RUN: at line 6'; C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\build\bin\llc.EXE < C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\test\CodeGen\AArch64\arm64-opt-remarks-lazy-bfi.ll -mtriple=arm64-apple-ios7.0 -pass-remarks-analysis=asm-printer -pass-remarks-with-hotness=0 -asm-verbose=0 -debug-only=lazy-machine-block-freq,block-freq -debug-pass=Executions 2>&1 | C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\build\bin\FileCheck.EXE C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\test\CodeGen\AArch64\arm64-opt-remarks-lazy-bfi.ll -check-prefix=NO_HOTNESS -- Exit Code: 1 Command Output (stdout): -- $ ":" "RUN: at line 1" $ "C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\build\bin\llc.EXE" "-mtriple=arm64-apple-ios7.0" "-pass-remarks-analysis=asm-printer" "-pass-remarks-with-hotness=1" "-asm-verbose=0" "-debug-only=lazy-machine-block-freq,block-freq" "-debug-pass=Executions" $ "C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\build\bin\FileCheck.EXE" "C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\test\CodeGen\AArch64\arm64-opt-remarks-lazy-bfi.ll" "-check-prefix=HOTNESS" # command stderr: C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\test\CodeGen\AArch64\arm64-opt-remarks-lazy-bfi.ll:31:17: error: HOTNESS-NEXT: is not on the line after the previous match ; HOTNESS-NEXT: Executing Pass 'Lazy Machine Block Frequency Analysis' ^ :698:47: note: 'next' match was here [2018-07-27 19:10:50.080587200] 0x1d4105a1760 Executing Pass 'Lazy Machine Block Frequency Analysis' on Function 'empty_func'... ^ :695:85: note: previous match ended here [2018-07-27 19:10:50.079779100] 0x1d410527f90 Executing Pass 'Function Pass Manager' on Module ''... ^ :696:1: note: non-matching line after previous match is here [2018-07-27 19:10:50.079879300] 0x1d4105a1760 Executing Pass 'Verify generated machine code' on Function 'empty_func'... ^ error: command failed with exit status: 1 -- On 2018-07-27 6:30 PM, Erik Pilkington wrote: This should be fixed by r338186. I'll keep an eye on this bot to make sure that this is the case. Thanks! Erik On 2018-07-27 5:46 PM, Galina Kistanova wrote: C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Sema\SemaTemplate.cpp : fatal error C1128: number of sections exceeded object file format limit: compile with /bigobj ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338187 - [AST] Add a convenient getter from QualType to RecordDecl
Author: george.karpenkov Date: Fri Jul 27 19:16:13 2018 New Revision: 338187 URL: http://llvm.org/viewvc/llvm-project?rev=338187=rev Log: [AST] Add a convenient getter from QualType to RecordDecl Differential Revision: https://reviews.llvm.org/D49951 Modified: cfe/trunk/include/clang/AST/Type.h cfe/trunk/lib/AST/Decl.cpp cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/Analysis/BodyFarm.cpp cfe/trunk/lib/CodeGen/CGExprConstant.cpp cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp Modified: cfe/trunk/include/clang/AST/Type.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=338187=338186=338187=diff == --- cfe/trunk/include/clang/AST/Type.h (original) +++ cfe/trunk/include/clang/AST/Type.h Fri Jul 27 19:16:13 2018 @@ -2017,6 +2017,9 @@ public: /// type of a class template or class template partial specialization. CXXRecordDecl *getAsCXXRecordDecl() const; + /// Retrieves the RecordDecl this type refers to. + RecordDecl *getAsRecordDecl() const; + /// Retrieves the TagDecl that this type refers to, either /// because the type is a TagType or because it is the injected-class-name /// type of a class template or class template partial specialization. Modified: cfe/trunk/lib/AST/Decl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=338187=338186=338187=diff == --- cfe/trunk/lib/AST/Decl.cpp (original) +++ cfe/trunk/lib/AST/Decl.cpp Fri Jul 27 19:16:13 2018 @@ -3149,12 +3149,9 @@ SourceRange FunctionDecl::getExceptionSp const Attr *FunctionDecl::getUnusedResultAttr() const { QualType RetType = getReturnType(); - if (RetType->isRecordType()) { -if (const auto *Ret = -dyn_cast_or_null(RetType->getAsTagDecl())) { - if (const auto *R = Ret->getAttr()) -return R; -} + if (const auto *Ret = RetType->getAsRecordDecl()) { +if (const auto *R = Ret->getAttr()) + return R; } else if (const auto *ET = RetType->getAs()) { if (const EnumDecl *ED = ET->getDecl()) { if (const auto *R = ED->getAttr()) Modified: cfe/trunk/lib/AST/Type.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=338187=338186=338187=diff == --- cfe/trunk/lib/AST/Type.cpp (original) +++ cfe/trunk/lib/AST/Type.cpp Fri Jul 27 19:16:13 2018 @@ -1628,6 +1628,10 @@ CXXRecordDecl *Type::getAsCXXRecordDecl( return dyn_cast_or_null(getAsTagDecl()); } +RecordDecl *Type::getAsRecordDecl() const { + return dyn_cast_or_null(getAsTagDecl()); +} + TagDecl *Type::getAsTagDecl() const { if (const auto *TT = getAs()) return TT->getDecl(); Modified: cfe/trunk/lib/Analysis/BodyFarm.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BodyFarm.cpp?rev=338187=338186=338187=diff == --- cfe/trunk/lib/Analysis/BodyFarm.cpp (original) +++ cfe/trunk/lib/Analysis/BodyFarm.cpp Fri Jul 27 19:16:13 2018 @@ -342,7 +342,7 @@ static Stmt *create_call_once(ASTContext // Nullable pointer, non-null iff function is a CXXRecordDecl. CXXRecordDecl *CallbackRecordDecl = CallbackType->getAsCXXRecordDecl(); QualType FlagType = Flag->getType().getNonReferenceType(); - auto *FlagRecordDecl = dyn_cast_or_null(FlagType->getAsTagDecl()); + auto *FlagRecordDecl = FlagType->getAsRecordDecl(); if (!FlagRecordDecl) { LLVM_DEBUG(llvm::dbgs() << "Flag field is not a record: " Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=338187=338186=338187=diff == --- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Fri Jul 27 19:16:13 2018 @@ -2064,8 +2064,7 @@ static llvm::Constant *EmitNullConstant( if (record->isUnion()) { if (Field->getIdentifier()) break; - if (const auto *FieldRD = - dyn_cast_or_null(Field->getType()->getAsTagDecl())) + if (const auto *FieldRD = Field->getType()->getAsRecordDecl()) if (FieldRD->findFirstNamedDataMember()) break; } Modified: cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=338187=338186=338187=diff == --- cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp (original) +++ cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp Fri Jul 27 19:16:13 2018 @@ -313,9 +313,8 @@ void CGRecordLowering::lowerUnion() { if (!SeenNamedMember) { SeenNamedMember = Field->getIdentifier(); if (!SeenNamedMember)
[PATCH] D49952: Check for NULL Destination-Type when creating ArrayConstant
rjmccall added a comment. I think the right fix here is to ensure that `DestType` is non-null at a higher level. Older branches of the compiler seem to be able to correctly emit this, probably because the initializer generated for this field ends up having type `a[0]`. Maybe we've just done some refactor that tries to optimize that but doesn't handle flexible array members correctly. Repository: rC Clang https://reviews.llvm.org/D49952 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49656: [analyzer] Add support for more pointer invalidating functions in InnerPointerChecker
xazax.hun accepted this revision. xazax.hun added a comment. This revision is now accepted and ready to land. LGTM! https://reviews.llvm.org/D49656 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r338165 - [Sema] Use a TreeTransform to extract deduction guide parameter types
This should be fixed by r338186. I'll keep an eye on this bot to make sure that this is the case. Thanks! Erik On 2018-07-27 5:46 PM, Galina Kistanova wrote: C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Sema\SemaTemplate.cpp : fatal error C1128: number of sections exceeded object file format limit: compile with /bigobj ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338186 - Compile SemaTemplate.cpp with /bigobj on MSVC
Author: epilk Date: Fri Jul 27 18:29:31 2018 New Revision: 338186 URL: http://llvm.org/viewvc/llvm-project?rev=338186=rev Log: Compile SemaTemplate.cpp with /bigobj on MSVC This should fix some bot failures introduced by r338165. Modified: cfe/trunk/lib/Sema/CMakeLists.txt Modified: cfe/trunk/lib/Sema/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CMakeLists.txt?rev=338186=338185=338186=diff == --- cfe/trunk/lib/Sema/CMakeLists.txt (original) +++ cfe/trunk/lib/Sema/CMakeLists.txt Fri Jul 27 18:29:31 2018 @@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS if (MSVC) set_source_files_properties(SemaDeclAttr.cpp PROPERTIES COMPILE_FLAGS /bigobj) set_source_files_properties(SemaExpr.cpp PROPERTIES COMPILE_FLAGS /bigobj) + set_source_files_properties(SemaTemplate.cpp PROPERTIES COMPILE_FLAGS /bigobj) endif() add_clang_library(clangSema ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49952: Check for NULL Destination-Type when creating ArrayConstant
bviyer created this revision. bviyer added reviewers: arphaman, dexonsmith, ahatanak, rjmccall. While emitting Array Constant, if the destination type is null-pointer, it will cause an assert. This patch will check if the destination type is null, and if so then it will just return nullptr as the array constant (not something that is derived from destination type). A test case is also attached. Repository: rC Clang https://reviews.llvm.org/D49952 Files: lib/CodeGen/CGExprConstant.cpp test/CodeGenCXX/empty-struct-init-list.cpp Index: test/CodeGenCXX/empty-struct-init-list.cpp === --- /dev/null +++ test/CodeGenCXX/empty-struct-init-list.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -std=c++11 %s +// RUN: %clang_cc1 -std=c++14 %s +// RUN: %clang_cc1 -std=c++17 %s +// expected-no-diagnostics + +typedef struct { } a; + +typedef struct { + a b[]; +} c; +c d{ }; Index: lib/CodeGen/CGExprConstant.cpp === --- lib/CodeGen/CGExprConstant.cpp +++ lib/CodeGen/CGExprConstant.cpp @@ -650,6 +650,8 @@ } if (NonzeroLength == 0) { +if (DestType == nullptr) + return nullptr; return llvm::ConstantAggregateZero::get( CGM.getTypes().ConvertType(QualType(DestType, 0))); } Index: test/CodeGenCXX/empty-struct-init-list.cpp === --- /dev/null +++ test/CodeGenCXX/empty-struct-init-list.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -std=c++11 %s +// RUN: %clang_cc1 -std=c++14 %s +// RUN: %clang_cc1 -std=c++17 %s +// expected-no-diagnostics + +typedef struct { } a; + +typedef struct { + a b[]; +} c; +c d{ }; Index: lib/CodeGen/CGExprConstant.cpp === --- lib/CodeGen/CGExprConstant.cpp +++ lib/CodeGen/CGExprConstant.cpp @@ -650,6 +650,8 @@ } if (NonzeroLength == 0) { +if (DestType == nullptr) + return nullptr; return llvm::ConstantAggregateZero::get( CGM.getTypes().ConvertType(QualType(DestType, 0))); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338183 - [CFG] Remove duplicate function/class names at the beginning of comments
Author: maskray Date: Fri Jul 27 17:48:05 2018 New Revision: 338183 URL: http://llvm.org/viewvc/llvm-project?rev=338183=rev Log: [CFG] Remove duplicate function/class names at the beginning of comments Some functions/classes have renamed while the comments still use the old names. Delete them per coding style. Also some whitespace cleanup. Modified: cfe/trunk/include/clang/Analysis/Analyses/CFGReachabilityAnalysis.h cfe/trunk/include/clang/Analysis/CFG.h cfe/trunk/include/clang/Analysis/CFGStmtMap.h cfe/trunk/lib/Analysis/CFGReachabilityAnalysis.cpp Modified: cfe/trunk/include/clang/Analysis/Analyses/CFGReachabilityAnalysis.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/CFGReachabilityAnalysis.h?rev=338183=338182=338183=diff == --- cfe/trunk/include/clang/Analysis/Analyses/CFGReachabilityAnalysis.h (original) +++ cfe/trunk/include/clang/Analysis/Analyses/CFGReachabilityAnalysis.h Fri Jul 27 17:48:05 2018 @@ -23,7 +23,7 @@ namespace clang { class CFG; class CFGBlock; - + // A class that performs reachability queries for CFGBlocks. Several internal // checks in this checker require reachability information. The requests all // tend to have a common destination, so we lazily do a predecessor search @@ -45,7 +45,7 @@ public: private: void mapReachability(const CFGBlock *Dst); }; - + } // namespace clang #endif // LLVM_CLANG_ANALYSIS_ANALYSES_CFGREACHABILITYANALYSIS_H Modified: cfe/trunk/include/clang/Analysis/CFG.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CFG.h?rev=338183=338182=338183=diff == --- cfe/trunk/include/clang/Analysis/CFG.h (original) +++ cfe/trunk/include/clang/Analysis/CFG.h Fri Jul 27 17:48:05 2018 @@ -51,7 +51,7 @@ class FieldDecl; class LangOptions; class VarDecl; -/// CFGElement - Represents a top-level expression in a basic block. +/// Represents a top-level expression in a basic block. class CFGElement { public: enum Kind { @@ -144,9 +144,9 @@ protected: CFGStmt() = default; }; -/// CFGConstructor - Represents C++ constructor call. Maintains information -/// necessary to figure out what memory is being initialized by the -/// constructor expression. For now this is only used by the analyzer's CFG. +/// Represents C++ constructor call. Maintains information necessary to figure +/// out what memory is being initialized by the constructor expression. For now +/// this is only used by the analyzer's CFG. class CFGConstructor : public CFGStmt { public: explicit CFGConstructor(CXXConstructExpr *CE, const ConstructionContext *C) @@ -169,12 +169,12 @@ private: } }; -/// CFGCXXRecordTypedCall - Represents a function call that returns a C++ object -/// by value. This, like constructor, requires a construction context in order -/// to understand the storage of the returned object . In C such tracking is not -/// necessary because no additional effort is required for destroying the object -/// or modeling copy elision. Like CFGConstructor, this element is for now only -/// used by the analyzer's CFG. +/// Represents a function call that returns a C++ object by value. This, like +/// constructor, requires a construction context in order to understand the +/// storage of the returned object . In C such tracking is not necessary because +/// no additional effort is required for destroying the object or modeling copy +/// elision. Like CFGConstructor, this element is for now only used by the +/// analyzer's CFG. class CFGCXXRecordTypedCall : public CFGStmt { public: /// Returns true when call expression \p CE needs to be represented @@ -210,8 +210,8 @@ private: } }; -/// CFGInitializer - Represents C++ base or member initializer from -/// constructor's initialization list. +/// Represents C++ base or member initializer from constructor's initialization +/// list. class CFGInitializer : public CFGElement { public: explicit CFGInitializer(CXXCtorInitializer *initializer) @@ -231,7 +231,7 @@ private: } }; -/// CFGNewAllocator - Represents C++ allocator call. +/// Represents C++ allocator call. class CFGNewAllocator : public CFGElement { public: explicit CFGNewAllocator(const CXXNewExpr *S) @@ -349,8 +349,8 @@ private: } }; -/// CFGImplicitDtor - Represents C++ object destructor implicitly generated -/// by compiler on various occasions. +/// Represents C++ object destructor implicitly generated by compiler on various +/// occasions. class CFGImplicitDtor : public CFGElement { protected: CFGImplicitDtor() = default; @@ -373,9 +373,9 @@ private: } }; -/// CFGAutomaticObjDtor - Represents C++ object destructor implicitly generated -/// for automatic object or temporary bound to const reference at the point -/// of leaving its local scope. +/// Represents C++ object
Re: r338165 - [Sema] Use a TreeTransform to extract deduction guide parameter types
Hello Erik, This commit broke build step on one of our builders: http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/11300 . . . FAILED: tools/clang/lib/Sema/CMakeFiles/clangSema.dir/SemaTemplate.cpp.obj C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe /nologo /TP -DEXPENSIVE_CHECKS -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_DEBUG -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\clang\lib\Sema -IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Sema -IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\include -Itools\clang\include -Iinclude -IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\include /DWIN32 /D_WINDOWS /Zc:inline /Zc:strictStrings /Oi /Zc:rvalueCast /W4 -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345 -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4324 -w14062 -we4238 /MDd /Zi /Ob0 /Od /RTC1/EHs-c- /GR- /showIncludes /Fotools\clang\lib\Sema\CMakeFiles\clangSema.dir\SemaTemplate.cpp.obj /Fdtools\clang\lib\Sema\CMakeFiles\clangSema.dir\clangSema.pdb /FS -c C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Sema\SemaTemplate.cpp C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Sema\SemaTemplate.cpp : fatal error C1128: number of sections exceeded object file format limit: compile with /bigobj ninja: build stopped: subcommand failed. Please have a look? The builder was already red and did not sent notifications. Thanks Galina On Fri, Jul 27, 2018 at 2:23 PM, Erik Pilkington via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: epilk > Date: Fri Jul 27 14:23:48 2018 > New Revision: 338165 > > URL: http://llvm.org/viewvc/llvm-project?rev=338165=rev > Log: > [Sema] Use a TreeTransform to extract deduction guide parameter types > > Previously, we just canonicalized the type, but this lead to crashes with > parameter types that referred to ParmVarDecls of the constructor. There > may be > more cases that this TreeTransform needs to handle though, such as a > constructor > parameter type referring to a member in an unevaluated context. > Canonicalization > doesn't address these cases either though, so we can address them > as-needed in > follow-up commits. > > rdar://41330135 > > Differential revision: https://reviews.llvm.org/D49439 > > Modified: > cfe/trunk/lib/Sema/SemaTemplate.cpp > cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp > > Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ > SemaTemplate.cpp?rev=338165=338164=338165=diff > > == > --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original) > +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Jul 27 14:23:48 2018 > @@ -1659,6 +1659,23 @@ DeclResult Sema::CheckClassTemplate( > } > > namespace { > +/// Tree transform to "extract" a transformed type from a class template's > +/// constructor to a deduction guide. > +class ExtractTypeForDeductionGuide > + : public TreeTransform { > +public: > + typedef TreeTransform Base; > + ExtractTypeForDeductionGuide(Sema ) : Base(SemaRef) {} > + > + TypeSourceInfo *transform(TypeSourceInfo *TSI) { return > TransformType(TSI); } > + > + QualType TransformTypedefType(TypeLocBuilder , TypedefTypeLoc TL) { > +return TransformType( > +TLB, > +TL.getTypedefNameDecl()->getTypeSourceInfo()->getTypeLoc()); > + } > +}; > + > /// Transform to convert portions of a constructor declaration into the > /// corresponding deduction guide, per C++1z [over.match.class.deduct]p1. > struct ConvertConstructorToDeductionGuideTransform { > @@ -1880,9 +1897,7 @@ private: > MultiLevelTemplateArgumentList ) { > TypeSourceInfo *OldDI = OldParam->getTypeSourceInfo(); > TypeSourceInfo *NewDI; > -if (!Args.getNumLevels()) > - NewDI = OldDI; > -else if (auto PackTL = OldDI->getTypeLoc().getAs()) > { > +if (auto PackTL = OldDI->getTypeLoc().getAs()) > { >// Expand out the one and only element in each inner pack. >Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(SemaRef, 0); >NewDI = > @@ -1898,23 +1913,17 @@ private: > if (!NewDI) >return nullptr; > > -// Canonicalize the type. This (for instance) replaces references to > -// typedef members of the current instantiations with the definitions > of > -// those typedefs, avoiding triggering instantiation of
[PATCH] D47196: [Time-report ](2): Recursive timers in Clang
efriedma added inline comments. Comment at: lib/Sema/SemaLambda.cpp:1447 +getFrontendFunctionTimeCtx()->startFrontendTimer( +{LSI.CallOperator, 0.0}); + } This seems sort of late? You're starting the timer after the body has already been parsed. Comment at: lib/Sema/TreeTransform.h:11011 +getFrontendFunctionTimeCtx()->startFrontendTimer( +{NewCallOperator, 0.0}); + } What happens if we never hit ActOnFinishFunctionBody()? TransformLambdaExpr has an early return if the body doesn't typecheck. More generally, given that we have early returns all over the place in Sema, I would be more comfortable using the RAII helper, rather than explicitly calling start/stop, even if that means you have to insert FrontendTimeRAII variables in half a dozen different places in the parser. (Note I'm specifically talking about the parser here; the explicit stopFrontendTimer in ~CodeGenFunction seems fine.) https://reviews.llvm.org/D47196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49548: [clangd] XPC WIP
arphaman requested changes to this revision. arphaman added a comment. FYI, this patch can't be applied because of the broken file paths (some diffs include /clangd prefix, some don't, while the test diffs are missing '/test'). Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D49548 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49119: [Sema][ObjC] Issue a warning when a method declared in a protocol is non-escaping but the corresponding method in the implementation is escaping.
ahatanak updated this revision to Diff 157815. ahatanak added a comment. - Produce a note that tells users where the class extension conforming to the protocol containing the non-escaping method is declared. - Add a class method that has the same name as the instance method and check that no spurious warnings are issued. Repository: rC Clang https://reviews.llvm.org/D49119 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDeclObjC.cpp test/SemaObjCXX/noescape.mm Index: test/SemaObjCXX/noescape.mm === --- test/SemaObjCXX/noescape.mm +++ test/SemaObjCXX/noescape.mm @@ -88,3 +88,42 @@ S5<> ne1; } + +@protocol NoescapeProt +-(void) m0:(int*)__attribute__((noescape)) p; // expected-note 2 {{parameter of overridden method is annotated with __attribute__((noescape))}} ++(void) m1:(int*)__attribute__((noescape)) p; +-(void) m1:(int*) p; +@end + +__attribute__((objc_root_class)) +@interface C3 +-(void) m0:(int*) p; ++(void) m1:(int*)__attribute__((noescape)) p; +-(void) m1:(int*) p; +@end + +@interface C3 () // expected-note {{class extension conforms to protocol 'NoescapeProt' which defines method 'm0:'}} +@end + +@implementation C3 +-(void) m0:(int*) p { // expected-warning {{parameter of overriding method should be annotated with __attribute__((noescape))}} +} ++(void) m1:(int*)__attribute__((noescape)) p { +} +-(void) m1:(int*) p { +} +@end + +__attribute__((objc_root_class)) +@interface C4 +-(void) m0:(int*) p; // expected-warning {{parameter of overriding method should be annotated with __attribute__((noescape))}} +@end + +@implementation C4 +-(void) m0:(int*) p { +} ++(void) m1:(int*)__attribute__((noescape)) p { +} +-(void) m1:(int*) p { +} +@end Index: lib/Sema/SemaDeclObjC.cpp === --- lib/Sema/SemaDeclObjC.cpp +++ lib/Sema/SemaDeclObjC.cpp @@ -109,6 +109,30 @@ return true; } +/// Issue a warning if the parameter of the overridden method is non-escaping +/// but the parameter of the overriding method is not. +static bool diagnoseNoescape(const ParmVarDecl *NewD, const ParmVarDecl *OldD, + Sema ) { + if (OldD->hasAttr() && !NewD->hasAttr()) { +S.Diag(NewD->getLocation(), diag::warn_overriding_method_missing_noescape); +S.Diag(OldD->getLocation(), diag::note_overridden_marked_noescape); +return false; + } + + return true; +} + +/// Produce additional diagnostics if a category conforms to a protocol that +/// defines a method taking a non-escaping parameter. +static void diagnoseNoescape(const ParmVarDecl *NewD, const ParmVarDecl *OldD, + const ObjCCategoryDecl *CD, + const ObjCProtocolDecl *PD, Sema ) { + if (!diagnoseNoescape(NewD, OldD, S)) +S.Diag(CD->getLocation(), diag::note_cat_conform_to_noescape_prot) +<< CD->IsClassExtension() << PD +<< cast(NewD->getDeclContext()); +} + void Sema::CheckObjCMethodOverride(ObjCMethodDecl *NewMethod, const ObjCMethodDecl *Overridden) { if (Overridden->hasRelatedResultType() && @@ -192,13 +216,7 @@ Diag(oldDecl->getLocation(), diag::note_previous_decl) << "parameter"; } -// A parameter of the overriding method should be annotated with noescape -// if the corresponding parameter of the overridden method is annotated. -if (oldDecl->hasAttr() && !newDecl->hasAttr()) { - Diag(newDecl->getLocation(), - diag::warn_overriding_method_missing_noescape); - Diag(oldDecl->getLocation(), diag::note_overridden_marked_noescape); -} +diagnoseNoescape(newDecl, oldDecl, *this); } } @@ -4643,6 +4661,22 @@ << ObjCMethod->getDeclName(); } } + + // Warn if a method declared in a protocol to which a category or + // extension conforms is non-escaping and the implementation's method is + // escaping. + for (auto *C : IDecl->visible_categories()) +for (auto : C->protocols()) + if (auto *IMD = P->lookupMethod(ObjCMethod->getSelector(), + ObjCMethod->isInstanceMethod())) { +assert(ObjCMethod->parameters().size() == + IMD->parameters().size() && + "Methods have different number of parameters"); +auto OI = IMD->param_begin(), OE = IMD->param_end(); +auto NI = ObjCMethod->param_begin(); +for (; OI != OE; ++OI, ++NI) + diagnoseNoescape(*NI, *OI, C, P, *this); + } } } else { cast(ClassDecl)->addDecl(ObjCMethod); Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -1733,6 +1733,8 @@ "__attribute__((noescape))">, InGroup; def
[PATCH] D49656: [analyzer] Add support for more pointer invalidating functions in InnerPointerChecker
NoQ added inline comments. Comment at: lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp:192 - if (Call.isCalled(CStrFn) || Call.isCalled(DataFn)) { -SVal RawPtr = Call.getReturnValue(); -if (SymbolRef Sym = RawPtr.getAsSymbol(/*IncludeBaseRegions=*/true)) { - // Start tracking this raw pointer by adding it to the set of symbols - // associated with this container object in the program state map. - PtrSet::Factory = State->getStateManager().get_context(); - const PtrSet *SetPtr = State->get(ObjRegion); - PtrSet Set = SetPtr ? *SetPtr : F.getEmptySet(); - assert(C.wasInlined || !Set.contains(Sym)); - Set = F.add(Set, Sym); - State = State->set(ObjRegion, Set); - C.addTransition(State); + SVal Arg = FC->getArgSVal(ArgI); + const auto *ArgRegion = rnkovacs wrote: > NoQ wrote: > > xazax.hun wrote: > > > While I cannot recall examples in the STL the number of arguments and > > > parameters might differ. We might have ellipsis in the parameters and > > > this way we may pass more arguments. Since we do not have the parameter > > > type for this case, I think it is ok to not handle it. But it might be > > > worth to have a comment. The other case, when we have default arguments. > > > I do not really know how the analyzer behaves with default arguments but > > > maybe it would be worth to add a test case to ensure we do not crash on > > > that? > > The analyzer behaves pretty badly with default arguments; we don't really > > model them unless they are like plain integer literals. But that's not an > > issue here because a default parameter/argument is still both a parameter > > and an argument (where the argument expression takes the form of > > `CXXDefaultArgExpr`). > Hm, it seems that passing objects of non-trivial types like `std::string` to > a variadic function is implementation defined, and for `clang 6.0`, this > means that it does not compile (does compile with `gcc 8.1` though, [[ > https://godbolt.org/g/C3MCtV | example ]]). > > Added a test for the default parameter case. Yup, that's correct; i noticed it a few days ago too in https://reviews.llvm.org/D49443#1170831. You can disable the warning/error with `-Wno-non-pod-varargs` for the purposes of testing, but you anyway won't be able to obtain the AST you'll want to test, so i don't think this requires a test. https://reviews.llvm.org/D49656 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49656: [analyzer] Add support for more pointer invalidating functions in InnerPointerChecker
rnkovacs added inline comments. Comment at: lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp:192 - if (Call.isCalled(CStrFn) || Call.isCalled(DataFn)) { -SVal RawPtr = Call.getReturnValue(); -if (SymbolRef Sym = RawPtr.getAsSymbol(/*IncludeBaseRegions=*/true)) { - // Start tracking this raw pointer by adding it to the set of symbols - // associated with this container object in the program state map. - PtrSet::Factory = State->getStateManager().get_context(); - const PtrSet *SetPtr = State->get(ObjRegion); - PtrSet Set = SetPtr ? *SetPtr : F.getEmptySet(); - assert(C.wasInlined || !Set.contains(Sym)); - Set = F.add(Set, Sym); - State = State->set(ObjRegion, Set); - C.addTransition(State); + SVal Arg = FC->getArgSVal(ArgI); + const auto *ArgRegion = NoQ wrote: > xazax.hun wrote: > > While I cannot recall examples in the STL the number of arguments and > > parameters might differ. We might have ellipsis in the parameters and this > > way we may pass more arguments. Since we do not have the parameter type for > > this case, I think it is ok to not handle it. But it might be worth to have > > a comment. The other case, when we have default arguments. I do not really > > know how the analyzer behaves with default arguments but maybe it would be > > worth to add a test case to ensure we do not crash on that? > The analyzer behaves pretty badly with default arguments; we don't really > model them unless they are like plain integer literals. But that's not an > issue here because a default parameter/argument is still both a parameter and > an argument (where the argument expression takes the form of > `CXXDefaultArgExpr`). Hm, it seems that passing objects of non-trivial types like `std::string` to a variadic function is implementation defined, and for `clang 6.0`, this means that it does not compile (does compile with `gcc 8.1` though, [[ https://godbolt.org/g/C3MCtV | example ]]). Added a test for the default parameter case. https://reviews.llvm.org/D49656 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49656: [analyzer] Add support for more pointer invalidating functions in InnerPointerChecker
rnkovacs updated this revision to Diff 157809. rnkovacs marked an inline comment as done. https://reviews.llvm.org/D49656 Files: lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp lib/StaticAnalyzer/Checkers/MallocChecker.cpp test/Analysis/inner-pointer.cpp Index: test/Analysis/inner-pointer.cpp === --- test/Analysis/inner-pointer.cpp +++ test/Analysis/inner-pointer.cpp @@ -38,13 +38,29 @@ typedef basic_string u16string; typedef basic_string u32string; +template +void func_ref(T ); + +template +void func_const_ref(const T ); + +template +void func_value(T a); + +string my_string = "default"; +void default_arg(int a = 42, string = my_string); + } // end namespace std void consume(const char *) {} void consume(const wchar_t *) {} void consume(const char16_t *) {} void consume(const char32_t *) {} +//=--=// +// `std::string` member functions // +//=--=// + void deref_after_scope_char(bool cond) { const char *c, *d; { @@ -151,6 +167,19 @@ } // expected-note@-1 {{Use of memory after it is freed}} } +void deref_after_scope_ok(bool cond) { + const char *c, *d; + std::string s; + { +c = s.c_str(); +d = s.data(); + } + if (cond) +consume(c); // no-warning + else +consume(d); // no-warning +} + void deref_after_equals() { const char *c; std::string s = "hello"; @@ -277,15 +306,58 @@ // expected-note@-1 {{Use of memory after it is freed}} } -void deref_after_scope_ok(bool cond) { - const char *c, *d; +//=---=// +// Other STL functions // +//=---=// + +void STL_func_ref() { + const char *c; std::string s; - { -c = s.c_str(); -d = s.data(); - } - if (cond) -consume(c); // no-warning - else -consume(d); // no-warning + c = s.c_str();// expected-note {{Dangling inner pointer obtained here}} + std::func_ref(s); // expected-note {{Inner pointer invalidated by call to 'func_ref'}} + consume(c); // expected-warning {{Use of memory after it is freed}} + // expected-note@-1 {{Use of memory after it is freed}} +} + +void STL_func_const_ref() { + const char *c; + std::string s; + c = s.c_str(); + std::func_const_ref(s); + consume(c); // no-warning +} + +void STL_func_value() { + const char *c; + std::string s; + c = s.c_str(); + std::func_value(s); + consume(c); // no-warning +} + +void func_ptr_known() { + const char *c; + std::string s; + void (*func_ptr)(std::string &) = std::func_ref; + c = s.c_str(); // expected-note {{Dangling inner pointer obtained here}} + func_ptr(s); // expected-note {{Inner pointer invalidated by call to 'func_ref'}} + consume(c);// expected-warning {{Use of memory after it is freed}} + // expected-note@-1 {{Use of memory after it is freed}} +} + +void func_ptr_unknown(void (*func_ptr)(std::string &)) { + const char *c; + std::string s; + c = s.c_str(); + func_ptr(s); + consume(c); // no-warning +} + +void func_default_arg() { + const char *c; + std::string s; + c = s.c_str(); // expected-note {{Dangling inner pointer obtained here}} + default_arg(3, s); // expected-note {{Inner pointer invalidated by call to 'default_arg'}} + consume(c);// expected-warning {{Use of memory after it is freed}} + // expected-note@-1 {{Use of memory after it is freed}} } Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp === --- lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -2930,6 +2930,11 @@ OS << MemCallE->getMethodDecl()->getNameAsString(); } else if (const auto *OpCallE = dyn_cast(S)) { OS << OpCallE->getDirectCallee()->getNameAsString(); +} else if (const auto *CallE = dyn_cast(S)) { + auto = BRC.getStateManager().getCallEventManager(); + CallEventRef<> Call = CEMgr.getSimpleCall(CallE, state, CurrentLC); + const auto *D = dyn_cast_or_null(Call->getDecl()); + OS << (D ? D->getNameAsString() : "unknown"); } OS << "'"; } Index: lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp === --- lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp +++ lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp @@ -91,37 +91,53 @@ ReserveFn("reserve"), ResizeFn("resize"), ShrinkToFitFn("shrink_to_fit"), SwapFn("swap") {} - /// Check whether the function called on the container object is a - /// member function that potentially invalidates pointers referring - /// to the objects's internal buffer. - bool mayInvalidateBuffer(const CallEvent ) const; - - /// Record the connection between the symbol returned by c_str() and
[PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map
rnk accepted this revision. rnk added a comment. This revision is now accepted and ready to land. lgtm Repository: rC Clang https://reviews.llvm.org/D49466 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46013: [ARM] Conform to AAPCS when passing overaligned composites as arguments
efriedma accepted this revision. efriedma added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D46013 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49511: [Sema/Attribute] Check for noderef attribute
mcgrathr added a comment. I think this wants to be a hard error rather than a warning. Though since we use -Werror anyway if others feel strongly contrary I won't object. Repository: rC Clang https://reviews.llvm.org/D49511 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49119: [Sema][ObjC] Issue a warning when a method declared in a protocol is non-escaping but the corresponding method in the implementation is escaping.
ahatanak added a comment. Thanks, I'll update the patch and commit it today. In https://reviews.llvm.org/D49119#1176139, @vsapsai wrote: > In https://reviews.llvm.org/D49119#1176047, @ahatanak wrote: > > > In https://reviews.llvm.org/D49119#1164285, @vsapsai wrote: > > > > > Also I had a few ideas for tests when the warning isn't required and it > > > is absent. But I'm not sure they are actually valuable. If you are > > > interested, we can discuss it in more details. > > > > > > Could you elaborate on what kind of tests you have in mind? > > > > > - declaring `noescape` on implementation when nothing like that was mentioned > in interface or protocols; Maybe we should consider this, but I don't think this is incorrect functionally. If you pass an object to such methods, clang's IRGen will just emit the unoptimized code that is emitted for calls to functions/methods taking escaping parameters (e.g., no 'nocapture' on parameters, no stack block optimization implemented in r337580). The opposite case (non-escaping interface and escaping implementation) is incorrect and can cause problems, so we need some diagnostics. > - have class method and instance method with the same name, only one of them > is `noescape`, test that we don't show spurious warning in this case; I can add a test case for this. > - try selector names that look similar but are different, like `-foo`, > `-foo:`, `-foo::` This test suggestion isn't really related to `noescape`, I > just got carried away. Repository: rC Clang https://reviews.llvm.org/D49119 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49945: [Fixed Point Arithmetic] Fix for FixedPointValueToString
leonardchan created this revision. leonardchan added reviewers: phosek, mcgrathr, jakehehrlich, ebevhan, rjmccall. leonardchan added a project: clang. Herald added a subscriber: mgorny. - Print negative numbers correctly - Handle APInts of different sizes - Add formal unit tests for FixedPointValueToString - Add tests for checking correct printing when padding is set Repository: rC Clang https://reviews.llvm.org/D49945 Files: include/clang/AST/Type.h lib/AST/Expr.cpp lib/AST/ExprConstant.cpp lib/AST/Type.cpp test/Frontend/fixed_point_to_string.c unittests/Frontend/CMakeLists.txt unittests/Frontend/FixedPointString.cpp Index: unittests/Frontend/FixedPointString.cpp === --- /dev/null +++ unittests/Frontend/FixedPointString.cpp @@ -0,0 +1,107 @@ +#include "clang/AST/Type.h" +#include "llvm/ADT/APSInt.h" +#include "llvm/ADT/SmallString.h" +#include "gtest/gtest.h" + +using clang::FixedPointValueToString; +using llvm::APSInt; +using llvm::SmallString; + +namespace { + +TEST(FixedPointString, DifferentTypes) { + SmallString<64> S; + FixedPointValueToString(S, APSInt::get(320), 7); + ASSERT_STREQ(S.c_str(), "2.5"); + + S.clear(); + FixedPointValueToString(S, APSInt::get(0), 7); + ASSERT_STREQ(S.c_str(), "0.0"); + + // signed short _Accum + S.clear(); + FixedPointValueToString(S, APSInt::getMaxValue(16, /*Unsigned=*/false), 7); + ASSERT_STREQ(S.c_str(), "255.9921875"); + + // signed _Accum + S.clear(); + FixedPointValueToString(S, APSInt::getMaxValue(32, /*Unsigned=*/false), 15); + ASSERT_STREQ(S.c_str(), "65535.69482421875"); + + // signed long _Accum + S.clear(); + FixedPointValueToString(S, APSInt::getMaxValue(64, /*Unsigned=*/false), 31); + ASSERT_STREQ(S.c_str(), "4294967295.95343387126922607421875"); + + // unsigned short _Accum + S.clear(); + FixedPointValueToString(S, APSInt::getMaxValue(16, /*Unsigned=*/true), 8); + ASSERT_STREQ(S.c_str(), "255.99609375"); + + // unsigned _Accum + S.clear(); + FixedPointValueToString(S, APSInt::getMaxValue(32, /*Unsigned=*/true), 16); + ASSERT_STREQ(S.c_str(), "65535.847412109375"); + + // unsigned long _Accum + S.clear(); + FixedPointValueToString(S, APSInt::getMaxValue(64, /*Unsigned=*/true), 32); + ASSERT_STREQ(S.c_str(), "4294967295.976716935634613037109375"); + + // signed short _Fract + S.clear(); + FixedPointValueToString(S, APSInt::getMaxValue(8, /*Unsigned=*/false), 7); + ASSERT_STREQ(S.c_str(), "0.9921875"); + + // signed _Fract + S.clear(); + FixedPointValueToString(S, APSInt::getMaxValue(16, /*Unsigned=*/false), 15); + ASSERT_STREQ(S.c_str(), "0.69482421875"); + + // signed long _Fract + S.clear(); + FixedPointValueToString(S, APSInt::getMaxValue(32, /*Unsigned=*/false), 31); + ASSERT_STREQ(S.c_str(), "0.95343387126922607421875"); + + // unsigned short _Fract + S.clear(); + FixedPointValueToString(S, APSInt::getMaxValue(8, /*Unsigned=*/true), 8); + ASSERT_STREQ(S.c_str(), "0.99609375"); + + // unsigned _Fract + S.clear(); + FixedPointValueToString(S, APSInt::getMaxValue(16, /*Unsigned=*/true), 16); + ASSERT_STREQ(S.c_str(), "0.847412109375"); + + // unsigned long _Fract + S.clear(); + FixedPointValueToString(S, APSInt::getMaxValue(32, /*Unsigned=*/true), 32); + ASSERT_STREQ(S.c_str(), "0.976716935634613037109375"); +} + +TEST(FixedPointString, Negative) { + SmallString<64> S; + FixedPointValueToString(S, APSInt::get(-320), 7); + ASSERT_STREQ(S.c_str(), "-2.5"); + + S.clear(); + FixedPointValueToString(S, APSInt::get(-64), 7); + ASSERT_STREQ(S.c_str(), "-0.5"); + + // signed short _Accum + S.clear(); + FixedPointValueToString(S, APSInt::getMinValue(16, /*Unsigned=*/false), 7); + ASSERT_STREQ(S.c_str(), "-256.0"); + + // signed _Accum + S.clear(); + FixedPointValueToString(S, APSInt::getMinValue(32, /*Unsigned=*/false), 15); + ASSERT_STREQ(S.c_str(), "-65536.0"); + + // signed long _Accum + S.clear(); + FixedPointValueToString(S, APSInt::getMinValue(64, /*Unsigned=*/false), 31); + ASSERT_STREQ(S.c_str(), "-4294967296.0"); +} + +} // namespace Index: unittests/Frontend/CMakeLists.txt === --- unittests/Frontend/CMakeLists.txt +++ unittests/Frontend/CMakeLists.txt @@ -5,6 +5,7 @@ add_clang_unittest(FrontendTests ASTUnitTest.cpp CompilerInstanceTest.cpp + FixedPointString.cpp FrontendActionTest.cpp CodeGenActionTest.cpp ParsedSourceLocationTest.cpp Index: test/Frontend/fixed_point_to_string.c === --- /dev/null +++ test/Frontend/fixed_point_to_string.c @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -ast-dump -ffixed-point %s | FileCheck %s +// RUN: %clang_cc1 -ast-dump -ffixed-point -fpadding-on-unsigned-fixed-point %s | FileCheck %s + +/** + * Check the same values are printed in the AST regardless of if unsigned types + * have
[PATCH] D49210: [CFG] [analyzer] NFC: Enumerate construction context layer kinds and re-use their code for ExprEngine keys.
NoQ updated this revision to Diff 157789. NoQ added a comment. A better `ConstructedObjectKey::print()`. https://reviews.llvm.org/D49210 Files: include/clang/Analysis/ConstructionContext.h include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h lib/Analysis/CFG.cpp lib/Analysis/ConstructionContext.cpp lib/StaticAnalyzer/Core/ExprEngine.cpp Index: lib/StaticAnalyzer/Core/ExprEngine.cpp === --- lib/StaticAnalyzer/Core/ExprEngine.cpp +++ lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -117,56 +117,42 @@ /// the construction context was present and contained references to these /// AST nodes. class ConstructedObjectKey { - typedef std::pair< - llvm::PointerUnion, - const LocationContext *> ConstructedObjectKeyImpl; + typedef std::pair + ConstructedObjectKeyImpl; - ConstructedObjectKeyImpl Impl; + const ConstructedObjectKeyImpl Impl; const void *getAnyASTNodePtr() const { -if (const Stmt *S = getStmt()) +if (const Stmt *S = getItem().getStmt()) return S; else - return getCXXCtorInitializer(); + return getItem().getCXXCtorInitializer(); } public: - ConstructedObjectKey( - llvm::PointerUnion P, - const LocationContext *LC) - : Impl(P, LC) { -// This is the full list of statements that require additional actions when -// encountered. This list may be expanded when new actions are implemented. -assert(getCXXCtorInitializer() || isa(getStmt()) || - isa(getStmt()) || isa(getStmt()) || - isa(getStmt()) || - isa(getStmt())); - } - - const Stmt *getStmt() const { -return Impl.first.dyn_cast(); - } - - const CXXCtorInitializer *getCXXCtorInitializer() const { -return Impl.first.dyn_cast(); - } + explicit ConstructedObjectKey(const ConstructionContextItem , + const LocationContext *LC) + : Impl(Item, LC) {} - const LocationContext *getLocationContext() const { -return Impl.second; - } + const ConstructionContextItem () const { return Impl.first; } + const LocationContext *getLocationContext() const { return Impl.second; } void print(llvm::raw_ostream , PrinterHelper *Helper, PrintingPolicy ) { -OS << '(' << getLocationContext() << ',' << getAnyASTNodePtr() << ") "; -if (const Stmt *S = getStmt()) { +OS << '(' << getLocationContext() << ',' << getAnyASTNodePtr() << ',' + << getItem().getKindAsString(); +if (getItem().getKind() == ConstructionContextItem::ArgumentKind) + OS << " #" << getItem().getIndex(); +OS << ") "; +if (const Stmt *S = getItem().getStmtOrNull()) { S->printPretty(OS, Helper, PP); } else { - const CXXCtorInitializer *I = getCXXCtorInitializer(); + const CXXCtorInitializer *I = getItem().getCXXCtorInitializer(); OS << I->getAnyMember()->getNameAsString(); } } void Profile(llvm::FoldingSetNodeID ) const { -ID.AddPointer(Impl.first.getOpaqueValue()); +ID.Add(Impl.first); ID.AddPointer(Impl.second); } @@ -184,15 +170,6 @@ REGISTER_TRAIT_WITH_PROGRAMSTATE(ObjectsUnderConstruction, ObjectsUnderConstructionMap) -// Additionally, track a set of destructors that correspond to elided -// constructors when copy elision occurs. -typedef std::pair -ElidedDestructorItem; -typedef llvm::ImmutableSet -ElidedDestructorSet; -REGISTER_TRAIT_WITH_PROGRAMSTATE(ElidedDestructors, - ElidedDestructorSet) - //===--===// // Engine construction and deletion. //===--===// @@ -449,57 +426,58 @@ return State; } -ProgramStateRef ExprEngine::addObjectUnderConstruction( -ProgramStateRef State, -llvm::PointerUnion P, -const LocationContext *LC, SVal V) { - ConstructedObjectKey Key(P, LC->getStackFrame()); +ProgramStateRef +ExprEngine::addObjectUnderConstruction(ProgramStateRef State, + const ConstructionContextItem , + const LocationContext *LC, SVal V) { + ConstructedObjectKey Key(Item, LC->getStackFrame()); // FIXME: Currently the state might already contain the marker due to // incorrect handling of temporaries bound to default parameters. assert(!State->get(Key) || - isa(Key.getStmt())); + Key.getItem().getKind() == + ConstructionContextItem::TemporaryDestructorKind); return State->set(Key, V); } -Optional ExprEngine::getObjectUnderConstruction( -ProgramStateRef State, -llvm::PointerUnion P, -const LocationContext *LC) { - ConstructedObjectKey Key(P, LC->getStackFrame()); +Optional +ExprEngine::getObjectUnderConstruction(ProgramStateRef State, + const ConstructionContextItem , +
[PATCH] D49119: [Sema][ObjC] Issue a warning when a method declared in a protocol is non-escaping but the corresponding method in the implementation is escaping.
vsapsai accepted this revision. vsapsai added a comment. This revision is now accepted and ready to land. Looks good to me. Any further improvements are up to you. Repository: rC Clang https://reviews.llvm.org/D49119 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49941: [ARM] Add ARMv8.2-A FP16 scalar intrinsic
az created this revision. az added a reviewer: SjoerdMeijer. Herald added a reviewer: javed.absar. Herald added subscribers: cfe-commits, chrib, kristof.beyls. This patch adds the fp16 scalar intrinsic for ARM as described in the ARM ACLE document. Only the frontend work is done here and some work is still needed in the backend codegen. Repository: rC Clang https://reviews.llvm.org/D49941 Files: clang/include/clang/Basic/arm_fp16.td clang/lib/CodeGen/CGBuiltin.cpp clang/test/CodeGen/arm-v8.2a-fp16-intrinsics.c llvm/include/llvm/IR/IntrinsicsARM.td Index: llvm/include/llvm/IR/IntrinsicsARM.td === --- llvm/include/llvm/IR/IntrinsicsARM.td +++ llvm/include/llvm/IR/IntrinsicsARM.td @@ -355,6 +355,9 @@ class Neon_2Arg_Intrinsic : Intrinsic<[llvm_anyvector_ty], [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem]>; +class Float_2Arg_Intrinsic + : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, LLVMMatchType<0>], + [IntrNoMem]>; class Neon_2Arg_Narrow_Intrinsic : Intrinsic<[llvm_anyvector_ty], [LLVMExtendedType<0>, LLVMExtendedType<0>], [IntrNoMem]>; @@ -377,8 +380,8 @@ : Intrinsic<[llvm_anyfloat_ty], [llvm_anyint_ty, llvm_i32_ty], [IntrNoMem]>; class Neon_CvtFPToFx_Intrinsic : Intrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty, llvm_i32_ty], [IntrNoMem]>; -class Neon_CvtFPtoInt_1Arg_Intrinsic - : Intrinsic<[llvm_anyvector_ty], [llvm_anyvector_ty], [IntrNoMem]>; +class CvtFPtoInt_1Arg_Intrinsic + : Intrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty], [IntrNoMem]>; class Neon_Compare_Intrinsic : Intrinsic<[llvm_anyvector_ty], [llvm_anyvector_ty, LLVMMatchType<1>], @@ -431,12 +434,12 @@ // Vector Maximum. def int_arm_neon_vmaxs : Neon_2Arg_Intrinsic; def int_arm_neon_vmaxu : Neon_2Arg_Intrinsic; - def int_arm_neon_vmaxnm : Neon_2Arg_Intrinsic; + def int_arm_neon_vmaxnm : Float_2Arg_Intrinsic; // Vector Minimum. def int_arm_neon_vmins : Neon_2Arg_Intrinsic; def int_arm_neon_vminu : Neon_2Arg_Intrinsic; - def int_arm_neon_vminnm : Neon_2Arg_Intrinsic; + def int_arm_neon_vminnm : Float_2Arg_Intrinsic; // Vector Reciprocal Step. def int_arm_neon_vrecps : Neon_2Arg_Intrinsic; @@ -552,15 +555,15 @@ // Vector Reciprocal Square Root Estimate. def int_arm_neon_vrsqrte : Neon_1Arg_Intrinsic; -// Vector Conversions Between Floating-point and Integer -def int_arm_neon_vcvtau : Neon_CvtFPtoInt_1Arg_Intrinsic; -def int_arm_neon_vcvtas : Neon_CvtFPtoInt_1Arg_Intrinsic; -def int_arm_neon_vcvtnu : Neon_CvtFPtoInt_1Arg_Intrinsic; -def int_arm_neon_vcvtns : Neon_CvtFPtoInt_1Arg_Intrinsic; -def int_arm_neon_vcvtpu : Neon_CvtFPtoInt_1Arg_Intrinsic; -def int_arm_neon_vcvtps : Neon_CvtFPtoInt_1Arg_Intrinsic; -def int_arm_neon_vcvtmu : Neon_CvtFPtoInt_1Arg_Intrinsic; -def int_arm_neon_vcvtms : Neon_CvtFPtoInt_1Arg_Intrinsic; +// Conversions Between Floating-point and Integer +def int_arm_neon_vcvtau : CvtFPtoInt_1Arg_Intrinsic; +def int_arm_neon_vcvtas : CvtFPtoInt_1Arg_Intrinsic; +def int_arm_neon_vcvtnu : CvtFPtoInt_1Arg_Intrinsic; +def int_arm_neon_vcvtns : CvtFPtoInt_1Arg_Intrinsic; +def int_arm_neon_vcvtpu : CvtFPtoInt_1Arg_Intrinsic; +def int_arm_neon_vcvtps : CvtFPtoInt_1Arg_Intrinsic; +def int_arm_neon_vcvtmu : CvtFPtoInt_1Arg_Intrinsic; +def int_arm_neon_vcvtms : CvtFPtoInt_1Arg_Intrinsic; // Vector Conversions Between Floating-point and Fixed-point. def int_arm_neon_vcvtfp2fxs : Neon_CvtFPToFx_Intrinsic; Index: clang/test/CodeGen/arm-v8.2a-fp16-intrinsics.c === --- /dev/null +++ clang/test/CodeGen/arm-v8.2a-fp16-intrinsics.c @@ -0,0 +1,225 @@ +// RUN: %clang_cc1 -triple armv8.2a-linux-gnu -target-abi apcs-gnu -target-feature +neon -target-feature +fullfp16 \ +// RUN: -fallow-half-arguments-and-returns -S -disable-O0-optnone -emit-llvm -o - %s \ +// RUN: | opt -S -mem2reg \ +// RUN: | FileCheck %s + +// REQUIRES: arm-registered-target + +#include + +// CHECK-LABEL: test_vabsh_f16 +// CHECK: [[ABS:%.*]] = call half @llvm.fabs.f16(half %{{.*}}) +float16_t test_vabsh_f16(float16_t a) { + return vabsh_f16(a); +} + +// CHECK-LABEL: test_vcvth_f16_s32 +// CHECK: [[VCVT:%.*]] = sitofp i32 %a to half +float16_t test_vcvth_f16_s32 (int32_t a) { + return vcvth_f16_s32(a); +} + +// CHECK-LABEL: test_vcvth_f16_u32 +// CHECK: [[VCVT:%.*]] = uitofp i32 %a to half +float16_t test_vcvth_f16_u32 (uint32_t a) { + return vcvth_f16_u32(a); +} + +// CHECK-LABEL: test_vcvth_s32_f16 +// CHECK: [[VCVT:%.*]] = fptosi half %{{.*}} to i32 +// CHECK: ret i32 [[VCVT]] +int32_t test_vcvth_s32_f16 (float16_t a) { + return vcvth_s32_f16(a); +} + +// CHECK-LABEL: test_vcvth_u32_f16 +// CHECK: [[VCVT:%.*]] = fptoui half %{{.*}} to i32 +// CHECK: ret i32 [[VCVT]] +uint32_t test_vcvth_u32_f16 (float16_t a) { + return vcvth_u32_f16(a); +} + +// CHECK-LABEL: test_vcvtah_s32_f16 +// CHECK: [[VCVT:%.*]] = call i32
[PATCH] D49931: [CUDA][HIP] Allow function-scope static const variable
yaxunl updated this revision to Diff 157778. yaxunl marked an inline comment as done. yaxunl added a comment. Revised by Artem's comments. https://reviews.llvm.org/D49931 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/CodeGen/CodeGenModule.cpp lib/Sema/SemaDecl.cpp test/CodeGenCUDA/device-var-init.cu test/SemaCUDA/device-var-init.cu Index: test/SemaCUDA/device-var-init.cu === --- test/SemaCUDA/device-var-init.cu +++ test/SemaCUDA/device-var-init.cu @@ -207,17 +207,22 @@ // expected-error@-1 {{initialization is not supported for __shared__ variables.}} static __device__ int ds; - // expected-error@-1 {{within a __device__ function, only __shared__ variables may be marked 'static'}} + // expected-error@-1 {{within a __device__ function, only __shared__ variables or const variables without device memory qualifier may be marked 'static'}} static __constant__ int dc; - // expected-error@-1 {{within a __device__ function, only __shared__ variables may be marked 'static'}} + // expected-error@-1 {{within a __device__ function, only __shared__ variables or const variables without device memory qualifier may be marked 'static'}} static int v; - // expected-error@-1 {{within a __device__ function, only __shared__ variables may be marked 'static'}} + // expected-error@-1 {{within a __device__ function, only __shared__ variables or const variables without device memory qualifier may be marked 'static'}} + static const int cv = 1; + static const __device__ int cds = 1; + // expected-error@-1 {{within a __device__ function, only __shared__ variables or const variables without device memory qualifier may be marked 'static'}} + static const __constant__ int cdc = 1; + // expected-error@-1 {{within a __device__ function, only __shared__ variables or const variables without device memory qualifier may be marked 'static'}} } __host__ __device__ void hd_sema() { static int x = 42; #ifdef __CUDA_ARCH__ - // expected-error@-2 {{within a __host__ __device__ function, only __shared__ variables may be marked 'static'}} + // expected-error@-2 {{within a __host__ __device__ function, only __shared__ variables or const variables without device memory qualifier may be marked 'static'}} #endif } Index: test/CodeGenCUDA/device-var-init.cu === --- test/CodeGenCUDA/device-var-init.cu +++ test/CodeGenCUDA/device-var-init.cu @@ -112,6 +112,9 @@ // CHECK: @_ZZ2dfvE4s_ec = internal addrspace(3) global %struct.EC undef // CHECK: @_ZZ2dfvE5s_etc = internal addrspace(3) global %struct.ETC undef +// CHECK: @_ZZ2dfvE11const_array = internal addrspace(4) constant [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5] +// CHECK: @_ZZ2dfvE9const_int = internal addrspace(4) constant i32 123 + // We should not emit global initializers for device-side variables. // CHECK-NOT: @__cxx_global_var_init @@ -234,6 +237,9 @@ static __shared__ ETC s_etc; // CHECK-NOT: call void @_ZN3ETCC1IJEEEDpT_(%struct.ETC* addrspacecast (%struct.ETC addrspace(3)* @_ZZ2dfvE5s_etc to %struct.ETC*)) + static const int const_array[] = {1, 2, 3, 4, 5}; + static const int const_int = 123; + // anchor point separating constructors and destructors df(); // CHECK: call void @_Z2dfv() Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -11914,14 +11914,25 @@ NewAttr->setInherited(true); VD->addAttr(NewAttr); } - // CUDA E.2.9.4: Within the body of a __device__ or __global__ - // function, only __shared__ variables may be declared with - // static storage class. - if (getLangOpts().CUDA && !VD->hasAttr() && - CUDADiagIfDeviceCode(VD->getLocation(), - diag::err_device_static_local_var) - << CurrentCUDATarget()) -VD->setInvalidDecl(); + // CUDA 8.0 E.3.9.4: Within the body of a __device__ or __global__ + // function, only __shared__ variables or variables without any device + // memory qualifiers may be declared with static storage class. + // Note: It is unclear how a function-scope non-const static variable + // without device memory qualifier is implemented, therefore only static + // const variable without device memory qualifier is allowed. + [&]() { +if (!getLangOpts().CUDA) + return; +if (VD->hasAttr()) + return; +if (VD->getType().isConstQualified() && +!(VD->hasAttr() || VD->hasAttr())) + return; +if (CUDADiagIfDeviceCode(VD->getLocation(), + diag::err_device_static_local_var) +<< CurrentCUDATarget()) + VD->setInvalidDecl(); + }(); } } Index: lib/CodeGen/CodeGenModule.cpp
[PATCH] D49848: Parse a possible trailing postfix expression suffix after a fold expression
This revision was automatically updated to reflect the committed changes. Closed by commit rL338170: Parse a possible trailing postfix expression suffix after a fold expression (authored by Rakete, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D49848 Files: cfe/trunk/include/clang/Parse/Parser.h cfe/trunk/lib/Parse/ParseExpr.cpp cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp Index: cfe/trunk/include/clang/Parse/Parser.h === --- cfe/trunk/include/clang/Parse/Parser.h +++ cfe/trunk/include/clang/Parse/Parser.h @@ -1653,6 +1653,7 @@ /// ParenParseOption - Control what ParseParenExpression will parse. enum ParenParseOption { SimpleExpr, // Only parse '(' expression ')' +FoldExpr,// Also allow fold-expression CompoundStmt,// Also allow '(' compound-statement ')' CompoundLiteral, // Also allow '(' type-name ')' '{' ... '}' CastExpr // Also allow '(' type-name ')' Index: cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp === --- cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp +++ cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp @@ -60,3 +60,29 @@ } static_assert(nestedFoldOperator<3, 1>() == 1); + +// A fold-expression is a primary-expression. +template +constexpr auto castSum(Ts... Args) { + return (T)(Args + ...).Value; // expected-error{{member reference base type 'int' is not a structure or union}} +} + +template +constexpr auto simpleSum(Ts... Args) { + return (... + Args).Value; // expected-error{{member reference base type 'int' is not a structure or union}} +} + +void prim() { + castSum(1, 2); + // expected-note@-1{{in instantiation of function template specialization}} + simpleSum(1, 2); + // expected-note@-1{{in instantiation of function template specialization}} + + struct Number { +int Value; +constexpr Number operator+(Number Rhs) const { return {Rhs.Value + Value}; } + }; + + static_assert(castSum(Number{1}, Number{2}) == 3); + static_assert(simpleSum(Number{1}, Number{2}) == 3); +} Index: cfe/trunk/lib/Parse/ParseExpr.cpp === --- cfe/trunk/lib/Parse/ParseExpr.cpp +++ cfe/trunk/lib/Parse/ParseExpr.cpp @@ -789,6 +789,10 @@ // We have parsed the cast-expression and no postfix-expr pieces are // following. return Res; +case FoldExpr: + // We only parsed a fold-expression. There might be postfix-expr pieces + // afterwards; parse them now. + break; } break; @@ -2523,8 +2527,9 @@ Diag(Tok, diag::err_expected_lbrace_in_compound_literal); return ExprError(); } - } else if (Tok.is(tok::ellipsis) && + } else if (ExprType >= FoldExpr && Tok.is(tok::ellipsis) && isFoldOperator(NextToken().getKind())) { +ExprType = FoldExpr; return ParseFoldExpression(ExprResult(), T); } else if (isTypeCast) { // Parse the expression-list. @@ -2536,9 +2541,11 @@ if (!ParseSimpleExpressionList(ArgExprs, CommaLocs)) { // FIXME: If we ever support comma expressions as operands to // fold-expressions, we'll need to allow multiple ArgExprs here. - if (ArgExprs.size() == 1 && isFoldOperator(Tok.getKind()) && - NextToken().is(tok::ellipsis)) + if (ExprType >= FoldExpr && ArgExprs.size() == 1 && + isFoldOperator(Tok.getKind()) && NextToken().is(tok::ellipsis)) { +ExprType = FoldExpr; return ParseFoldExpression(ArgExprs[0], T); + } ExprType = SimpleExpr; Result = Actions.ActOnParenListExpr(OpenLoc, Tok.getLocation(), @@ -2553,10 +2560,13 @@ // expressions are parsed correctly. Result = Actions.CorrectDelayedTyposInExpr(Result); } -ExprType = SimpleExpr; -if (isFoldOperator(Tok.getKind()) && NextToken().is(tok::ellipsis)) +if (ExprType >= FoldExpr && isFoldOperator(Tok.getKind()) && +NextToken().is(tok::ellipsis)) { + ExprType = FoldExpr; return ParseFoldExpression(Result, T); +} +ExprType = SimpleExpr; // Don't build a paren expression unless we actually match a ')'. if (!Result.isInvalid() && Tok.is(tok::r_paren)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338170 - Parse a possible trailing postfix expression suffix after a fold expression
Author: rakete Date: Fri Jul 27 14:55:12 2018 New Revision: 338170 URL: http://llvm.org/viewvc/llvm-project?rev=338170=rev Log: Parse a possible trailing postfix expression suffix after a fold expression Summary: This patch allows the parsing of a postfix expression involving a fold expression, which is legal as a fold-expression is a primary-expression. See also https://llvm.org/pr38282 Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D49848 Modified: cfe/trunk/include/clang/Parse/Parser.h cfe/trunk/lib/Parse/ParseExpr.cpp cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp Modified: cfe/trunk/include/clang/Parse/Parser.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=338170=338169=338170=diff == --- cfe/trunk/include/clang/Parse/Parser.h (original) +++ cfe/trunk/include/clang/Parse/Parser.h Fri Jul 27 14:55:12 2018 @@ -1653,6 +1653,7 @@ private: /// ParenParseOption - Control what ParseParenExpression will parse. enum ParenParseOption { SimpleExpr, // Only parse '(' expression ')' +FoldExpr,// Also allow fold-expression CompoundStmt,// Also allow '(' compound-statement ')' CompoundLiteral, // Also allow '(' type-name ')' '{' ... '}' CastExpr // Also allow '(' type-name ')' Modified: cfe/trunk/lib/Parse/ParseExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=338170=338169=338170=diff == --- cfe/trunk/lib/Parse/ParseExpr.cpp (original) +++ cfe/trunk/lib/Parse/ParseExpr.cpp Fri Jul 27 14:55:12 2018 @@ -789,6 +789,10 @@ ExprResult Parser::ParseCastExpression(b // We have parsed the cast-expression and no postfix-expr pieces are // following. return Res; +case FoldExpr: + // We only parsed a fold-expression. There might be postfix-expr pieces + // afterwards; parse them now. + break; } break; @@ -2523,8 +2527,9 @@ Parser::ParseParenExpression(ParenParseO Diag(Tok, diag::err_expected_lbrace_in_compound_literal); return ExprError(); } - } else if (Tok.is(tok::ellipsis) && + } else if (ExprType >= FoldExpr && Tok.is(tok::ellipsis) && isFoldOperator(NextToken().getKind())) { +ExprType = FoldExpr; return ParseFoldExpression(ExprResult(), T); } else if (isTypeCast) { // Parse the expression-list. @@ -2536,9 +2541,11 @@ Parser::ParseParenExpression(ParenParseO if (!ParseSimpleExpressionList(ArgExprs, CommaLocs)) { // FIXME: If we ever support comma expressions as operands to // fold-expressions, we'll need to allow multiple ArgExprs here. - if (ArgExprs.size() == 1 && isFoldOperator(Tok.getKind()) && - NextToken().is(tok::ellipsis)) + if (ExprType >= FoldExpr && ArgExprs.size() == 1 && + isFoldOperator(Tok.getKind()) && NextToken().is(tok::ellipsis)) { +ExprType = FoldExpr; return ParseFoldExpression(ArgExprs[0], T); + } ExprType = SimpleExpr; Result = Actions.ActOnParenListExpr(OpenLoc, Tok.getLocation(), @@ -2553,10 +2560,13 @@ Parser::ParseParenExpression(ParenParseO // expressions are parsed correctly. Result = Actions.CorrectDelayedTyposInExpr(Result); } -ExprType = SimpleExpr; -if (isFoldOperator(Tok.getKind()) && NextToken().is(tok::ellipsis)) +if (ExprType >= FoldExpr && isFoldOperator(Tok.getKind()) && +NextToken().is(tok::ellipsis)) { + ExprType = FoldExpr; return ParseFoldExpression(Result, T); +} +ExprType = SimpleExpr; // Don't build a paren expression unless we actually match a ')'. if (!Result.isInvalid() && Tok.is(tok::r_paren)) Modified: cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp?rev=338170=338169=338170=diff == --- cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp (original) +++ cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp Fri Jul 27 14:55:12 2018 @@ -60,3 +60,29 @@ template constexpr int nested } static_assert(nestedFoldOperator<3, 1>() == 1); + +// A fold-expression is a primary-expression. +template +constexpr auto castSum(Ts... Args) { + return (T)(Args + ...).Value; // expected-error{{member reference base type 'int' is not a structure or union}} +} + +template +constexpr auto simpleSum(Ts... Args) { + return (... + Args).Value; // expected-error{{member reference base type 'int' is not a structure or union}} +} + +void prim() { + castSum(1, 2); + // expected-note@-1{{in instantiation of function template specialization}} + simpleSum(1, 2); + // expected-note@-1{{in instantiation of
[PATCH] D49931: [CUDA][HIP] Allow function-scope static const variable
yaxunl marked an inline comment as done. yaxunl added inline comments. Comment at: lib/Sema/SemaDecl.cpp:11923-11930 + if (getLangOpts().CUDA && + !(VD->hasAttr() || +(VD->getType().isConstQualified() && + !VD->hasAttr() && + !VD->hasAttr())) && CUDADiagIfDeviceCode(VD->getLocation(), diag::err_device_static_local_var) tra wrote: > This is rather convoluted. It would make it somewhat more readable if we > could split CUDADiagIfDeviceCode into its own if(). > > Or, maybe use a lambda + early exit or, perhaps even goto to break down this > huge if: > > ``` > [&](){ >if (VD->hasAttr()) return; >if (VD->getType().isConstQualified() > && !(VD->hasAttr()||VD->hasAttr()) > return; >if (CUDADiagIfDeviceCode(VD->getLocation(), > diag::err_device_static_local_var) > << CurrentCUDATarget())) > VD->setInvalidDecl(); > }() > ``` The lambda looks good. Will use it. Thanks! https://reviews.llvm.org/D49931 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49931: [CUDA][HIP] Allow function-scope static const variable
tra added a comment. Looks OK overall except for the huge `if` below. Comment at: lib/Sema/SemaDecl.cpp:11923-11930 + if (getLangOpts().CUDA && + !(VD->hasAttr() || +(VD->getType().isConstQualified() && + !VD->hasAttr() && + !VD->hasAttr())) && CUDADiagIfDeviceCode(VD->getLocation(), diag::err_device_static_local_var) This is rather convoluted. It would make it somewhat more readable if we could split CUDADiagIfDeviceCode into its own if(). Or, maybe use a lambda + early exit or, perhaps even goto to break down this huge if: ``` [&](){ if (VD->hasAttr()) return; if (VD->getType().isConstQualified() && !(VD->hasAttr()||VD->hasAttr()) return; if (CUDADiagIfDeviceCode(VD->getLocation(), diag::err_device_static_local_var) << CurrentCUDATarget())) VD->setInvalidDecl(); }() ``` https://reviews.llvm.org/D49931 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49439: [Sema] Fix a crash while converting constructors to deduction guides
This revision was automatically updated to reflect the committed changes. Closed by commit rC338165: [Sema] Use a TreeTransform to extract deduction guide parameter types (authored by epilk, committed by ). Changed prior to commit: https://reviews.llvm.org/D49439?vs=157309=157767#toc Repository: rC Clang https://reviews.llvm.org/D49439 Files: lib/Sema/SemaTemplate.cpp test/SemaCXX/cxx1z-class-template-argument-deduction.cpp Index: lib/Sema/SemaTemplate.cpp === --- lib/Sema/SemaTemplate.cpp +++ lib/Sema/SemaTemplate.cpp @@ -1659,6 +1659,23 @@ } namespace { +/// Tree transform to "extract" a transformed type from a class template's +/// constructor to a deduction guide. +class ExtractTypeForDeductionGuide + : public TreeTransform { +public: + typedef TreeTransform Base; + ExtractTypeForDeductionGuide(Sema ) : Base(SemaRef) {} + + TypeSourceInfo *transform(TypeSourceInfo *TSI) { return TransformType(TSI); } + + QualType TransformTypedefType(TypeLocBuilder , TypedefTypeLoc TL) { +return TransformType( +TLB, +TL.getTypedefNameDecl()->getTypeSourceInfo()->getTypeLoc()); + } +}; + /// Transform to convert portions of a constructor declaration into the /// corresponding deduction guide, per C++1z [over.match.class.deduct]p1. struct ConvertConstructorToDeductionGuideTransform { @@ -1880,9 +1897,7 @@ MultiLevelTemplateArgumentList ) { TypeSourceInfo *OldDI = OldParam->getTypeSourceInfo(); TypeSourceInfo *NewDI; -if (!Args.getNumLevels()) - NewDI = OldDI; -else if (auto PackTL = OldDI->getTypeLoc().getAs()) { +if (auto PackTL = OldDI->getTypeLoc().getAs()) { // Expand out the one and only element in each inner pack. Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(SemaRef, 0); NewDI = @@ -1898,23 +1913,17 @@ if (!NewDI) return nullptr; -// Canonicalize the type. This (for instance) replaces references to -// typedef members of the current instantiations with the definitions of -// those typedefs, avoiding triggering instantiation of the deduced type -// during deduction. -// FIXME: It would be preferable to retain type sugar and source -// information here (and handle this in substitution instead). -NewDI = SemaRef.Context.getTrivialTypeSourceInfo( -SemaRef.Context.getCanonicalType(NewDI->getType()), -OldParam->getLocation()); +// Extract the type. This (for instance) replaces references to typedef +// members of the current instantiations with the definitions of those +// typedefs, avoiding triggering instantiation of the deduced type during +// deduction. +NewDI = ExtractTypeForDeductionGuide(SemaRef).transform(NewDI); // Resolving a wording defect, we also inherit default arguments from the // constructor. ExprResult NewDefArg; if (OldParam->hasDefaultArg()) { - NewDefArg = Args.getNumLevels() - ? SemaRef.SubstExpr(OldParam->getDefaultArg(), Args) - : OldParam->getDefaultArg(); + NewDefArg = SemaRef.SubstExpr(OldParam->getDefaultArg(), Args); if (NewDefArg.isInvalid()) return nullptr; } @@ -1929,6 +1938,7 @@ NewDefArg.get()); NewParam->setScopeInfo(OldParam->getFunctionScopeDepth(), OldParam->getFunctionScopeIndex()); +SemaRef.CurrentInstantiationScope->InstantiatedLocal(OldParam, NewParam); return NewParam; } Index: test/SemaCXX/cxx1z-class-template-argument-deduction.cpp === --- test/SemaCXX/cxx1z-class-template-argument-deduction.cpp +++ test/SemaCXX/cxx1z-class-template-argument-deduction.cpp @@ -373,6 +373,35 @@ } } +namespace rdar41330135 { +template struct A {}; +template +struct S { + template + S(T a, U t, A); +}; +template struct D { + D(T t, A); +}; +int f() { + S s(0, 0, A()); + D d(0, A()); +} + +namespace test_dupls { +template struct X {}; +template struct A { + A(T t, X); +}; +A a(0, {}); +template struct B { + B(U u, X); +}; +B b(0, {}); +} + +} + #else // expected-no-diagnostics ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338165 - [Sema] Use a TreeTransform to extract deduction guide parameter types
Author: epilk Date: Fri Jul 27 14:23:48 2018 New Revision: 338165 URL: http://llvm.org/viewvc/llvm-project?rev=338165=rev Log: [Sema] Use a TreeTransform to extract deduction guide parameter types Previously, we just canonicalized the type, but this lead to crashes with parameter types that referred to ParmVarDecls of the constructor. There may be more cases that this TreeTransform needs to handle though, such as a constructor parameter type referring to a member in an unevaluated context. Canonicalization doesn't address these cases either though, so we can address them as-needed in follow-up commits. rdar://41330135 Differential revision: https://reviews.llvm.org/D49439 Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=338165=338164=338165=diff == --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original) +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Jul 27 14:23:48 2018 @@ -1659,6 +1659,23 @@ DeclResult Sema::CheckClassTemplate( } namespace { +/// Tree transform to "extract" a transformed type from a class template's +/// constructor to a deduction guide. +class ExtractTypeForDeductionGuide + : public TreeTransform { +public: + typedef TreeTransform Base; + ExtractTypeForDeductionGuide(Sema ) : Base(SemaRef) {} + + TypeSourceInfo *transform(TypeSourceInfo *TSI) { return TransformType(TSI); } + + QualType TransformTypedefType(TypeLocBuilder , TypedefTypeLoc TL) { +return TransformType( +TLB, +TL.getTypedefNameDecl()->getTypeSourceInfo()->getTypeLoc()); + } +}; + /// Transform to convert portions of a constructor declaration into the /// corresponding deduction guide, per C++1z [over.match.class.deduct]p1. struct ConvertConstructorToDeductionGuideTransform { @@ -1880,9 +1897,7 @@ private: MultiLevelTemplateArgumentList ) { TypeSourceInfo *OldDI = OldParam->getTypeSourceInfo(); TypeSourceInfo *NewDI; -if (!Args.getNumLevels()) - NewDI = OldDI; -else if (auto PackTL = OldDI->getTypeLoc().getAs()) { +if (auto PackTL = OldDI->getTypeLoc().getAs()) { // Expand out the one and only element in each inner pack. Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(SemaRef, 0); NewDI = @@ -1898,23 +1913,17 @@ private: if (!NewDI) return nullptr; -// Canonicalize the type. This (for instance) replaces references to -// typedef members of the current instantiations with the definitions of -// those typedefs, avoiding triggering instantiation of the deduced type -// during deduction. -// FIXME: It would be preferable to retain type sugar and source -// information here (and handle this in substitution instead). -NewDI = SemaRef.Context.getTrivialTypeSourceInfo( -SemaRef.Context.getCanonicalType(NewDI->getType()), -OldParam->getLocation()); +// Extract the type. This (for instance) replaces references to typedef +// members of the current instantiations with the definitions of those +// typedefs, avoiding triggering instantiation of the deduced type during +// deduction. +NewDI = ExtractTypeForDeductionGuide(SemaRef).transform(NewDI); // Resolving a wording defect, we also inherit default arguments from the // constructor. ExprResult NewDefArg; if (OldParam->hasDefaultArg()) { - NewDefArg = Args.getNumLevels() - ? SemaRef.SubstExpr(OldParam->getDefaultArg(), Args) - : OldParam->getDefaultArg(); + NewDefArg = SemaRef.SubstExpr(OldParam->getDefaultArg(), Args); if (NewDefArg.isInvalid()) return nullptr; } @@ -1929,6 +1938,7 @@ private: NewDefArg.get()); NewParam->setScopeInfo(OldParam->getFunctionScopeDepth(), OldParam->getFunctionScopeIndex()); +SemaRef.CurrentInstantiationScope->InstantiatedLocal(OldParam, NewParam); return NewParam; } Modified: cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp?rev=338165=338164=338165=diff == --- cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp (original) +++ cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp Fri Jul 27 14:23:48 2018 @@ -373,6 +373,35 @@ void bar(D& d) { } } +namespace rdar41330135 { +template struct A {}; +template +struct S { + template + S(T a, U t, A); +}; +template struct D { + D(T t, A); +}; +int f() { + S s(0, 0, A()); + D d(0, A()); +} + +namespace test_dupls { +template
[PATCH] D49758: [clangd] allow clients to pass in compilationDatabaseChanges in the 'workspace/didChangeConfiguration' request
arphaman updated this revision to Diff 157762. arphaman marked 2 inline comments as done. arphaman added a comment. Updated patch to address review comments: - The compilation database updated are used only when '-in-memory-compile-commands' flag is used. - It's now possible to set the working directory as well. https://reviews.llvm.org/D49758 Files: clangd/ClangdLSPServer.cpp clangd/ClangdLSPServer.h clangd/GlobalCompilationDatabase.cpp clangd/GlobalCompilationDatabase.h clangd/Protocol.cpp clangd/Protocol.h clangd/tool/ClangdMain.cpp test/clangd/did-change-configuration-params.test Index: test/clangd/did-change-configuration-params.test === --- /dev/null +++ test/clangd/did-change-configuration-params.test @@ -0,0 +1,51 @@ +# RUN: clangd -in-memory-compile-commands -lit-test < %s 2> %t | FileCheck -strict-whitespace %s +# RUN: cat %t | FileCheck --check-prefix=ERR %s +{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} +--- +{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabaseChanges":{"/clangd-test/foo.c": {"workingDirectory":"/clangd-test", "compilationCommand": ["clang", "-c", "foo.c"]} +--- +{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"c","version":1,"text":"int main() { int i; return i; }"}}} +# CHECK: "method": "textDocument/publishDiagnostics", +# CHECK-NEXT: "params": { +# CHECK-NEXT:"diagnostics": [], +# CHECK-NEXT:"uri": "file://{{.*}}/foo.c" +# CHECK-NEXT: } +--- +{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///bar.c","languageId":"c","version":1,"text":"int main() { int i; return i; }"}}} +# CHECK: "method": "textDocument/publishDiagnostics", +# CHECK-NEXT: "params": { +# CHECK-NEXT:"diagnostics": [], +# CHECK-NEXT:"uri": "file://{{.*}}/bar.c" +# CHECK-NEXT: } +--- +{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabaseChanges":{"/clangd-test/foo.c": {"workingDirectory":"/clangd-test2", "compilationCommand": ["clang", "-c", "foo.c", "-Wall", "-Werror"]} +# CHECK: "method": "textDocument/publishDiagnostics", +# CHECK-NEXT: "params": { +# CHECK-NEXT:"diagnostics": [ +# CHECK-NEXT: { +# CHECK-NEXT:"message": "variable 'i' is uninitialized when used here", +# CHECK-NEXT:"range": { +# CHECK-NEXT: "end": { +# CHECK-NEXT:"character": 28, +# CHECK-NEXT:"line": 0 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT:"character": 27, +# CHECK-NEXT:"line": 0 +# CHECK-NEXT: } +# CHECK-NEXT:}, +# CHECK-NEXT:"severity": 1 +# CHECK-NEXT: } +# CHECK-NEXT:], +# CHECK-NEXT:"uri": "file://{{.*}}/foo.c" +# CHECK-NEXT: } +# +# ERR: Updating file /clangd-test/foo.c with command [/clangd-test2] clang -c foo.c -Wall -Werror +# Don't reparse the second file: +# ERR: Skipping rebuild of the AST for /clangd-test/bar.c +--- +{"jsonrpc":"2.0","id":5,"method":"shutdown"} +--- +{"jsonrpc":"2.0","method":"exit"} + + Index: clangd/tool/ClangdMain.cpp === --- clangd/tool/ClangdMain.cpp +++ clangd/tool/ClangdMain.cpp @@ -166,6 +166,11 @@ "eventually. Don't rely on it."), llvm::cl::init(""), llvm::cl::Hidden); +static llvm::cl::opt +InMemoryCompileCommands("in-memory-compile-commands", +llvm::cl::desc("Use an in-memory compile commands"), +llvm::cl::init(false), llvm::cl::Hidden); + int main(int argc, char *argv[]) { llvm::sys::PrintStackTraceOnErrorSignal(argv[0]); llvm::cl::SetVersionPrinter([](llvm::raw_ostream ) { @@ -278,7 +283,9 @@ CCOpts.ShowOrigins = ShowOrigins; // Initialize and run ClangdLSPServer. - ClangdLSPServer LSPServer(Out, CCOpts, CompileCommandsDirPath, Opts); + ClangdLSPServer LSPServer(Out, CCOpts, CompileCommandsDirPath, +/*ShouldUseInMemoryCDB=*/InMemoryCompileCommands, +Opts); constexpr int NoShutdownRequestErrorCode = 1; llvm::set_thread_name("clangd.main"); // Change stdin to binary to not lose \r\n on windows. Index: clangd/Protocol.h === --- clangd/Protocol.h +++ clangd/Protocol.h @@ -419,10 +419,26 @@ }; bool fromJSON(const llvm::json::Value &, DidChangeWatchedFilesParams &); +/// Clangd extension that's used in the 'compilationDatabaseChanges' in +/// workspace/didChangeConfiguration to record updates to the in-memory +/// compilation database. +struct ClangdConfigurationCompilationDatabaseUpdate { + std::string workingDirectory; + std::vector
[PATCH] D49650: Targets/AMDGPU: Don't set fp32-denormals feature for r600
jvesely abandoned this revision. jvesely added a comment. In https://reviews.llvm.org/D49650#1177323, @jvesely wrote: > In https://reviews.llvm.org/D49650#1176336, @arsenm wrote: > > > In https://reviews.llvm.org/D49650#1175461, @jvesely wrote: > > > > > In https://reviews.llvm.org/D49650#1175438, @arsenm wrote: > > > > > > > According to cayman manual, these registers do exist so we should > > > > probably just make the feature accepted on r600 as well > > > > > > > > > sure, that's the way it was before r335942. I assumed the removal was > > > intentional. > > > > > > Probably accidental because nothing in r600 was actually using it > > > given the number of warnings it outputs, I find that unlikely. > @tstellar what was your intention? It's not like someone is going to work on > EG/CM denormals any time soon. > > I don't mind either way. I just want to avoid another round of bikeshedding. https://reviews.llvm.org/D49934 Repository: rC Clang https://reviews.llvm.org/D49650 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47618: __c11_atomic_load's _Atomic can be const
jfb marked an inline comment as done. jfb added a comment. Give the comments, I think this is ready to commit. Repository: rC Clang https://reviews.llvm.org/D47618 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47618: __c11_atomic_load's _Atomic can be const
jfb updated this revision to Diff 157761. jfb added a comment. - Add constant AS pointer test. Repository: rC Clang https://reviews.llvm.org/D47618 Files: lib/Sema/SemaChecking.cpp test/Sema/atomic-ops.c test/SemaOpenCL/atomic-ops.cl Index: test/SemaOpenCL/atomic-ops.cl === --- test/SemaOpenCL/atomic-ops.cl +++ test/SemaOpenCL/atomic-ops.cl @@ -58,7 +58,8 @@ __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_work_group); __opencl_atomic_load(p, memory_order_seq_cst, memory_scope_work_group); __opencl_atomic_load(d, memory_order_seq_cst, memory_scope_work_group); - __opencl_atomic_load(ci, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic _Atomic(int) *') invalid)}} + __opencl_atomic_load(ci, memory_order_seq_cst, memory_scope_work_group); + __opencl_atomic_load(i_c, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to non-constant _Atomic type ('__constant atomic_int *' (aka '__constant _Atomic(int) *') invalid)}} __opencl_atomic_store(i, 1, memory_order_seq_cst, memory_scope_work_group); __opencl_atomic_store(p, 1, memory_order_seq_cst, memory_scope_work_group); @@ -94,7 +95,7 @@ __opencl_atomic_init(ci, 0); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic _Atomic(int) *') invalid)}} __opencl_atomic_store(ci, 0, memory_order_release, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic _Atomic(int) *') invalid)}} - __opencl_atomic_load(ci, memory_order_acquire, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic _Atomic(int) *') invalid)}} + __opencl_atomic_load(ci, memory_order_acquire, memory_scope_work_group); __opencl_atomic_init(, 456); __opencl_atomic_init(, (void*)0); // expected-warning{{incompatible pointer to integer conversion passing '__generic void *' to parameter of type 'int'}} Index: test/Sema/atomic-ops.c === --- test/Sema/atomic-ops.c +++ test/Sema/atomic-ops.c @@ -115,7 +115,7 @@ __c11_atomic_load(i, memory_order_seq_cst); __c11_atomic_load(p, memory_order_seq_cst); __c11_atomic_load(d, memory_order_seq_cst); - __c11_atomic_load(ci, memory_order_seq_cst); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}} + __c11_atomic_load(ci, memory_order_seq_cst); int load_n_1 = __atomic_load_n(I, memory_order_relaxed); int *load_n_2 = __atomic_load_n(P, memory_order_relaxed); @@ -222,7 +222,7 @@ __c11_atomic_init(ci, 0); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}} __c11_atomic_store(ci, 0, memory_order_release); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}} - __c11_atomic_load(ci, memory_order_acquire); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}} + __c11_atomic_load(ci, memory_order_acquire); // Ensure the macros behave appropriately. atomic_int n = ATOMIC_VAR_INIT(123); Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -4347,7 +4347,7 @@ << Ptr->getType() << Ptr->getSourceRange(); return ExprError(); } -if (AtomTy.isConstQualified() || +if ((Form != Load && Form != LoadCopy && AtomTy.isConstQualified()) || AtomTy.getAddressSpace() == LangAS::opencl_constant) { Diag(DRE->getLocStart(), diag::err_atomic_op_needs_non_const_atomic) << (AtomTy.isConstQualified() ? 0 : 1) << Ptr->getType() Index: test/SemaOpenCL/atomic-ops.cl === --- test/SemaOpenCL/atomic-ops.cl +++ test/SemaOpenCL/atomic-ops.cl @@ -58,7 +58,8 @@ __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_work_group); __opencl_atomic_load(p, memory_order_seq_cst, memory_scope_work_group); __opencl_atomic_load(d, memory_order_seq_cst, memory_scope_work_group); - __opencl_atomic_load(ci, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to non-const
[PATCH] D49848: Parse a possible trailing postfix expression suffix after a fold expression
Rakete updated this revision to Diff 157759. Rakete added a comment. Addressed review comments :) Repository: rC Clang https://reviews.llvm.org/D49848 Files: include/clang/Parse/Parser.h lib/Parse/ParseExpr.cpp test/Parser/cxx1z-fold-expressions.cpp Index: test/Parser/cxx1z-fold-expressions.cpp === --- test/Parser/cxx1z-fold-expressions.cpp +++ test/Parser/cxx1z-fold-expressions.cpp @@ -60,3 +60,29 @@ } static_assert(nestedFoldOperator<3, 1>() == 1); + +// A fold-expression is a primary-expression. +template +constexpr auto castSum(Ts... Args) { + return (T)(Args + ...).Value; // expected-error{{member reference base type 'int' is not a structure or union}} +} + +template +constexpr auto simpleSum(Ts... Args) { + return (... + Args).Value; // expected-error{{member reference base type 'int' is not a structure or union}} +} + +void prim() { + castSum(1, 2); + // expected-note@-1{{in instantiation of function template specialization}} + simpleSum(1, 2); + // expected-note@-1{{in instantiation of function template specialization}} + + struct Number { +int Value; +constexpr Number operator+(Number Rhs) const { return {Rhs.Value + Value}; } + }; + + static_assert(castSum(Number{1}, Number{2}) == 3); + static_assert(simpleSum(Number{1}, Number{2}) == 3); +} Index: lib/Parse/ParseExpr.cpp === --- lib/Parse/ParseExpr.cpp +++ lib/Parse/ParseExpr.cpp @@ -787,6 +787,10 @@ // We have parsed the cast-expression and no postfix-expr pieces are // following. return Res; +case FoldExpr: + // We only parsed a fold-expression. There might be postfix-expr pieces + // afterwards; parse them now. + break; } break; @@ -2520,8 +2524,9 @@ Diag(Tok, diag::err_expected_lbrace_in_compound_literal); return ExprError(); } - } else if (Tok.is(tok::ellipsis) && + } else if (ExprType >= FoldExpr && Tok.is(tok::ellipsis) && isFoldOperator(NextToken().getKind())) { +ExprType = FoldExpr; return ParseFoldExpression(ExprResult(), T); } else if (isTypeCast) { // Parse the expression-list. @@ -2533,9 +2538,11 @@ if (!ParseSimpleExpressionList(ArgExprs, CommaLocs)) { // FIXME: If we ever support comma expressions as operands to // fold-expressions, we'll need to allow multiple ArgExprs here. - if (ArgExprs.size() == 1 && isFoldOperator(Tok.getKind()) && - NextToken().is(tok::ellipsis)) + if (ExprType >= FoldExpr && ArgExprs.size() == 1 && + isFoldOperator(Tok.getKind()) && NextToken().is(tok::ellipsis)) { +ExprType = FoldExpr; return ParseFoldExpression(ArgExprs[0], T); + } ExprType = SimpleExpr; Result = Actions.ActOnParenListExpr(OpenLoc, Tok.getLocation(), @@ -2550,10 +2557,13 @@ // expressions are parsed correctly. Result = Actions.CorrectDelayedTyposInExpr(Result); } -ExprType = SimpleExpr; -if (isFoldOperator(Tok.getKind()) && NextToken().is(tok::ellipsis)) +if (ExprType >= FoldExpr && isFoldOperator(Tok.getKind()) && +NextToken().is(tok::ellipsis)) { + ExprType = FoldExpr; return ParseFoldExpression(Result, T); +} +ExprType = SimpleExpr; // Don't build a paren expression unless we actually match a ')'. if (!Result.isInvalid() && Tok.is(tok::r_paren)) Index: include/clang/Parse/Parser.h === --- include/clang/Parse/Parser.h +++ include/clang/Parse/Parser.h @@ -1653,6 +1653,7 @@ /// ParenParseOption - Control what ParseParenExpression will parse. enum ParenParseOption { SimpleExpr, // Only parse '(' expression ')' +FoldExpr,// Also allow fold-expression CompoundStmt,// Also allow '(' compound-statement ')' CompoundLiteral, // Also allow '(' type-name ')' '{' ... '}' CastExpr // Also allow '(' type-name ')' ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49899: Force test/Driver/fuchsia.c(pp) to use lld
greened added a comment. In https://reviews.llvm.org/D49899#1178545, @ruiu wrote: > > The Fuchsia driver relies on lld so invoke clang with -fuse-ld=lld. This > > gets the test passing when the clang default linker is something other than > > lld. > > Does it work if lld is not installed at all? I believe if the driver cannot > find a specified linker, it reports an error instead of trying to execute a > nonexistent file. Not it does not. There does not seem to be a way to disable a test if lld is not available. I couldn't find anything appropriate for a REQUIRES in the test. I would like to leave that work for another time. This at least gets things working a little better. https://reviews.llvm.org/D49899 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49931: [CUDA][HIP] Allow function-scope static const variable
yaxunl added a comment. In https://reviews.llvm.org/D49931#1178720, @tra wrote: > > This patch also allows function-scope static const variable without device > > memory qualifier and emits it as a global variable in constant address > > space. > > What does NVCC do with local static const variables? Both const and non-const static var without device memory qualifier are allowed. It emits it as a global variable in global address space. https://reviews.llvm.org/D49931 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49317: Move __construct_forward (etc.) out of std::allocator_traits.
ldionne added a comment. In https://reviews.llvm.org/D49317#1178767, @Quuxplusone wrote: > @ldionne: I don't know if your "LGTM" is necessarily sufficient to commit > this or not; but either way, I don't have commit privs, so could I ask you > (or someone else) to commit this on my behalf? Thanks! I would not dare say that my LGTM is sufficient. My goal in reviewing this was to lower the barrier for a more senior contributor (Eric/Marshall) to give a definitive LGTM. Repository: rCXX libc++ https://reviews.llvm.org/D49317 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49317: Move __construct_forward (etc.) out of std::allocator_traits.
Quuxplusone added a comment. @ldionne: I don't know if your "LGTM" is necessarily sufficient to commit this or not; but either way, I don't have commit privs, so could I ask you (or someone else) to commit this on my behalf? Thanks! Repository: rCXX libc++ https://reviews.llvm.org/D49317 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49317: Move __construct_forward (etc.) out of std::allocator_traits.
ldionne accepted this revision. ldionne added a comment. This revision is now accepted and ready to land. LGTM Comment at: include/vector:296 +_LIBCPP_INLINE_VISIBILITY +inline void +__copy_construct_forward(_Alloc& __a, _Iter __begin1, _Iter __end1, Quuxplusone wrote: > ldionne wrote: > > Do you really need `inline` here? > I'm actually not sure — and also suddenly not sure if the visibility > attribute should be `_LIBCPP_INLINE_VISIBILITY` or `_LIBCPP_TEMPLATE_VIS`. (I > *think* the latter is only for type templates, though, not function > templates?) However, this is exactly parallel to what we do for `operator<`, > so I think changing it would be gratuitous. If someone wants to remove > `inline` from a bunch of templates, I won't complain, but I also don't want > this PR to be the one that initiates it. > > ``` > template > inline _LIBCPP_INLINE_VISIBILITY > bool > operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& > __y) > { > return _VSTD::lexicographical_compare(__x.begin(), __x.end(), > __y.begin(), __y.end()); > } > ``` > Sure. Then, the current one is correct. You want to be using `_LIBCPP_INLINE_VISIBILITY` here. Actually, you want to be using `_LIBCPP_HIDE_FROM_ABI`, but don't start doing this in this commit -- I'll do a bulk replacement later. Comment at: include/vector:545 +is_trivially_move_constructible<_Tp>::value +> {}; + Quuxplusone wrote: > Louis writes: > > It would be nice if all the TMP required to determine whether to call > > `__move_construct_forward(..., true_type)` or > > `__move_construct_forward(..., false_type)` was done in > > `__move_construct_forward` itself (or a helper). This way, callers wouldn't > > have to do it themselves. > > I know where you're coming from, but I believe that in this case we > definitely *can't* do that, because the whole point of these routines is that > the routine itself can't always tell whether it's supposed to memcpy or not; > the *caller* is the only one with the power to decide that. The decision (in > theory, though not yet in practice, because this particular PR is a pure > refactoring) depends not only on details of `_Tp` and `_Allocator` but also > on the specific call-site: we can memcpy more aggressively at some call-sites > than others, because of information available only to the caller (such as > "this is a relocation operation"). > > See > https://github.com/Quuxplusone/libcxx/commit/e7e5999b01#diff-07c2b769648850d040dcbb07754e5f2fR1076 > , lines 1076 et seq., for how I envision some future caller making the > decisions on a callsite-by-callsite basis. Got it. Repository: rCXX libc++ https://reviews.llvm.org/D49317 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49848: Parse a possible trailing postfix expression suffix after a fold expression
rsmith added a comment. Thanks, I like this approach a lot more. Comment at: include/clang/Parse/Parser.h:1658 +CastExpr,// Also allow '(' type-name ')' +FoldExpr // Also allow fold-expression }; This should be reordered up nearer the top (probably as the second enumerator); when we call `ParseParenExpression` with `ExprType == CastExpr` or `ExprType == CompoundLiteral`, we still want to parse `FoldExpr`s. Comment at: lib/Parse/ParseExpr.cpp:2519-2563 } else if (Tok.is(tok::ellipsis) && isFoldOperator(NextToken().getKind())) { +ExprType = FoldExpr; return ParseFoldExpression(ExprResult(), T); } else if (isTypeCast) { // Parse the expression-list. InMessageExpressionRAIIObject InMessage(*this, false); The cases where we parse a fold-expression should all be guarded by `ExprType >= FoldExpr`. Repository: rC Clang https://reviews.llvm.org/D49848 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49317: Move __construct_forward (etc.) out of std::allocator_traits.
Quuxplusone marked an inline comment as done. Quuxplusone added inline comments. Comment at: include/vector:296 +_LIBCPP_INLINE_VISIBILITY +inline void +__copy_construct_forward(_Alloc& __a, _Iter __begin1, _Iter __end1, ldionne wrote: > Do you really need `inline` here? I'm actually not sure — and also suddenly not sure if the visibility attribute should be `_LIBCPP_INLINE_VISIBILITY` or `_LIBCPP_TEMPLATE_VIS`. (I *think* the latter is only for type templates, though, not function templates?) However, this is exactly parallel to what we do for `operator<`, so I think changing it would be gratuitous. If someone wants to remove `inline` from a bunch of templates, I won't complain, but I also don't want this PR to be the one that initiates it. ``` template inline _LIBCPP_INLINE_VISIBILITY bool operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); } ``` Comment at: include/vector:545 +is_trivially_move_constructible<_Tp>::value +> {}; + Louis writes: > It would be nice if all the TMP required to determine whether to call > `__move_construct_forward(..., true_type)` or `__move_construct_forward(..., > false_type)` was done in `__move_construct_forward` itself (or a helper). > This way, callers wouldn't have to do it themselves. I know where you're coming from, but I believe that in this case we definitely *can't* do that, because the whole point of these routines is that the routine itself can't always tell whether it's supposed to memcpy or not; the *caller* is the only one with the power to decide that. The decision (in theory, though not yet in practice, because this particular PR is a pure refactoring) depends not only on details of `_Tp` and `_Allocator` but also on the specific call-site: we can memcpy more aggressively at some call-sites than others, because of information available only to the caller (such as "this is a relocation operation"). See https://github.com/Quuxplusone/libcxx/commit/e7e5999b01#diff-07c2b769648850d040dcbb07754e5f2fR1076 , lines 1076 et seq., for how I envision some future caller making the decisions on a callsite-by-callsite basis. Repository: rCXX libc++ https://reviews.llvm.org/D49317 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41376: [libcxx] Implement ABI for Clang/GCC vector extension, constructors, copy_from and copy_to.
timshen added inline comments. Comment at: libcxx/include/experimental/simd:1341 // [simd.class] // TODO: implement simd template timshen wrote: > mclow.lists wrote: > > Is this TODO still necessary? > I think so, as some operations are still not implemented, for example > operator++(). For test coverage I turned many of the tests into templates, in the hope not to duplicate the text and increase the coverage. I'm not sure if you like the idea. https://reviews.llvm.org/D41376 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41376: [libcxx] Implement ABI for Clang/GCC vector extension, constructors, copy_from and copy_to.
timshen added a comment. I'm not going to rebase all the succeeding patches immediately onto this one, as it is painful and spamming emails. Rather, I'll only rebase the next patch in the line. So if you review more than one patch ahead (as you already did), you may see some stale patch context. https://reviews.llvm.org/D41376 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41376: [libcxx] Implement ABI for Clang/GCC vector extension, constructors, copy_from and copy_to.
timshen added inline comments. Comment at: libcxx/include/experimental/simd:726 +#if defined(_LIBCPP_COMPILER_CLANG) +#define _SPECIALIZE_VEC_EXT(_TYPE, _NUM_ELEMENT) \ + template <> \ mclow.lists wrote: > When we define user-visible macros in libc++, we prepend them with _LIBCPP_ > to avoid collisions. > Accordingly, `_SPECIALIZE_VEC_EXT` should be named > `_LIBCPP_SPECIALIZE_VEC_EXT` > Well _SPECIALIZE_VEC_EXT and _SPECIALIZE_VEC_EXT_32 are not user-visible, as they are (1) '#undef'ed after all uses, and (2) they start with underscore, so don't collide with existing user-defined macros. Comment at: libcxx/include/experimental/simd:1341 // [simd.class] // TODO: implement simd template mclow.lists wrote: > Is this TODO still necessary? I think so, as some operations are still not implemented, for example operator++(). Comment at: libcxx/test/std/experimental/simd/simd.cons/default.pass.cpp:21 +using namespace std::experimental::parallelism_v2; + +int main() { (void)native_simd(); } mclow.lists wrote: > Do we need any other ctors tested here? `fixed_size_simd` for > example? > Are there any post-conditions on the object created? > > calling `size()` for example? > Yes. Added more. The test space is large and it's hard to test everything. I went "every line of the implementation should be covered" standard with myself, and only had native_simd's default ctor. fixed_size_simd<>'s ctor is exactly implemented by the same line, so I didn't bother. But now the attention is already raised, it doesn't hurt to add more tests. Comment at: libcxx/test/std/experimental/simd/simd.cons/default.pass.cpp:21 +using namespace std::experimental::parallelism_v2; + +int main() { (void)native_simd(); } timshen wrote: > mclow.lists wrote: > > Do we need any other ctors tested here? `fixed_size_simd` for > > example? > > Are there any post-conditions on the object created? > > > > calling `size()` for example? > > > Yes. Added more. > > The test space is large and it's hard to test everything. I went "every line > of the implementation should be covered" standard with myself, and only had > native_simd's default ctor. fixed_size_simd<>'s ctor is exactly implemented > by the same line, so I didn't bother. > > But now the attention is already raised, it doesn't hurt to add more tests. Yes, size() is the post-condition. There is not much beyond that - the elements are not even value initialized. https://reviews.llvm.org/D41376 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41376: [libcxx] Implement ABI for Clang/GCC vector extension, constructors, copy_from and copy_to.
timshen updated this revision to Diff 157751. timshen marked 6 inline comments as done. timshen added a comment. Update based on the comments. https://reviews.llvm.org/D41376 Files: libcxx/include/__config libcxx/include/experimental/__config libcxx/include/experimental/simd libcxx/test/std/experimental/simd/simd.abi/vector_extension.pass.cpp libcxx/test/std/experimental/simd/simd.access/default.pass.cpp libcxx/test/std/experimental/simd/simd.casts/simd_cast.pass.cpp libcxx/test/std/experimental/simd/simd.casts/static_simd_cast.pass.cpp libcxx/test/std/experimental/simd/simd.cons/broadcast.pass.cpp libcxx/test/std/experimental/simd/simd.cons/default.pass.cpp libcxx/test/std/experimental/simd/simd.cons/generator.pass.cpp libcxx/test/std/experimental/simd/simd.cons/load.pass.cpp libcxx/test/std/experimental/simd/simd.mem/load.pass.cpp libcxx/test/std/experimental/simd/simd.mem/store.pass.cpp libcxx/test/std/experimental/simd/simd.traits/abi_for_size.pass.cpp libcxx/test/std/experimental/simd/simd.traits/is_abi_tag.pass.cpp libcxx/test/std/experimental/simd/simd.traits/is_simd.pass.cpp libcxx/test/std/experimental/simd/simd.traits/is_simd_flag_type.pass.cpp libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp Index: libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp === --- libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp +++ libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp @@ -7,127 +7,146 @@ // //===--===// -// UNSUPPORTED: c++98, c++03 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // // // [simd.traits] -// template struct is_simd_mask; -// template inline constexpr bool is_simd_mask_v = is_simd_mask::value; +// template struct ex::is_simd_mask; +// template inline constexpr bool ex::is_simd_mask_v = +// ex::is_simd_mask::value; #include #include #include "test_macros.h" -using namespace std::experimental::parallelism_v2; +namespace ex = std::experimental::parallelism_v2; struct UserType {}; -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); - -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); - -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); - -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); - -static_assert(!is_simd_mask::value, ""); -static_assert(!is_simd_mask::value, ""); -static_assert(!is_simd_mask::value, ""); -static_assert(!is_simd_mask>::value, ""); -static_assert(!is_simd_mask>::value, ""); -static_assert(!is_simd_mask::value, ""); - -#if TEST_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) &&\ -!defined(_LIBCPP_HAS_NO_INLINE_VARIABLES) - -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); - -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, "");
r338158 - [DEBUG_INFO] Fix tests, NFC.
Author: abataev Date: Fri Jul 27 13:16:44 2018 New Revision: 338158 URL: http://llvm.org/viewvc/llvm-project?rev=338158=rev Log: [DEBUG_INFO] Fix tests, NFC. Modified: cfe/trunk/test/Driver/cuda-unsupported-debug-options.cu cfe/trunk/test/Driver/openmp-unsupported-debug-options.c Modified: cfe/trunk/test/Driver/cuda-unsupported-debug-options.cu URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-unsupported-debug-options.cu?rev=338158=338157=338158=diff == --- cfe/trunk/test/Driver/cuda-unsupported-debug-options.cu (original) +++ cfe/trunk/test/Driver/cuda-unsupported-debug-options.cu Fri Jul 27 13:16:44 2018 @@ -1,6 +1,7 @@ // REQUIRES: clang-driver // REQUIRES: x86-registered-target // REQUIRES: nvptx-registered-target +// REQUIRES: zlib // RUN: %clang -### -target x86_64-linux-gnu -c %s -g -gz 2>&1 | FileCheck %s // RUN: %clang -### -target x86_64-linux-gnu -c %s -gdwarf -fdebug-info-for-profiling 2>&1 | FileCheck %s Modified: cfe/trunk/test/Driver/openmp-unsupported-debug-options.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openmp-unsupported-debug-options.c?rev=338158=338157=338158=diff == --- cfe/trunk/test/Driver/openmp-unsupported-debug-options.c (original) +++ cfe/trunk/test/Driver/openmp-unsupported-debug-options.c Fri Jul 27 13:16:44 2018 @@ -1,6 +1,7 @@ // REQUIRES: clang-driver // REQUIRES: x86-registered-target // REQUIRES: nvptx-registered-target +// REQUIRES: zlib // RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -gz 2>&1 | FileCheck %s // RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -gdwarf -fdebug-info-for-profiling 2>&1 | FileCheck %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49931: [CUDA][HIP] Allow function-scope static const variable
tra added a comment. > This patch also allows function-scope static const variable without device > memory qualifier and emits it as a global variable in constant address space. What does NVCC do with local static const variables? https://reviews.llvm.org/D49931 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49927: [libc++] Exclude posix_l/strtonum fallback inclusion for newlib > 2.4
This revision was automatically updated to reflect the committed changes. Closed by commit rL338157: [libc++] Exclude posix_l/strtonum fallback inclusion for newlib 2.4 (authored by rupprecht, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D49927 Files: libcxx/trunk/include/support/newlib/xlocale.h Index: libcxx/trunk/include/support/newlib/xlocale.h === --- libcxx/trunk/include/support/newlib/xlocale.h +++ libcxx/trunk/include/support/newlib/xlocale.h @@ -19,9 +19,9 @@ #if !defined(__NEWLIB__) || __NEWLIB__ < 2 || \ __NEWLIB__ == 2 && __NEWLIB_MINOR__ < 5 #include -#endif #include #include +#endif #endif // _NEWLIB_VERSION Index: libcxx/trunk/include/support/newlib/xlocale.h === --- libcxx/trunk/include/support/newlib/xlocale.h +++ libcxx/trunk/include/support/newlib/xlocale.h @@ -19,9 +19,9 @@ #if !defined(__NEWLIB__) || __NEWLIB__ < 2 || \ __NEWLIB__ == 2 && __NEWLIB_MINOR__ < 5 #include -#endif #include #include +#endif #endif // _NEWLIB_VERSION ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r338157 - [libc++] Exclude posix_l/strtonum fallback inclusion for newlib > 2.4
Author: rupprecht Date: Fri Jul 27 13:02:58 2018 New Revision: 338157 URL: http://llvm.org/viewvc/llvm-project?rev=338157=rev Log: [libc++] Exclude posix_l/strtonum fallback inclusion for newlib > 2.4 Summary: [libc++] Exclude posix_l/strtonum fallback inclusion for newlib > 2.4 r338122 changed the linkage of some methods which revealed an existing ODR violation, e.g.: projects/libcxx/include/support/xlocale/__posix_l_fallback.h:83:38: error: 'internal_linkage' attribute does not appear on the first declaration of 'iswcntrl_l' inline _LIBCPP_INLINE_VISIBILITY int iswcntrl_l(wint_t c, locale_t) { ^ lib/include/wctype.h:55:12: note: previous definition is here extern int iswcntrl_l (wint_t, locale_t); These were added to newlib in 2.4 [1] [2], so move them to the already existing include guard. [1] https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=commit;h=238455adfab4f8070ac65400aac22bb8a9e502fc [2] https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=commit;h=8493c1631643fada62384768408852bc0fa6ff44 Reviewers: ldionne, rsmith, EricWF Subscribers: christof, cfe-commits Differential Revision: https://reviews.llvm.org/D49927 Modified: libcxx/trunk/include/support/newlib/xlocale.h Modified: libcxx/trunk/include/support/newlib/xlocale.h URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/newlib/xlocale.h?rev=338157=338156=338157=diff == --- libcxx/trunk/include/support/newlib/xlocale.h (original) +++ libcxx/trunk/include/support/newlib/xlocale.h Fri Jul 27 13:02:58 2018 @@ -19,9 +19,9 @@ #if !defined(__NEWLIB__) || __NEWLIB__ < 2 || \ __NEWLIB__ == 2 && __NEWLIB_MINOR__ < 5 #include -#endif #include #include +#endif #endif // _NEWLIB_VERSION ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49317: Move __construct_forward (etc.) out of std::allocator_traits.
ldionne added a comment. It would be nice if all the TMP required to determine whether to call `__move_construct_forward(..., true_type)` or `__move_construct_forward(..., false_type)` was done in `__move_construct_forward` itself (or a helper). This way, callers wouldn't have to do it themselves. For example, vector currently needs typedef integral_constant::value && (is_same<_ForwardIterator, _Tp*>::value || is_same<_ForwardIterator, const _Tp*>::value || is_same<_ForwardIterator, pointer>::value) > __copy_via_memcpy; ... _VSTD::__copy_construct_forward(__a, __first, __last, this->__end_, __copy_via_memcpy()); It would be neat if we could just do VSTD::__copy_construct_forward(__a, __first, __last, this->__end_); and have it dispatched correctly from there. That would make those functions potentially useful elsewhere. Does that make sense? Otherwise this LGTM. Comment at: include/vector:296 +_LIBCPP_INLINE_VISIBILITY +inline void +__copy_construct_forward(_Alloc& __a, _Iter __begin1, _Iter __end1, Do you really need `inline` here? Repository: rCXX libc++ https://reviews.llvm.org/D49317 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49148: [DEBUGINFO] Disable unsupported debug info options for NVPTX target.
This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rC338155: [DEBUGINFO] Disable unsupported debug info options for NVPTX target. (authored by ABataev, committed by ). Changed prior to commit: https://reviews.llvm.org/D49148?vs=157563=157744#toc Repository: rC Clang https://reviews.llvm.org/D49148 Files: include/clang/Basic/DiagnosticDriverKinds.td include/clang/Basic/DiagnosticGroups.td include/clang/Driver/ToolChain.h lib/Driver/ToolChains/Clang.cpp lib/Driver/ToolChains/Cuda.cpp lib/Driver/ToolChains/Cuda.h test/Driver/cuda-dwarf-2.cu test/Driver/cuda-unsupported-debug-options.cu test/Driver/openmp-offload-gpu.c test/Driver/openmp-unsupported-debug-options.c Index: test/Driver/openmp-unsupported-debug-options.c === --- test/Driver/openmp-unsupported-debug-options.c +++ test/Driver/openmp-unsupported-debug-options.c @@ -0,0 +1,21 @@ +// REQUIRES: clang-driver +// REQUIRES: x86-registered-target +// REQUIRES: nvptx-registered-target + +// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -gz 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -gdwarf -fdebug-info-for-profiling 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -gdwarf-2 -gsplit-dwarf 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -gdwarf-3 -glldb 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -gdwarf-4 -gcodeview 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -gdwarf-5 -gmodules 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -ggdb -gembed-source -gdwarf-5 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -ggdb1 -fdebug-macro 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -ggdb2 -ggnu-pubnames 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -ggdb3 -gdwarf-aranges 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -gcolumn-info -fdebug-types-section 2>&1 | FileCheck %s +// CHECK: debug information option '{{-gz|-fdebug-info-for-profiling|-gsplit-dwarf|-glldb|-gcodeview|-gmodules|-gembed-source|-fdebug-macro|-ggnu-pubnames|-gdwarf-aranges|-fdebug-types-section}}' is not supported for target 'nvptx64-nvidia-cuda' [-Wunsupported-target-opt] +// CHECK-NOT: debug information option '{{.*}}' is not supported for target 'x86 +// CHECK: "-triple" "nvptx64-nvidia-cuda" +// CHECK-NOT: {{-compress-debug|-fdebug-info-for-profiling|split-dwarf|lldb|codeview|module-format|embed-source|debug-info-macro|gnu-pubnames|generate-arange-section|generate-type-units}} +// CHECK: "-triple" "x86_64 +// CHECK-SAME: {{-compress-debug|-fdebug-info-for-profiling|split-dwarf|lldb|codeview|module-format|embed-source|debug-info-macro|gnu-pubnames|generate-arange-section|generate-type-units}} Index: test/Driver/cuda-dwarf-2.cu === --- test/Driver/cuda-dwarf-2.cu +++ test/Driver/cuda-dwarf-2.cu @@ -15,6 +15,8 @@ // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -gline-tables-only -O2 --cuda-noopt-device-debug 2>&1 | \ // RUN: FileCheck %s -check-prefix NO_DEBUG -check-prefix LINE_TABLE +// NO_DEBUG-NOT: warning: debug +// LINE_TABLE-NOT: warning: debug // NO_DEBUG: ptxas // NO_DEBUG-NOT: "-g" // LINE_TABLE: "-lineinfo" @@ -36,6 +38,7 @@ // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -ggdb3 -O3 --cuda-noopt-device-debug 2>&1 | \ // RUN: FileCheck %s -check-prefix HAS_DEBUG +// HAS_DEBUG-NOT: warning: debug // HAS_DEBUG: "-fcuda-is-device" // HAS_DEBUG-SAME: "-dwarf-version=2" // HAS_DEBUG: ptxas Index: test/Driver/cuda-unsupported-debug-options.cu === --- test/Driver/cuda-unsupported-debug-options.cu +++ test/Driver/cuda-unsupported-debug-options.cu @@ -0,0 +1,21 @@ +// REQUIRES: clang-driver +// REQUIRES: x86-registered-target +// REQUIRES: nvptx-registered-target + +// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -gz 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -c %s -gdwarf -fdebug-info-for-profiling 2>&1 | FileCheck %s +// RUN: %clang
r338155 - [DEBUGINFO] Disable unsupported debug info options for NVPTX target.
Author: abataev Date: Fri Jul 27 12:45:14 2018 New Revision: 338155 URL: http://llvm.org/viewvc/llvm-project?rev=338155=rev Log: [DEBUGINFO] Disable unsupported debug info options for NVPTX target. Summary: Some targets support only default set of the debug options and do not support additional debug options, like NVPTX target. Patch introduced virtual function supportsDebugInfoOptions() that can be overloaded by the toolchain, checks if the target supports some debug options and emits warning when an unsupported debug option is found. Reviewers: echristo Subscribers: aprantl, JDevlieghere, cfe-commits Differential Revision: https://reviews.llvm.org/D49148 Added: cfe/trunk/test/Driver/cuda-unsupported-debug-options.cu cfe/trunk/test/Driver/openmp-unsupported-debug-options.c Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td cfe/trunk/include/clang/Basic/DiagnosticGroups.td cfe/trunk/include/clang/Driver/ToolChain.h cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/lib/Driver/ToolChains/Cuda.cpp cfe/trunk/lib/Driver/ToolChains/Cuda.h cfe/trunk/test/Driver/cuda-dwarf-2.cu cfe/trunk/test/Driver/openmp-offload-gpu.c Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=338155=338154=338155=diff == --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Jul 27 12:45:14 2018 @@ -226,6 +226,9 @@ def warn_ignored_clang_option : Warning< def warn_drv_unsupported_opt_for_target : Warning< "optimization flag '%0' is not supported for target '%1'">, InGroup; +def warn_drv_unsupported_debug_info_opt_for_target : Warning< + "debug information option '%0' is not supported for target '%1'">, + InGroup; def warn_c_kext : Warning< "ignoring -fapple-kext which is valid for C++ and Objective-C++ only">; def warn_drv_input_file_unused : Warning< Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=338155=338154=338155=diff == --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jul 27 12:45:14 2018 @@ -72,6 +72,7 @@ def UnsupportedNan : DiagGroup<"unsuppor def UnsupportedAbs : DiagGroup<"unsupported-abs">; def UnsupportedCB : DiagGroup<"unsupported-cb">; def UnsupportedGPOpt : DiagGroup<"unsupported-gpopt">; +def UnsupportedTargetOpt : DiagGroup<"unsupported-target-opt">; def NonLiteralNullConversion : DiagGroup<"non-literal-null-conversion">; def NullConversion : DiagGroup<"null-conversion">; def ImplicitConversionFloatingPointToBool : Modified: cfe/trunk/include/clang/Driver/ToolChain.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=338155=338154=338155=diff == --- cfe/trunk/include/clang/Driver/ToolChain.h (original) +++ cfe/trunk/include/clang/Driver/ToolChain.h Fri Jul 27 12:45:14 2018 @@ -413,6 +413,11 @@ public: return llvm::DebuggerKind::GDB; } + /// Does this toolchain supports given debug info option or not. + virtual bool supportsDebugInfoOption(const llvm::opt::Arg *) const { +return true; + } + /// GetExceptionModel - Return the tool chain exception model. virtual llvm::ExceptionHandling GetExceptionModel(const llvm::opt::ArgList ) const; Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=338155=338154=338155=diff == --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Jul 27 12:45:14 2018 @@ -919,34 +919,46 @@ static void RenderDebugEnablingArgs(cons } } +static bool checkDebugInfoOption(const Arg *A, const ArgList , + const Driver , const ToolChain ) { + assert(A && "Expected non-nullptr argument."); + if (TC.supportsDebugInfoOption(A)) +return true; + D.Diag(diag::warn_drv_unsupported_debug_info_opt_for_target) + << A->getAsString(Args) << TC.getTripleString(); + return false; +} + static void RenderDebugInfoCompressionArgs(const ArgList , ArgStringList , - const Driver ) { + const Driver , + const ToolChain ) { const Arg *A = Args.getLastArg(options::OPT_gz, options::OPT_gz_EQ); if (!A) return; + if (checkDebugInfoOption(A, Args, D,
[PATCH] D49931: [CUDA][HIP] Allow function-scope static const variable
yaxunl updated this revision to Diff 157740. yaxunl edited the summary of this revision. yaxunl added a comment. update diagnostic message. https://reviews.llvm.org/D49931 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/CodeGen/CodeGenModule.cpp lib/Sema/SemaDecl.cpp test/CodeGenCUDA/device-var-init.cu test/SemaCUDA/device-var-init.cu Index: test/SemaCUDA/device-var-init.cu === --- test/SemaCUDA/device-var-init.cu +++ test/SemaCUDA/device-var-init.cu @@ -207,17 +207,17 @@ // expected-error@-1 {{initialization is not supported for __shared__ variables.}} static __device__ int ds; - // expected-error@-1 {{within a __device__ function, only __shared__ variables may be marked 'static'}} + // expected-error@-1 {{within a __device__ function, only __shared__ variables or const variables without device memory qualifier may be marked 'static'}} static __constant__ int dc; - // expected-error@-1 {{within a __device__ function, only __shared__ variables may be marked 'static'}} + // expected-error@-1 {{within a __device__ function, only __shared__ variables or const variables without device memory qualifier may be marked 'static'}} static int v; - // expected-error@-1 {{within a __device__ function, only __shared__ variables may be marked 'static'}} + // expected-error@-1 {{within a __device__ function, only __shared__ variables or const variables without device memory qualifier may be marked 'static'}} } __host__ __device__ void hd_sema() { static int x = 42; #ifdef __CUDA_ARCH__ - // expected-error@-2 {{within a __host__ __device__ function, only __shared__ variables may be marked 'static'}} + // expected-error@-2 {{within a __host__ __device__ function, only __shared__ variables or const variables without device memory qualifier may be marked 'static'}} #endif } Index: test/CodeGenCUDA/device-var-init.cu === --- test/CodeGenCUDA/device-var-init.cu +++ test/CodeGenCUDA/device-var-init.cu @@ -112,6 +112,9 @@ // CHECK: @_ZZ2dfvE4s_ec = internal addrspace(3) global %struct.EC undef // CHECK: @_ZZ2dfvE5s_etc = internal addrspace(3) global %struct.ETC undef +// CHECK: @_ZZ2dfvE11const_array = internal addrspace(4) constant [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5] +// CHECK: @_ZZ2dfvE9const_int = internal addrspace(4) constant i32 123 + // We should not emit global initializers for device-side variables. // CHECK-NOT: @__cxx_global_var_init @@ -234,6 +237,9 @@ static __shared__ ETC s_etc; // CHECK-NOT: call void @_ZN3ETCC1IJEEEDpT_(%struct.ETC* addrspacecast (%struct.ETC addrspace(3)* @_ZZ2dfvE5s_etc to %struct.ETC*)) + static const int const_array[] = {1, 2, 3, 4, 5}; + static const int const_int = 123; + // anchor point separating constructors and destructors df(); // CHECK: call void @_Z2dfv() Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -11914,10 +11914,17 @@ NewAttr->setInherited(true); VD->addAttr(NewAttr); } - // CUDA E.2.9.4: Within the body of a __device__ or __global__ - // function, only __shared__ variables may be declared with - // static storage class. - if (getLangOpts().CUDA && !VD->hasAttr() && + // CUDA 8.0 E.3.9.4: Within the body of a __device__ or __global__ + // function, only __shared__ variables or variables without any device + // memory qualifiers may be declared with static storage class. + // Note: It is unclear how a function-scope non-const static variable + // without device memory qualifier is implemented, therefore only static + // const variable without device memory qualifier is allowed. + if (getLangOpts().CUDA && + !(VD->hasAttr() || +(VD->getType().isConstQualified() && + !VD->hasAttr() && + !VD->hasAttr())) && CUDADiagIfDeviceCode(VD->getLocation(), diag::err_device_static_local_var) << CurrentCUDATarget()) Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -3176,6 +3176,10 @@ return LangAS::cuda_constant; else if (D && D->hasAttr()) return LangAS::cuda_shared; +else if (D && D->hasAttr()) + return LangAS::cuda_device; +else if (D && D->getType().isConstQualified()) + return LangAS::cuda_constant; else return LangAS::cuda_device; } Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -7121,7 +7121,8 @@ "initialization is not supported for __shared__
[PATCH] D49931: [CUDA][HIP] Allow function-scope static const variable
yaxunl created this revision. yaxunl added reviewers: tra, rjmccall. CUDA 8.0 E.3.9.4 says: Within the body of a __device__ or __global__ function, only __shared__ variables or variables without any device memory qualifiers may be declared with static storage class. It is unclear how a function-scope non-const static variable without device memory qualifier is implemented, therefore only static const variable without device memory qualifier is allowed, which can be emitted as a global variable in constant address space. Currently clang only allows function-scope static variable with `__shared__` qualifier. This patch also allows function-scope static const variable without device memory qualifier and emits it as a global variable in constant address space. https://reviews.llvm.org/D49931 Files: lib/CodeGen/CodeGenModule.cpp lib/Sema/SemaDecl.cpp test/CodeGenCUDA/device-var-init.cu Index: test/CodeGenCUDA/device-var-init.cu === --- test/CodeGenCUDA/device-var-init.cu +++ test/CodeGenCUDA/device-var-init.cu @@ -112,6 +112,9 @@ // CHECK: @_ZZ2dfvE4s_ec = internal addrspace(3) global %struct.EC undef // CHECK: @_ZZ2dfvE5s_etc = internal addrspace(3) global %struct.ETC undef +// CHECK: @_ZZ2dfvE11const_array = internal addrspace(4) constant [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5] +// CHECK: @_ZZ2dfvE9const_int = internal addrspace(4) constant i32 123 + // We should not emit global initializers for device-side variables. // CHECK-NOT: @__cxx_global_var_init @@ -234,6 +237,9 @@ static __shared__ ETC s_etc; // CHECK-NOT: call void @_ZN3ETCC1IJEEEDpT_(%struct.ETC* addrspacecast (%struct.ETC addrspace(3)* @_ZZ2dfvE5s_etc to %struct.ETC*)) + static const int const_array[] = {1, 2, 3, 4, 5}; + static const int const_int = 123; + // anchor point separating constructors and destructors df(); // CHECK: call void @_Z2dfv() Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -11914,10 +11914,15 @@ NewAttr->setInherited(true); VD->addAttr(NewAttr); } - // CUDA E.2.9.4: Within the body of a __device__ or __global__ - // function, only __shared__ variables may be declared with - // static storage class. - if (getLangOpts().CUDA && !VD->hasAttr() && + // CUDA 8.0 E.3.9.4: Within the body of a __device__ or __global__ + // function, only __shared__ variables or variables without any device + // memory qualifiers may be declared with static storage class. + // Note: It is unclear how a function-scope non-const static variable + // without device memory qualifier is implemented, therefore only static + // const variable without device memory qualifier is allowed. + if (getLangOpts().CUDA && + !(VD->hasAttr() || +VD->getType().isConstQualified()) && CUDADiagIfDeviceCode(VD->getLocation(), diag::err_device_static_local_var) << CurrentCUDATarget()) Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -3176,6 +3176,10 @@ return LangAS::cuda_constant; else if (D && D->hasAttr()) return LangAS::cuda_shared; +else if (D && D->hasAttr()) + return LangAS::cuda_device; +else if (D && D->getType().isConstQualified()) + return LangAS::cuda_constant; else return LangAS::cuda_device; } Index: test/CodeGenCUDA/device-var-init.cu === --- test/CodeGenCUDA/device-var-init.cu +++ test/CodeGenCUDA/device-var-init.cu @@ -112,6 +112,9 @@ // CHECK: @_ZZ2dfvE4s_ec = internal addrspace(3) global %struct.EC undef // CHECK: @_ZZ2dfvE5s_etc = internal addrspace(3) global %struct.ETC undef +// CHECK: @_ZZ2dfvE11const_array = internal addrspace(4) constant [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5] +// CHECK: @_ZZ2dfvE9const_int = internal addrspace(4) constant i32 123 + // We should not emit global initializers for device-side variables. // CHECK-NOT: @__cxx_global_var_init @@ -234,6 +237,9 @@ static __shared__ ETC s_etc; // CHECK-NOT: call void @_ZN3ETCC1IJEEEDpT_(%struct.ETC* addrspacecast (%struct.ETC addrspace(3)* @_ZZ2dfvE5s_etc to %struct.ETC*)) + static const int const_array[] = {1, 2, 3, 4, 5}; + static const int const_int = 123; + // anchor point separating constructors and destructors df(); // CHECK: call void @_Z2dfv() Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -11914,10 +11914,15 @@ NewAttr->setInherited(true); VD->addAttr(NewAttr); } - // CUDA E.2.9.4: Within the body of a
[PATCH] D49927: [libc++] Exclude posix_l/strtonum fallback inclusion for newlib > 2.4
rupprecht added a comment. In https://reviews.llvm.org/D49927#1178659, @ldionne wrote: > Just to make sure I understand properly: this means we will use newlib's > implementation of `iswcntrl_l` & friends instead of our own emulation (which > is an ODR violation currently going unnoticed)? And this is OK because newlib > provides `iswcntrl_l` & friends starting at version 2.4. Yes, that's correct. I clarified the description: when the methods were added, the tree was configured with NEWLIB_MINOR_VERSION = 4, meaning this wasn't released until the next version, newlib 2.5. > This is my understanding. If it is correct, then LGTM. Repository: rCXX libc++ https://reviews.llvm.org/D49927 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49927: [libc++] Exclude posix_l/strtonum fallback inclusion for newlib > 2.4
jyknight accepted this revision. jyknight added a comment. This revision is now accepted and ready to land. Typo in commit message? They were added to 2.5, not 2.4 (the code is right, just the comment is wrong). Repository: rCXX libc++ https://reviews.llvm.org/D49927 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49930: [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL
scott.linder created this revision. scott.linder added reviewers: Anastasia, echristo. Herald added subscribers: cfe-commits, JDevlieghere, aprantl, yaxunl. OpenCL block literal structs have different fields which are now correctly identified in the debug info. Repository: rC Clang https://reviews.llvm.org/D49930 Files: lib/CodeGen/CGDebugInfo.cpp test/CodeGenOpenCL/blocks.cl Index: test/CodeGenOpenCL/blocks.cl === --- test/CodeGenOpenCL/blocks.cl +++ test/CodeGenOpenCL/blocks.cl @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -O0 -triple spir-unknown-unknown | FileCheck -check-prefixes=COMMON,SPIR %s -// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -O0 -triple amdgcn-amd-amdhsa | FileCheck -check-prefixes=COMMON,AMDGCN %s +// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -O0 -debug-info-kind=limited -triple spir-unknown-unknown | FileCheck -check-prefixes=COMMON,SPIR %s +// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -O0 -debug-info-kind=limited -triple amdgcn-amd-amdhsa | FileCheck -check-prefixes=COMMON,AMDGCN %s // COMMON: @__block_literal_global = internal addrspace(1) constant { i32, i32 } { i32 8, i32 4 } // COMMON-NOT: .str @@ -60,3 +60,11 @@ // AMDGCN: %[[block_capture:.*]] = load i32, i32* %[[block_capture_addr]] // COMMON-NOT: define{{.*}}@__foo_block_invoke_kernel + +// COMMON: !DIDerivedType(tag: DW_TAG_member, name: "__size" +// COMMON: !DIDerivedType(tag: DW_TAG_member, name: "__align" + +// COMMON-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__isa" +// COMMON-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__flags" +// COMMON-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__reserved" +// COMMON-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__FuncPtr" Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -971,20 +971,25 @@ auto *DescTy = DBuilder.createPointerType(EltTy, Size); FieldOffset = 0; - FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); - EltTys.push_back(CreateMemberType(Unit, FType, "__isa", )); - FType = CGM.getContext().IntTy; - EltTys.push_back(CreateMemberType(Unit, FType, "__flags", )); - EltTys.push_back(CreateMemberType(Unit, FType, "__reserved", )); - FType = CGM.getContext().getPointerType(Ty->getPointeeType()); - EltTys.push_back(CreateMemberType(Unit, FType, "__FuncPtr", )); - - FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); - FieldSize = CGM.getContext().getTypeSize(Ty); - FieldAlign = CGM.getContext().getTypeAlign(Ty); - EltTys.push_back(DBuilder.createMemberType( - Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign, FieldOffset, - llvm::DINode::FlagZero, DescTy)); + if (CGM.getLangOpts().OpenCL) { +FType = CGM.getContext().IntTy; +EltTys.push_back(CreateMemberType(Unit, FType, "__size", )); +EltTys.push_back(CreateMemberType(Unit, FType, "__align", )); + } else { +FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); +EltTys.push_back(CreateMemberType(Unit, FType, "__isa", )); +FType = CGM.getContext().IntTy; +EltTys.push_back(CreateMemberType(Unit, FType, "__flags", )); +EltTys.push_back(CreateMemberType(Unit, FType, "__reserved", )); +FType = CGM.getContext().getPointerType(Ty->getPointeeType()); +EltTys.push_back(CreateMemberType(Unit, FType, "__FuncPtr", )); +FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); +FieldSize = CGM.getContext().getTypeSize(Ty); +FieldAlign = CGM.getContext().getTypeAlign(Ty); +EltTys.push_back(DBuilder.createMemberType( +Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign, FieldOffset, +llvm::DINode::FlagZero, DescTy)); + } FieldOffset += FieldSize; Elements = DBuilder.getOrCreateArray(EltTys); @@ -3847,26 +3852,35 @@ CGM.getDataLayout().getStructLayout(block.StructureType); SmallVector fields; - fields.push_back(createFieldType("__isa", C.VoidPtrTy, loc, AS_public, - blockLayout->getElementOffsetInBits(0), - tunit, tunit)); - fields.push_back(createFieldType("__flags", C.IntTy, loc, AS_public, - blockLayout->getElementOffsetInBits(1), - tunit, tunit)); - fields.push_back(createFieldType("__reserved", C.IntTy, loc, AS_public, - blockLayout->getElementOffsetInBits(2), - tunit, tunit)); - auto *FnTy = block.getBlockExpr()->getFunctionType(); - auto FnPtrType = CGM.getContext().getPointerType(FnTy->desugar()); - fields.push_back(createFieldType("__FuncPtr", FnPtrType, loc, AS_public, - blockLayout->getElementOffsetInBits(3), -
[PATCH] D49148: [DEBUGINFO] Disable unsupported debug info options for NVPTX target.
ABataev added a comment. Eric accepted the patch offline. Repository: rC Clang https://reviews.llvm.org/D49148 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49927: [libc++] Exclude posix_l/strtonum fallback inclusion for newlib > 2.4
ldionne added a comment. Just to make sure I understand properly: this means we will use newlib's implementation of `iswcntrl_l` & friends instead of our own emulation (which is an ODR violation currently going unnoticed)? And this is OK because newlib provides `iswcntrl_l` & friends starting at version 2.4. This is my understanding. If it is correct, then LGTM. Repository: rCXX libc++ https://reviews.llvm.org/D49927 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43745: Fix cppcoreguidelines-pro-bounds-pointer-arithmetic not working for functions with auto return specifier.
mgehre added a comment. Does it also work with lambdas (being implicitly auto) that return pointers? A test case for that would be nice. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D43745 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49927: [libc++] Exclude posix_l/strtonum fallback inclusion for newlib > 2.4
rupprecht created this revision. rupprecht added reviewers: ldionne, rsmith. Herald added a reviewer: EricWF. Herald added subscribers: cfe-commits, christof. [libc++] Exclude posix_l/strtonum fallback inclusion for newlib > 2.4 r338122 changed the linkage of some methods which revealed an existing ODR violation, e.g.: projects/libcxx/include/support/xlocale/__posix_l_fallback.h:83:38: error: 'internal_linkage' attribute does not appear on the first declaration of 'iswcntrl_l' inline _LIBCPP_INLINE_VISIBILITY int iswcntrl_l(wint_t c, locale_t) { ^ lib/include/wctype.h:55:12: note: previous definition is here extern int iswcntrl_l (wint_t, locale_t); These were added to newlib in 2.4 [1] [2], so move them to the already existing include guard. [1] https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=commit;h=238455adfab4f8070ac65400aac22bb8a9e502fc [2] https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=commit;h=8493c1631643fada62384768408852bc0fa6ff44 Repository: rCXX libc++ https://reviews.llvm.org/D49927 Files: include/support/newlib/xlocale.h Index: include/support/newlib/xlocale.h === --- include/support/newlib/xlocale.h +++ include/support/newlib/xlocale.h @@ -19,9 +19,9 @@ #if !defined(__NEWLIB__) || __NEWLIB__ < 2 || \ __NEWLIB__ == 2 && __NEWLIB_MINOR__ < 5 #include -#endif #include #include +#endif #endif // _NEWLIB_VERSION Index: include/support/newlib/xlocale.h === --- include/support/newlib/xlocale.h +++ include/support/newlib/xlocale.h @@ -19,9 +19,9 @@ #if !defined(__NEWLIB__) || __NEWLIB__ < 2 || \ __NEWLIB__ == 2 && __NEWLIB_MINOR__ < 5 #include -#endif #include #include +#endif #endif // _NEWLIB_VERSION ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49920: [clangd] [WIP] Find references of local symbols
malaperle planned changes to this revision. malaperle added a comment. Needs tests. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D49920 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49920: [clangd] [WIP] Find references of local symbols
malaperle updated this revision to Diff 157732. malaperle added a comment. Fix silly bug I introduced in last minute clean-up. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D49920 Files: clangd/ClangdLSPServer.cpp clangd/ClangdLSPServer.h clangd/ClangdServer.cpp clangd/ClangdServer.h clangd/Protocol.cpp clangd/Protocol.h clangd/ProtocolHandlers.cpp clangd/ProtocolHandlers.h clangd/XRefs.cpp clangd/XRefs.h test/clangd/initialize-params-invalid.test test/clangd/initialize-params.test Index: test/clangd/initialize-params.test === --- test/clangd/initialize-params.test +++ test/clangd/initialize-params.test @@ -29,6 +29,7 @@ # CHECK-NEXT:] # CHECK-NEXT: }, # CHECK-NEXT: "hoverProvider": true, +# CHECK-NEXT: "referencesProvider": true, # CHECK-NEXT: "renameProvider": true, # CHECK-NEXT: "signatureHelpProvider": { # CHECK-NEXT:"triggerCharacters": [ Index: test/clangd/initialize-params-invalid.test === --- test/clangd/initialize-params-invalid.test +++ test/clangd/initialize-params-invalid.test @@ -29,6 +29,7 @@ # CHECK-NEXT:] # CHECK-NEXT: }, # CHECK-NEXT: "hoverProvider": true, +# CHECK-NEXT: "referencesProvider": true, # CHECK-NEXT: "renameProvider": true, # CHECK-NEXT: "signatureHelpProvider": { # CHECK-NEXT:"triggerCharacters": [ Index: clangd/XRefs.h === --- clangd/XRefs.h +++ clangd/XRefs.h @@ -30,6 +30,9 @@ std::vector findDocumentHighlights(ParsedAST , Position Pos); +std::vector findReferences(ParsedAST , Position Pos, + bool IncludeDeclaration); + /// Get the hover information when hovering at \p Pos. llvm::Optional getHover(ParsedAST , Position Pos); Index: clangd/XRefs.cpp === --- clangd/XRefs.cpp +++ clangd/XRefs.cpp @@ -211,6 +211,58 @@ return SymbolID(USR); } +/// Finds declarations locations that a given source Decl refers to, in the main +/// file. +class ReferenceLocationsFinder : public index::IndexDataConsumer { + std::vector ReferenceLocations; + ParsedAST + const Decl *ReferencedDecl; + index::SymbolRoleSet InterestingRoleSet; + +public: + ReferenceLocationsFinder(ParsedAST , const Decl *D, + bool IncludeDeclaration) + : AST(AST), ReferencedDecl(D), +InterestingRoleSet( +static_cast(index::SymbolRole::Reference)) { +if (IncludeDeclaration) + InterestingRoleSet |= + static_cast(index::SymbolRole::Declaration) | + static_cast(index::SymbolRole::Definition); + } + + std::vector takeLocations() { +// Don't keep the same location multiple times. +// This can happen when nodes in the AST are visited twice. +std::sort(ReferenceLocations.begin(), ReferenceLocations.end()); +auto last = +std::unique(ReferenceLocations.begin(), ReferenceLocations.end()); +ReferenceLocations.erase(last, ReferenceLocations.end()); +return std::move(ReferenceLocations); + } + + bool + handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles, + ArrayRef Relations, + SourceLocation Loc, + index::IndexDataConsumer::ASTNodeInfo ASTNode) override { +const SourceManager = AST.getASTContext().getSourceManager(); +if (D != ReferencedDecl || !SourceMgr.isWrittenInMainFile(Loc)) { + return true; +} + +// The end loc is adjusted in makeLocation with getLocForEndOfToken. +SourceRange Range(Loc, Loc); + +if (Roles & InterestingRoleSet) { + auto L = makeLocation(AST, Range); + if (L) +ReferenceLocations.push_back(*L); +} +return true; + } +}; + } // namespace std::vector findDefinitions(ParsedAST , Position Pos, @@ -324,6 +376,45 @@ return Result; } +std::vector findReferences(ParsedAST , Position Pos, + bool IncludeDeclaration) { + SourceManager = AST.getASTContext().getSourceManager(); + SourceLocation SourceLocationBeg = + getBeginningOfIdentifier(AST, Pos, SourceMgr.getMainFileID()); + + DeclarationAndMacrosFinder DeclMacrosFinder(llvm::errs(), SourceLocationBeg, + AST.getASTContext(), + AST.getPreprocessor()); + index::IndexingOptions IndexOpts; + IndexOpts.SystemSymbolFilter = + index::IndexingOptions::SystemSymbolFilterKind::All; + IndexOpts.IndexFunctionLocals = true; + indexTopLevelDecls(AST.getASTContext(), AST.getLocalTopLevelDecls(), + DeclMacrosFinder, IndexOpts); + std::vector Decls = DeclMacrosFinder.takeDecls();
[PATCH] D49511: [Sema/Attribute] Check for noderef attribute
rsmith added a comment. In https://reviews.llvm.org/D49511#1170693, @leonardchan wrote: > Done. I opted for not using `ExpressionEvaluationContextRecord` because I > don't think I was using it correctly. A few other tests in sema failed when I > tried pushing and popping from the stack holding these. I still process > expressions as they are parsed though without using AST traversal on every > expression. You shouldn't be adding your own `ExpressionEvaluationContextRecord`s. What I was suggesting is that you store a list of pending `noderef` expressions on the record, and diagnose them when the record is popped (if they've not been removed since). Your current counter-based approach doesn't work very well in the case where we switch to another context while processing an expression (for example, during template instantiation): you'll defer all the diagnostics for the inner construct until the outer construct is complete. Generally global `Sema` state doesn't work very well for this reason. That said... have you considered changing the specification of your attribute so that you warn on lvalue-to-rvalue conversions instead of warning on dereference-like things with a list of exceptions? That would be both simpler to implement and more precise (and it would naturally extend to C++, where a reference-to-`noderef` would be a reasonable type to support). Comment at: include/clang/Sema/Sema.h:1556 + unsigned NoDerefCallCount = 0; + std::unordered_set PossibleDerefs; + Do not use `unordered_set` here; see https://llvm.org/docs/ProgrammersManual.html#picking-the-right-data-structure-for-a-task `llvm::SmallPtrSet` or `llvm::DenseSet` would be better choices here, but I think just using a `SmallVector` would be fine. Comment at: lib/Sema/SemaExpr.cpp:14230-14242 +class DeclRefFinder : public ConstEvaluatedExprVisitor { +public: + typedef ConstEvaluatedExprVisitor Inherited; + + DeclRefFinder(ASTContext ) : Inherited(Ctx) {} + + void VisitDeclRefExpr(const DeclRefExpr *E) { DeclRef = E; } I don't see any reason to assume that the `DeclRefExpr` found by this visitor will be the one you're interested in (the one the `noderef` attribute came from). How about instead you walk over only expressions that you *know* preserve `noderef`, and if you can't find a declaration as the source of the `noderef` attribute, produce a differently-worded diagnostic that doesn't give a variable name? Comment at: lib/Sema/SemaExpr.cpp:14252-14257 + const DeclRefExpr *DeclRef = Finder.GetDeclRef(); + const ValueDecl *Decl = DeclRef->getDecl(); + + Diag(E->getExprLoc(), diag::warn_dereference_of_noderef_type) + << Decl->getName() << E->getSourceRange(); + Diag(Decl->getLocation(), diag::note_previous_decl) << Decl->getName(); This will crash if the `DeclRefFinder` doesn't find a `DeclRefExpr`. What justifies the assumption that it will always succeed? Repository: rC Clang https://reviews.llvm.org/D49511 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49766: Fix a crash when an error occurs in Template and the initializer is a nullptr for C++17
bviyer updated this revision to Diff 157730. bviyer added a comment. Fixed the comment as you suggested. I do not have check in rights yet. Can you please check it in for me? Repository: rC Clang https://reviews.llvm.org/D49766 Files: include/clang/AST/TemplateBase.h test/SemaObjCXX/class-templ-error-null-init.mm Index: test/SemaObjCXX/class-templ-error-null-init.mm === --- /dev/null +++ test/SemaObjCXX/class-templ-error-null-init.mm @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s +// expected-no-diagnostics +template +struct e { +e(a) {} +}; +e c(0); Index: include/clang/AST/TemplateBase.h === --- include/clang/AST/TemplateBase.h +++ include/clang/AST/TemplateBase.h @@ -465,7 +465,13 @@ TemplateArgumentLoc(const TemplateArgument , Expr *E) : Argument(Argument), LocInfo(E) { -assert(Argument.getKind() == TemplateArgument::Expression); + +// Permit any kind of template argument that can be represented +// with an expression +assert(Argument.getKind() == TemplateArgument::NullPtr || + Argument.getKind() == TemplateArgument::Integral || + Argument.getKind() == TemplateArgument::Declaration || + Argument.getKind() == TemplateArgument::Expression); } TemplateArgumentLoc(const TemplateArgument , Index: test/SemaObjCXX/class-templ-error-null-init.mm === --- /dev/null +++ test/SemaObjCXX/class-templ-error-null-init.mm @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s +// expected-no-diagnostics +template +struct e { +e(a) {} +}; +e c(0); Index: include/clang/AST/TemplateBase.h === --- include/clang/AST/TemplateBase.h +++ include/clang/AST/TemplateBase.h @@ -465,7 +465,13 @@ TemplateArgumentLoc(const TemplateArgument , Expr *E) : Argument(Argument), LocInfo(E) { -assert(Argument.getKind() == TemplateArgument::Expression); + +// Permit any kind of template argument that can be represented +// with an expression +assert(Argument.getKind() == TemplateArgument::NullPtr || + Argument.getKind() == TemplateArgument::Integral || + Argument.getKind() == TemplateArgument::Declaration || + Argument.getKind() == TemplateArgument::Expression); } TemplateArgumentLoc(const TemplateArgument , ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49439: [Sema] Fix a crash while converting constructors to deduction guides
rsmith accepted this revision. rsmith added inline comments. This revision is now accepted and ready to land. Comment at: clang/lib/Sema/SemaTemplate.cpp:1899-1907 // Canonicalize the type. This (for instance) replaces references to // typedef members of the current instantiations with the definitions of // those typedefs, avoiding triggering instantiation of the deduced type // during deduction. // FIXME: It would be preferable to retain type sugar and source // information here (and handle this in substitution instead). NewDI = SemaRef.Context.getTrivialTypeSourceInfo( erik.pilkington wrote: > rsmith wrote: > > This is really the problem: we shouldn't be doing a full canonicalization > > step here. I expect that even with your patch applied we'll still see > > problems for cases like: > > ``` > > template struct X {}; > > template struct A { > > A(T t, X); > > }; > > A a(0, {}); > > template struct B { > > B(U u, X); > > }; > > B b(0, {}); > > ``` > > ... because we'll canonicalize the second parameter of `B`'s deduction > > guide to have type `X` (where that's the `t` from `A`'s > > deduction guide). > > > > So I think we should look at fixing the FIXME here properly. There seem to > > be at least two viable options: > > > > 1) don't canonicalize the type; instead, extend template instantiation to > > be able to cope with one template referring to members of another template > > directly, without instantiating the class containing those members, or > > 2) add a custom `TreeTransform` to do the canonicalization we want to do > > here, and to avoid the canonicalization we don't want to do > > > > Both of these seem pretty tricky to get right, though, which is why we > > currently use the canonicalization hack :( > Yep, that still crashes :/ > > I started to implement 2 in the new patch. This implementation just unwraps > typedefs into the deduction guide, but that is already enough to pass > libcxx's test suite. This doesn't handle everything that we could, such as > expression in a decltype [1]. This is fine for now though, because the > canonicalization hack doesn't either. In fact, I couldn't find any cases > where this patch fails but the canonicalization succeeds. I'm inclined to fix > the crash now, address any extra cases in a follow-up if we actually want to > support them. Does this seem reasonable to you? > > It also seems we're reading pretty far between the lines of the standard > here, do you think a DR should be filed? > > [1]: I think we could support this is we wanted by stubbing out DeclRefExprs > to members for a new (or existing?) opaque reference AST node that acted like > a declval() analog. This would allow us to do sfinae using the member's > type without relying on it's context. In core discussion, we agreed to handwave vigorously about such things in the wording for now... (the other option was that we'd spend many meetings refining wording to express what we mean here). A DR to keep us honest seems like a very good thing, especially if you have examples (such as the `decltype` example) where the correct behavior is unclear. I think it's fine to do as you've done here (fix the crash for now, and address any subsequent necessary transformations as we find we need them). I'm pleasantly surprised by how simple the `TreeTransform` turned out to be (though I bet it makes the clang binary significantly larger). Please can you add the example I gave above (or something like it) as a test case? https://reviews.llvm.org/D49439 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49899: Force test/Driver/fuchsia.c(pp) to use lld
ruiu added a comment. > The Fuchsia driver relies on lld so invoke clang with -fuse-ld=lld. This gets > the test passing when the clang default linker is something other than lld. Does it work if lld is not installed at all? I believe if the driver cannot find a specified linker, it reports an error instead of trying to execute a nonexistent file. https://reviews.llvm.org/D49899 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49766: Fix a crash when an error occurs in Template and the initializer is a nullptr for C++17
erik.pilkington accepted this revision. erik.pilkington added a comment. This revision is now accepted and ready to land. LGTM, thanks! Do you have your commit rights yet? Comment at: include/clang/AST/TemplateBase.h:469 + +// Allow more additional argument kinds for the constructor. +assert(Argument.getKind() == TemplateArgument::NullPtr || This comment sounds pretty strange, how about "Permit any kind of template argument that can be represented with an expression"? Repository: rC Clang https://reviews.llvm.org/D49766 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r337746 - [clang-cl] Expose -fblocks and -fno-builtin as driver flags
On Wed, Jul 25, 2018 at 4:39 AM Nico Weber wrote: > I thought about adding -fblocks when that thread happened, but since > there's no runtime for them that just works exposing it doesn't seem very > helpful. Maybe we should instead change the warning text to not suggest > -fblocks when building on a non-mac target? > Someone linked to a github repo that has a Windows implementation of the runtime. It may not be officially supported, but I don't see any reason to throw up extra roadblocks. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49914: [libc++] Add the _LIBCPP_HIDE_FROM_ABI_AFTER_V1 macro
ldionne added inline comments. Comment at: libcxx/include/__config:798 -// Just so we can migrate to _LIBCPP_HIDE_FROM_ABI gradually. -#define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI - -#ifndef _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -#define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__visibility__("default"), __always_inline__)) +#ifdef _LIBCPP_BUILDING_LIBRARY +# if _LIBCPP_ABI_VERSION > 1 dexonsmith wrote: > It looks like if you switch this to `#if !defined(...)` you can use `#elif` > instead of a nested `#if`. I think that would make the logic a bit more > clear for me, but if you disagree feel free to leave it as is. The reason I did it that way is that this structure will make it easier to add new versions in the future: ``` #ifdef _LIBCPP_BUILDING_LIBRARY # if _LIBCPP_ABI_VERSION > 1 #define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI # else #define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 # endif # if _LIBCPP_ABI_VERSION > 2 #define _LIBCPP_HIDE_FROM_ABI_AFTER_V2 _LIBCPP_HIDE_FROM_ABI # else #define _LIBCPP_HIDE_FROM_ABI_AFTER_V2 # endif #else # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI # define _LIBCPP_HIDE_FROM_ABI_AFTER_V2 _LIBCPP_HIDE_FROM_ABI #endif ``` With your suggestion, the case where we have only one ABI version is indeed clearer, but it's not as easy to add a new version (remember than if the version is `2`, both `_LIBCPP_HIDE_FROM_ABI_AFTER_V1` and `_LIBCPP_HIDE_FROM_ABI_AFTER_V2` would need to be defined, so an `elif` chain does not cut it): ``` // Hide symbols when we're not building the dylib #if !defined(_LIBCPP_BUILDING_LIBRARY) # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI // Otherwise, hide symbols depending on the ABI version used to build the dylib #elif _LIBCPP_ABI_VERSION > 1 # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI #else # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 #endif ``` This basically needs to turn into what I've put above if we are to add a new ABI version. Repository: rCXX libc++ https://reviews.llvm.org/D49914 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338149 - [analyzer] Extend NoStoreFuncVisitor to insert a note on IVars
Author: george.karpenkov Date: Fri Jul 27 11:26:40 2018 New Revision: 338149 URL: http://llvm.org/viewvc/llvm-project?rev=338149=rev Log: [analyzer] Extend NoStoreFuncVisitor to insert a note on IVars The note is added in the following situation: - We are throwing a nullability-related warning on an IVar - The path goes through a method which *could have* (syntactically determined) written into that IVar, but did not rdar://4260 Differential Revision: https://reviews.llvm.org/D49689 Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp cfe/trunk/test/Analysis/diagnostics/no-store-func-path-notes.cpp cfe/trunk/test/Analysis/diagnostics/no-store-func-path-notes.m Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=338149=338148=338149=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Fri Jul 27 11:26:40 2018 @@ -22,6 +22,7 @@ #include "clang/AST/ExprObjC.h" #include "clang/AST/Stmt.h" #include "clang/AST/Type.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/Analysis/AnalysisDeclContext.h" #include "clang/Analysis/CFG.h" #include "clang/Analysis/CFGStmtMap.h" @@ -306,15 +307,26 @@ public: CallEventRef<> Call = BRC.getStateManager().getCallEventManager().getCaller(SCtx, State); - const PrintingPolicy = BRC.getASTContext().getPrintingPolicy(); const SourceManager = BRC.getSourceManager(); + +// Region of interest corresponds to an IVar, exiting a method +// which could have written into that IVar, but did not. +if (const auto *MC = dyn_cast(Call)) + if (const auto *IvarR = dyn_cast(RegionOfInterest)) +if (potentiallyWritesIntoIvar(Call->getRuntimeDefinition().getDecl(), + IvarR->getDecl()) && +!isRegionOfInterestModifiedInFrame(N)) + return notModifiedMemberDiagnostics( + Ctx, SM, PP, *CallExitLoc, Call, + MC->getReceiverSVal().getAsRegion()); + if (const auto *CCall = dyn_cast(Call)) { const MemRegion *ThisRegion = CCall->getCXXThisVal().getAsRegion(); if (RegionOfInterest->isSubRegionOf(ThisRegion) && !CCall->getDecl()->isImplicit() && !isRegionOfInterestModifiedInFrame(N)) -return notModifiedInConstructorDiagnostics(Ctx, SM, PP, *CallExitLoc, +return notModifiedMemberDiagnostics(Ctx, SM, PP, *CallExitLoc, CCall, ThisRegion); } @@ -331,7 +343,7 @@ public: if (isRegionOfInterestModifiedInFrame(N)) return nullptr; - return notModifiedDiagnostics( + return notModifiedParameterDiagnostics( Ctx, SM, PP, *CallExitLoc, Call, PVD, R, IndirectionLevel); } QualType PT = T->getPointeeType(); @@ -346,6 +358,22 @@ public: } private: + + /// \return Whether the method declaration \p Parent + /// syntactically has a binary operation writing into the ivar \p Ivar. + bool potentiallyWritesIntoIvar(const Decl *Parent, + const ObjCIvarDecl *Ivar) { +using namespace ast_matchers; +if (!Parent || !Parent->getBody()) + return false; +StatementMatcher WriteIntoIvarM = binaryOperator( +hasOperatorName("="), hasLHS(ignoringParenImpCasts(objcIvarRefExpr( + hasDeclaration(equalsNode(Ivar)); +StatementMatcher ParentM = stmt(hasDescendant(WriteIntoIvarM)); +auto Matches = match(ParentM, *Parent->getBody(), Parent->getASTContext()); +return !Matches.empty(); + } + /// Check and lazily calculate whether the region of interest is /// modified in the stack frame to which \p N belongs. /// The calculation is cached in FramesModifyingRegion. @@ -414,19 +442,21 @@ private: Ty->getPointeeType().getCanonicalType().isConstQualified(); } - std::shared_ptr notModifiedInConstructorDiagnostics( + /// \return Diagnostics piece for the member field not modified + /// in a given function. + std::shared_ptr notModifiedMemberDiagnostics( const LocationContext *Ctx, const SourceManager , const PrintingPolicy , CallExitBegin , - const CXXConstructorCall *Call, + CallEventRef<> Call, const MemRegion *ArgRegion) { +const char *TopRegionName = isa(Call) ? "self" : "this"; SmallString<256> sbuf; llvm::raw_svector_ostream os(sbuf); os << DiagnosticsMsg; -bool out = prettyPrintRegionName( -"this", "->", /*IsReference=*/true, -/*IndirectionLevel=*/1, ArgRegion, os, PP); +bool out = prettyPrintRegionName(TopRegionName, "->", /*IsReference=*/true, +
[PATCH] D49865: Inform the AST of #pragma FENV_ACCESS use
rsmith added a comment. Thanks, this is definitely a step in the right direction. Comment at: include/clang/AST/Expr.h:3257-3261 + // Get the FENV_ACCESS status of this operator. Only meaningful for + // operations on floating point types. + bool isFENVAccessOn() const { +return FPOptions(FPFeatures).allowFENVAccess(); + } Nit: I think this should be capitalized as `FEnvAccess`. Lowercasing the "ccess" of "access" but not the "nv" of "environment" seems inconsistent to me, and falsely makes "FENV" look like an initialism or acronym. Comment at: include/clang/Basic/LangOptions.h:273-280 FPOptions() : fp_contract(LangOptions::FPC_Off) {} // Used for serializing. explicit FPOptions(unsigned I) : fp_contract(static_cast(I)) {} explicit FPOptions(const LangOptions ) These constructors need to be updated. Comment at: lib/Parse/ParsePragma.cpp:619-623 +#if NOTYET // FIXME: Add this cli option when it makes sense. + case tok::OOS_DEFAULT: +FPC = getLangOpts().getDefaultFENVAccessMode(); +break; +#endif You need to do *something* in this case. Currently, `FPC` is read uninitialized a few lines below when this happens. How about just treating this as the same as `OFF` for now, since that is our default. Comment at: lib/Parse/ParseStmt.cpp:353 +ProhibitAttributes(Attrs); +//Diag(Tok, diag::err_pragma_fp_scope); +HandlePragmaFENVAccess(); Delete this line. Comment at: lib/Sema/SemaAttr.cpp:779 + case LangOptions::FEA_On: +FPFeatures.setAllowFENVAccess(); +break; Not directly related to your patch, but... treating `FPFeatures` as persistent `Sema` state will be error-prone. For example, we'll get the wrong features in template instantiation and implicitly-generated special member functions. But I don't have a good alternative to suggest right now (other than tracking down the places where we need to save and restore this extra state and doing so), so this is just a concern, not a call to action at this point. Repository: rC Clang https://reviews.llvm.org/D49865 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49766: Fix a crash when an error occurs in Template and the initializer is a nullptr for C++17
bviyer updated this revision to Diff 157721. bviyer added a comment. I have fixed all the changes requested by Erik along with shortening the test case. Repository: rC Clang https://reviews.llvm.org/D49766 Files: include/clang/AST/TemplateBase.h test/SemaObjCXX/class-templ-error-null-init.mm Index: test/SemaObjCXX/class-templ-error-null-init.mm === --- /dev/null +++ test/SemaObjCXX/class-templ-error-null-init.mm @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s +// expected-no-diagnostics +template +struct e { +e(a) {} +}; +e c(0); Index: include/clang/AST/TemplateBase.h === --- include/clang/AST/TemplateBase.h +++ include/clang/AST/TemplateBase.h @@ -465,7 +465,12 @@ TemplateArgumentLoc(const TemplateArgument , Expr *E) : Argument(Argument), LocInfo(E) { -assert(Argument.getKind() == TemplateArgument::Expression); + +// Allow more additional argument kinds for the constructor. +assert(Argument.getKind() == TemplateArgument::NullPtr || + Argument.getKind() == TemplateArgument::Integral || + Argument.getKind() == TemplateArgument::Declaration || + Argument.getKind() == TemplateArgument::Expression); } TemplateArgumentLoc(const TemplateArgument , Index: test/SemaObjCXX/class-templ-error-null-init.mm === --- /dev/null +++ test/SemaObjCXX/class-templ-error-null-init.mm @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s +// expected-no-diagnostics +template +struct e { +e(a) {} +}; +e c(0); Index: include/clang/AST/TemplateBase.h === --- include/clang/AST/TemplateBase.h +++ include/clang/AST/TemplateBase.h @@ -465,7 +465,12 @@ TemplateArgumentLoc(const TemplateArgument , Expr *E) : Argument(Argument), LocInfo(E) { -assert(Argument.getKind() == TemplateArgument::Expression); + +// Allow more additional argument kinds for the constructor. +assert(Argument.getKind() == TemplateArgument::NullPtr || + Argument.getKind() == TemplateArgument::Integral || + Argument.getKind() == TemplateArgument::Declaration || + Argument.getKind() == TemplateArgument::Expression); } TemplateArgumentLoc(const TemplateArgument , ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r338139 - [OPENMP] Static variables on device must be externally visible.
Hi Alexey, from what I can see this change can't handle the case where there are static variables with the same name in multiple TUs. (The same problem exists for static CUDA kernels with -fcuda-rdc. I found that nvcc mangles the function names in this case, but didn't have time yet to prepare a similar patch for Clang.) I think for now it would be better to emit a meaningful error instead of generating incorrect code and letting the user figure out what went wrong. My 2 cents, Jonas On 2018-07-27 19:37, Alexey Bataev via cfe-commits wrote: Author: abataev Date: Fri Jul 27 10:37:32 2018 New Revision: 338139 URL: http://llvm.org/viewvc/llvm-project?rev=338139=rev Log: [OPENMP] Static variables on device must be externally visible. Do not mark static variable as internal on the device as they must be visible from the host to be mapped correctly. Modified: cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/test/OpenMP/declare_target_codegen.cpp cfe/trunk/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=338139=338138=338139=diff == --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Fri Jul 27 10:37:32 2018 @@ -9504,6 +9504,21 @@ static GVALinkage basicGVALinkageForFunc return GVA_DiscardableODR; } +static bool isDeclareTargetToDeclaration(const Decl *VD) { + for (const Decl *D : VD->redecls()) { +if (!D->hasAttrs()) + continue; +if (const auto *Attr = D->getAttr()) + return Attr->getMapType() == OMPDeclareTargetDeclAttr::MT_To; + } + if (const auto *V = dyn_cast(VD)) { +if (const VarDecl *TD = V->getTemplateInstantiationPattern()) + return isDeclareTargetToDeclaration(TD); + } + + return false; +} + static GVALinkage adjustGVALinkageForAttributes(const ASTContext , const Decl *D, GVALinkage L) { // See http://msdn.microsoft.com/en-us/library/xa0d9ste.aspx @@ -9520,6 +9535,12 @@ static GVALinkage adjustGVALinkageForAtt // visible externally so they can be launched from host. if (L == GVA_DiscardableODR || L == GVA_Internal) return GVA_StrongODR; + } else if (Context.getLangOpts().OpenMP && Context.getLangOpts().OpenMPIsDevice && + isDeclareTargetToDeclaration(D)) { +// Static variables must be visible externally so they can be mapped from +// host. +if (L == GVA_Internal) + return GVA_StrongODR; } return L; } Modified: cfe/trunk/test/OpenMP/declare_target_codegen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_target_codegen.cpp?rev=338139=338138=338139=diff == --- cfe/trunk/test/OpenMP/declare_target_codegen.cpp (original) +++ cfe/trunk/test/OpenMP/declare_target_codegen.cpp Fri Jul 27 10:37:32 2018 @@ -18,12 +18,14 @@ // CHECK-DAG: @d = global i32 0, // CHECK-DAG: @c = external global i32, // CHECK-DAG: @globals = global %struct.S zeroinitializer, -// CHECK-DAG: @llvm.used = appending global [1 x i8*] [i8* bitcast (void ()* @__omp_offloading__{{.+}}_globals_l[[@LINE+41]]_ctor to i8*)], section "llvm.metadata" +// CHECK-DAG: @{{.+}}stat = weak_odr global %struct.S zeroinitializer, +// CHECK-DAG: @llvm.used = appending global [2 x i8*] [i8* bitcast (void ()* @__omp_offloading__{{.+}}_globals_l[[@LINE+42]]_ctor to i8*), i8* bitcast (void ()* @__omp_offloading__{{.+}}_stat_l[[@LINE+43]]_ctor to i8*)], section "llvm.metadata" // CHECK-DAG: define {{.*}}i32 @{{.*}}{{foo|bar|baz2|baz3|FA|f_method}}{{.*}}() // CHECK-DAG: define {{.*}}void @{{.*}}TemplateClass{{.*}}(%class.TemplateClass* %{{.*}}) // CHECK-DAG: define {{.*}}i32 @{{.*}}TemplateClass{{.*}}f_method{{.*}}(%class.TemplateClass* %{{.*}}) -// CHECK-DAG: define {{.*}}void @__omp_offloading__{{.*}}_globals_l[[@LINE+36]]_ctor() +// CHECK-DAG: define {{.*}}void @__omp_offloading__{{.*}}_globals_l[[@LINE+37]]_ctor() +// CHECK-DAG: define {{.*}}void @__omp_offloading__{{.*}}_stat_l[[@LINE+37]]_ctor() #ifndef HEADER #define HEADER @@ -60,6 +62,7 @@ int foo() { return 0; } int b = 15; int d; S globals(d); +static S stat(d); #pragma omp end declare target int c; Modified: cfe/trunk/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp?rev=338139=338138=338139=diff == --- cfe/trunk/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp (original) +++ cfe/trunk/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp Fri Jul 27 10:37:32 2018 @@ -15,7 +15,7 @@ // SIMD-ONLY-NOT: {{__kmpc|__tgt}} -// DEVICE-DAG: [[C_ADDR:.+]] = internal global
[PATCH] D49922: [P0936R0] add [[clang::lifetimebound]] attribute
rsmith added inline comments. Comment at: include/clang/AST/TypeLoc.h:96-97 /// Convert to the specified TypeLoc type, returning a null TypeLoc if - /// this TypeLock is not of the desired type. It will consider type - /// adjustments from a type that wad written as a T to another type that is + /// this TypeLoc is not of the desired type. It will consider type + /// adjustments from a type that was written as a T to another type that is /// still canonically a T (ignores parens, attributes, elaborated types, etc). (This typo fix has been committed separately.) Comment at: include/clang/Basic/AttrDocs.td:2368 + let Content = [{ +The ``lifetime_bound`` attribute indicates that a resource owned by +a function parameter or implicit object parameter I've removed the underscore here. Comment at: lib/AST/TypePrinter.cpp:1492-1521 - case AttributedType::attr_objc_gc: { -OS << "objc_gc("; - -QualType tmp = T->getEquivalentType(); -while (tmp.getObjCGCAttr() == Qualifiers::GCNone) { - QualType next = tmp->getPointeeType(); - if (next == tmp) break; (This was dead code; see lines 1396-1399.) Repository: rC Clang https://reviews.llvm.org/D49922 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48341: [clang-doc] Refactoring mapper to map by scope
juliehockett added a comment. any further thoughts on this? https://reviews.llvm.org/D48341 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49922: [P0936R0] add [[clang::lifetimebound]] attribute
rsmith created this revision. rsmith added a reviewer: aaron.ballman. Herald added a reviewer: javed.absar. Herald added a subscriber: kristof.beyls. This patch adds support for a new attribute, [[clang::lifetimebound]], that indicates that the lifetime of a function result is related to one of the function arguments. When walking an initializer to make sure that the lifetime of the initial value is at least as long as the lifetime of the initialized object, we step through parameters (including the implicit object parameter of a non-static member function) that are marked with this attribute. There's nowhere to write an attribute on the implicit object parameter, so in lieu of that, it may be applied to a function type (where it appears immediately after the cv-qualifiers and ref-qualifier, which is as close to a declaration of the implicit object parameter as we have). I'm currently modeling this in the AST as the attribute appertaining to a `ParmVarDecl` or to a function type, but in the latter case I'd be happy to stash it somewhere else if there is a better home for it. Repository: rC Clang https://reviews.llvm.org/D49922 Files: include/clang/AST/Type.h include/clang/AST/TypeLoc.h include/clang/Basic/Attr.td include/clang/Basic/AttrDocs.td include/clang/Basic/DiagnosticSemaKinds.td lib/AST/Type.cpp lib/AST/TypePrinter.cpp lib/Parse/ParseDeclCXX.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclAttr.cpp lib/Sema/SemaInit.cpp lib/Sema/SemaOverload.cpp lib/Sema/SemaType.cpp utils/TableGen/ClangAttrEmitter.cpp Index: utils/TableGen/ClangAttrEmitter.cpp === --- utils/TableGen/ClangAttrEmitter.cpp +++ utils/TableGen/ClangAttrEmitter.cpp @@ -3305,11 +3305,16 @@ // Otherwise, generate an appertainsTo check specific to this attribute which // checks all of the given subjects against the Decl passed in. Return the // name of that check to the caller. + // + // If D is null, that means the attribute was not applied to a declaration + // at all (for instance because it was applied to a type), or that the caller + // has determined that the check should fail (perhaps prior to the creation + // of the declaration). std::string FnName = "check" + Attr.getName().str() + "AppertainsTo"; std::stringstream SS; SS << "static bool " << FnName << "(Sema , const ParsedAttr , "; SS << "const Decl *D) {\n"; - SS << " if ("; + SS << " if (!D || ("; for (auto I = Subjects.begin(), E = Subjects.end(); I != E; ++I) { // If the subject has custom code associated with it, generate a function // for it. The function cannot be inlined into this check (yet) because it @@ -3325,7 +3330,7 @@ if (I + 1 != E) SS << " && "; } - SS << ") {\n"; + SS << ")) {\n"; SS << "S.Diag(Attr.getLoc(), diag::"; SS << (Warn ? "warn_attribute_wrong_decl_type_str" : "err_attribute_wrong_decl_type_str"); Index: lib/Sema/SemaType.cpp === --- lib/Sema/SemaType.cpp +++ lib/Sema/SemaType.cpp @@ -5233,6 +5233,8 @@ return ParsedAttr::AT_ObjCKindOf; case AttributedType::attr_ns_returns_retained: return ParsedAttr::AT_NSReturnsRetained; + case AttributedType::attr_lifetimebound: +return ParsedAttr::AT_LifetimeBound; } llvm_unreachable("unexpected attribute kind!"); } @@ -7194,6 +7196,18 @@ T = State.getSema().Context.getAddrSpaceQualType(T, ImpAddr); } +static void HandleLifetimeBoundAttr(QualType , +const ParsedAttr , +Sema , Declarator ) { + if (D.isDeclarationOfFunction()) { +CurType = S.Context.getAttributedType(AttributedType::attr_lifetimebound, + CurType, CurType); + } else { +Attr.diagnoseAppertainsTo(S, nullptr); + } +} + + static void processTypeAttrs(TypeProcessingState , QualType , TypeAttrLocation TAL, ParsedAttributesView ) { @@ -7298,6 +7312,13 @@ HandleOpenCLAccessAttr(type, attr, state.getSema()); attr.setUsedAsTypeAttr(); break; +case ParsedAttr::AT_LifetimeBound: + if (TAL == TAL_DeclChunk) { +HandleLifetimeBoundAttr(type, attr, state.getSema(), +state.getDeclarator()); +attr.setUsedAsTypeAttr(); + } + break; MS_TYPE_ATTRS_CASELIST: if (!handleMSPointerTypeQualifierAttr(state, attr, type)) Index: lib/Sema/SemaOverload.cpp === --- lib/Sema/SemaOverload.cpp +++ lib/Sema/SemaOverload.cpp @@ -5230,7 +5230,9 @@ if (!Context.hasSameType(From->getType(), DestType)) From = ImpCastExprToType(From, DestType, CK_NoOp, From->getValueKind()).get(); - return From; + if
r338141 - Fix typos in comment.
Author: rsmith Date: Fri Jul 27 11:06:54 2018 New Revision: 338141 URL: http://llvm.org/viewvc/llvm-project?rev=338141=rev Log: Fix typos in comment. Modified: cfe/trunk/include/clang/AST/TypeLoc.h Modified: cfe/trunk/include/clang/AST/TypeLoc.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeLoc.h?rev=338141=338140=338141=diff == --- cfe/trunk/include/clang/AST/TypeLoc.h (original) +++ cfe/trunk/include/clang/AST/TypeLoc.h Fri Jul 27 11:06:54 2018 @@ -93,8 +93,8 @@ public: } /// Convert to the specified TypeLoc type, returning a null TypeLoc if - /// this TypeLock is not of the desired type. It will consider type - /// adjustments from a type that wad written as a T to another type that is + /// this TypeLoc is not of the desired type. It will consider type + /// adjustments from a type that was written as a T to another type that is /// still canonically a T (ignores parens, attributes, elaborated types, etc). template T getAsAdjusted() const; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43871: [modules] No longer include stdlib.h from mm_malloc.h.
teemperor planned changes to this revision. teemperor marked an inline comment as done. teemperor added a comment. (Just marking this as "Plan changes" because otherwise it's just stuck in my "Waiting on review" queue). https://reviews.llvm.org/D43871 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49920: [clangd] [WIP] Find references of local symbols
malaperle created this revision. Herald added subscribers: cfe-commits, arphaman, mgrang, jkorous, MaskRay, ioeric, ilya-biryukov. We do not have a global index of references but we can find the references of local symbols within the AST in the mean time. Also, since we will not record local symbol references in the index, we will need that logic anyway. Signed-off-by: Marc-Andre Laperle Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D49920 Files: clangd/ClangdLSPServer.cpp clangd/ClangdLSPServer.h clangd/ClangdServer.cpp clangd/ClangdServer.h clangd/Protocol.cpp clangd/Protocol.h clangd/ProtocolHandlers.cpp clangd/ProtocolHandlers.h clangd/XRefs.cpp clangd/XRefs.h test/clangd/initialize-params-invalid.test test/clangd/initialize-params.test Index: test/clangd/initialize-params.test === --- test/clangd/initialize-params.test +++ test/clangd/initialize-params.test @@ -29,6 +29,7 @@ # CHECK-NEXT:] # CHECK-NEXT: }, # CHECK-NEXT: "hoverProvider": true, +# CHECK-NEXT: "referencesProvider": true, # CHECK-NEXT: "renameProvider": true, # CHECK-NEXT: "signatureHelpProvider": { # CHECK-NEXT:"triggerCharacters": [ Index: test/clangd/initialize-params-invalid.test === --- test/clangd/initialize-params-invalid.test +++ test/clangd/initialize-params-invalid.test @@ -29,6 +29,7 @@ # CHECK-NEXT:] # CHECK-NEXT: }, # CHECK-NEXT: "hoverProvider": true, +# CHECK-NEXT: "referencesProvider": true, # CHECK-NEXT: "renameProvider": true, # CHECK-NEXT: "signatureHelpProvider": { # CHECK-NEXT:"triggerCharacters": [ Index: clangd/XRefs.h === --- clangd/XRefs.h +++ clangd/XRefs.h @@ -30,6 +30,9 @@ std::vector findDocumentHighlights(ParsedAST , Position Pos); +std::vector findReferences(ParsedAST , Position Pos, + bool IncludeDeclaration); + /// Get the hover information when hovering at \p Pos. llvm::Optional getHover(ParsedAST , Position Pos); Index: clangd/XRefs.cpp === --- clangd/XRefs.cpp +++ clangd/XRefs.cpp @@ -211,6 +211,58 @@ return SymbolID(USR); } +/// Finds declarations locations that a given source Decl refers to, in the main +/// file. +class ReferenceLocationsFinder : public index::IndexDataConsumer { + std::vector ReferenceLocations; + ParsedAST + const Decl *ReferencedDecl; + index::SymbolRoleSet InterestingRoleSet; + +public: + ReferenceLocationsFinder(ParsedAST , const Decl *D, + bool IncludeDeclaration) + : AST(AST), ReferencedDecl(D), +InterestingRoleSet( +static_cast(index::SymbolRole::Reference)) { +if (IncludeDeclaration) + InterestingRoleSet |= + static_cast(index::SymbolRole::Declaration) | + static_cast(index::SymbolRole::Definition); + } + + std::vector takeLocations() { +// Don't keep the same location multiple times. +// This can happen when nodes in the AST are visited twice. +std::sort(ReferenceLocations.begin(), ReferenceLocations.end()); +auto last = +std::unique(ReferenceLocations.begin(), ReferenceLocations.end()); +ReferenceLocations.erase(last, ReferenceLocations.end()); +return std::move(ReferenceLocations); + } + + bool + handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles, + ArrayRef Relations, + SourceLocation Loc, + index::IndexDataConsumer::ASTNodeInfo ASTNode) override { +const SourceManager = AST.getASTContext().getSourceManager(); +if (D != ReferencedDecl || SourceMgr.isWrittenInMainFile(Loc)) { + return true; +} + +// The end loc is adjusted in makeLocation with getLocForEndOfToken. +SourceRange Range(Loc, Loc); + +if (Roles & InterestingRoleSet) { + auto L = makeLocation(AST, Range); + if (L) +ReferenceLocations.push_back(*L); +} +return true; + } +}; + } // namespace std::vector findDefinitions(ParsedAST , Position Pos, @@ -324,6 +376,45 @@ return Result; } +std::vector findReferences(ParsedAST , Position Pos, + bool IncludeDeclaration) { + SourceManager = AST.getASTContext().getSourceManager(); + SourceLocation SourceLocationBeg = + getBeginningOfIdentifier(AST, Pos, SourceMgr.getMainFileID()); + + DeclarationAndMacrosFinder DeclMacrosFinder(llvm::errs(), SourceLocationBeg, + AST.getASTContext(), + AST.getPreprocessor()); + index::IndexingOptions IndexOpts; + IndexOpts.SystemSymbolFilter = +
r338140 - [ASTMatchers] Introduce a matcher for `ObjCIvarExpr`, support getting it's declaration
Author: george.karpenkov Date: Fri Jul 27 10:40:59 2018 New Revision: 338140 URL: http://llvm.org/viewvc/llvm-project?rev=338140=rev Log: [ASTMatchers] Introduce a matcher for `ObjCIvarExpr`, support getting it's declaration ObjCIvarExpr is *not* a subclass of MemberExpr, and a separate matcher is required to support it. Adding a hasDeclaration support as well, as it's not very useful without it. Differential Revision: https://reviews.llvm.org/D49701 Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=338140=338139=338140=diff == --- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h (original) +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Fri Jul 27 10:40:59 2018 @@ -41,6 +41,7 @@ #include "clang/AST/DeclFriend.h" #include "clang/AST/DeclTemplate.h" #include "clang/AST/Expr.h" +#include "clang/AST/ExprObjC.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/ExprObjC.h" #include "clang/AST/NestedNameSpecifier.h" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338139 - [OPENMP] Static variables on device must be externally visible.
Author: abataev Date: Fri Jul 27 10:37:32 2018 New Revision: 338139 URL: http://llvm.org/viewvc/llvm-project?rev=338139=rev Log: [OPENMP] Static variables on device must be externally visible. Do not mark static variable as internal on the device as they must be visible from the host to be mapped correctly. Modified: cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/test/OpenMP/declare_target_codegen.cpp cfe/trunk/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=338139=338138=338139=diff == --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Fri Jul 27 10:37:32 2018 @@ -9504,6 +9504,21 @@ static GVALinkage basicGVALinkageForFunc return GVA_DiscardableODR; } +static bool isDeclareTargetToDeclaration(const Decl *VD) { + for (const Decl *D : VD->redecls()) { +if (!D->hasAttrs()) + continue; +if (const auto *Attr = D->getAttr()) + return Attr->getMapType() == OMPDeclareTargetDeclAttr::MT_To; + } + if (const auto *V = dyn_cast(VD)) { +if (const VarDecl *TD = V->getTemplateInstantiationPattern()) + return isDeclareTargetToDeclaration(TD); + } + + return false; +} + static GVALinkage adjustGVALinkageForAttributes(const ASTContext , const Decl *D, GVALinkage L) { // See http://msdn.microsoft.com/en-us/library/xa0d9ste.aspx @@ -9520,6 +9535,12 @@ static GVALinkage adjustGVALinkageForAtt // visible externally so they can be launched from host. if (L == GVA_DiscardableODR || L == GVA_Internal) return GVA_StrongODR; + } else if (Context.getLangOpts().OpenMP && Context.getLangOpts().OpenMPIsDevice && + isDeclareTargetToDeclaration(D)) { +// Static variables must be visible externally so they can be mapped from +// host. +if (L == GVA_Internal) + return GVA_StrongODR; } return L; } Modified: cfe/trunk/test/OpenMP/declare_target_codegen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_target_codegen.cpp?rev=338139=338138=338139=diff == --- cfe/trunk/test/OpenMP/declare_target_codegen.cpp (original) +++ cfe/trunk/test/OpenMP/declare_target_codegen.cpp Fri Jul 27 10:37:32 2018 @@ -18,12 +18,14 @@ // CHECK-DAG: @d = global i32 0, // CHECK-DAG: @c = external global i32, // CHECK-DAG: @globals = global %struct.S zeroinitializer, -// CHECK-DAG: @llvm.used = appending global [1 x i8*] [i8* bitcast (void ()* @__omp_offloading__{{.+}}_globals_l[[@LINE+41]]_ctor to i8*)], section "llvm.metadata" +// CHECK-DAG: @{{.+}}stat = weak_odr global %struct.S zeroinitializer, +// CHECK-DAG: @llvm.used = appending global [2 x i8*] [i8* bitcast (void ()* @__omp_offloading__{{.+}}_globals_l[[@LINE+42]]_ctor to i8*), i8* bitcast (void ()* @__omp_offloading__{{.+}}_stat_l[[@LINE+43]]_ctor to i8*)], section "llvm.metadata" // CHECK-DAG: define {{.*}}i32 @{{.*}}{{foo|bar|baz2|baz3|FA|f_method}}{{.*}}() // CHECK-DAG: define {{.*}}void @{{.*}}TemplateClass{{.*}}(%class.TemplateClass* %{{.*}}) // CHECK-DAG: define {{.*}}i32 @{{.*}}TemplateClass{{.*}}f_method{{.*}}(%class.TemplateClass* %{{.*}}) -// CHECK-DAG: define {{.*}}void @__omp_offloading__{{.*}}_globals_l[[@LINE+36]]_ctor() +// CHECK-DAG: define {{.*}}void @__omp_offloading__{{.*}}_globals_l[[@LINE+37]]_ctor() +// CHECK-DAG: define {{.*}}void @__omp_offloading__{{.*}}_stat_l[[@LINE+37]]_ctor() #ifndef HEADER #define HEADER @@ -60,6 +62,7 @@ int foo() { return 0; } int b = 15; int d; S globals(d); +static S stat(d); #pragma omp end declare target int c; Modified: cfe/trunk/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp?rev=338139=338138=338139=diff == --- cfe/trunk/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp (original) +++ cfe/trunk/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp Fri Jul 27 10:37:32 2018 @@ -15,7 +15,7 @@ // SIMD-ONLY-NOT: {{__kmpc|__tgt}} -// DEVICE-DAG: [[C_ADDR:.+]] = internal global i32 0, +// DEVICE-DAG: [[C_ADDR:.+]] = weak_odr global i32 0, // DEVICE-DAG: [[CD_ADDR:@.+]] = global %struct.S zeroinitializer, // HOST-DAG: @[[C_ADDR:.+]] = internal global i32 0, // HOST-DAG: @[[CD_ADDR:.+]] = global %struct.S zeroinitializer, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49589: [UBSan] Strengthen pointer checks in 'new' expressions
sepavloff added a comment. @rjmccall Thank you! Repository: rC Clang https://reviews.llvm.org/D49589 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxxabi] r338138 - [demangler] Support for reference collapsing
Author: epilk Date: Fri Jul 27 10:27:40 2018 New Revision: 338138 URL: http://llvm.org/viewvc/llvm-project?rev=338138=rev Log: [demangler] Support for reference collapsing llvm.org/PR38323 Modified: libcxxabi/trunk/src/cxa_demangle.cpp libcxxabi/trunk/test/test_demangle.pass.cpp Modified: libcxxabi/trunk/src/cxa_demangle.cpp URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=338138=338137=338138=diff == --- libcxxabi/trunk/src/cxa_demangle.cpp (original) +++ libcxxabi/trunk/src/cxa_demangle.cpp Fri Jul 27 10:27:40 2018 @@ -25,11 +25,10 @@ #include #include #include +#include #include - namespace { - enum : int { demangle_unknown_error = -4, demangle_invalid_args = -3, @@ -55,8 +54,7 @@ public: KEnableIfAttr, KObjCProtoName, KPointerType, -KLValueReferenceType, -KRValueReferenceType, +KReferenceType, KPointerToMemberType, KArrayType, KFunctionType, @@ -137,6 +135,12 @@ public: virtual bool hasArraySlow(OutputStream &) const { return false; } virtual bool hasFunctionSlow(OutputStream &) const { return false; } + // Dig through "glue" nodes like ParameterPack and ForwardTemplateReference to + // get at a node that actually represents some concrete syntax. + virtual const Node *getSyntaxNode(OutputStream &) const { +return this; + } + void print(OutputStream ) const { printLeft(S); if (RHSComponentCache != Cache::No) @@ -447,60 +451,56 @@ public: } }; -class LValueReferenceType final : public Node { - const Node *Pointee; - -public: - LValueReferenceType(Node *Pointee_) - : Node(KLValueReferenceType, Pointee_->RHSComponentCache), -Pointee(Pointee_) {} - - bool hasRHSComponentSlow(OutputStream ) const override { -return Pointee->hasRHSComponent(S); - } - - void printLeft(OutputStream ) const override { -Pointee->printLeft(s); -if (Pointee->hasArray(s)) - s += " "; -if (Pointee->hasArray(s) || Pointee->hasFunction(s)) - s += "(&"; -else - s += "&"; - } - void printRight(OutputStream ) const override { -if (Pointee->hasArray(s) || Pointee->hasFunction(s)) - s += ")"; -Pointee->printRight(s); - } +enum class ReferenceKind { + LValue, + RValue, }; -class RValueReferenceType final : public Node { +// Represents either a LValue or an RValue reference type. +class ReferenceType : public Node { const Node *Pointee; + ReferenceKind RK; + + // Dig through any refs to refs, collapsing the ReferenceTypes as we go. The + // rule here is rvalue ref to rvalue ref collapses to a rvalue ref, and any + // other combination collapses to a lvalue ref. + std::pair collapse(OutputStream ) const { +auto SoFar = std::make_pair(RK, Pointee); +for (;;) { + const Node *SN = SoFar.second->getSyntaxNode(S); + if (SN->getKind() != KReferenceType) +break; + auto *RT = static_cast(SN); + SoFar.second = RT->Pointee; + SoFar.first = std::min(SoFar.first, RT->RK); +} +return SoFar; + } public: - RValueReferenceType(Node *Pointee_) - : Node(KRValueReferenceType, Pointee_->RHSComponentCache), -Pointee(Pointee_) {} + ReferenceType(Node *Pointee_, ReferenceKind RK_) + : Node(KReferenceType, Pointee_->RHSComponentCache), +Pointee(Pointee_), RK(RK_) {} bool hasRHSComponentSlow(OutputStream ) const override { return Pointee->hasRHSComponent(S); } void printLeft(OutputStream ) const override { -Pointee->printLeft(s); -if (Pointee->hasArray(s)) +std::pair Collapsed = collapse(s); +Collapsed.second->printLeft(s); +if (Collapsed.second->hasArray(s)) s += " "; -if (Pointee->hasArray(s) || Pointee->hasFunction(s)) - s += "(&&"; -else - s += "&&"; - } +if (Collapsed.second->hasArray(s) || Collapsed.second->hasFunction(s)) + s += "("; +s += (Collapsed.first == ReferenceKind::LValue ? "&" : "&&"); + } void printRight(OutputStream ) const override { -if (Pointee->hasArray(s) || Pointee->hasFunction(s)) +std::pair Collapsed = collapse(s); +if (Collapsed.second->hasArray(s) || Collapsed.second->hasFunction(s)) s += ")"; -Pointee->printRight(s); +Collapsed.second->printRight(s); } }; @@ -919,6 +919,11 @@ public: size_t Idx = S.CurrentPackIndex; return Idx < Data.size() && Data[Idx]->hasFunction(S); } + const Node *getSyntaxNode(OutputStream ) const override { +initializePackExpansion(S); +size_t Idx = S.CurrentPackIndex; +return Idx < Data.size() ? Data[Idx]->getSyntaxNode(S) : this; + } void printLeft(OutputStream ) const override { initializePackExpansion(S); @@ -1046,6 +1051,12 @@ struct ForwardTemplateReference : Node { SwapAndRestore SavePrinting(Printing, true); return Ref->hasFunction(S); } + const Node
r338137 - [ASTMatchers] Introduce a matcher for `ObjCIvarExpr`, support getting it's declaration.
Author: george.karpenkov Date: Fri Jul 27 10:26:11 2018 New Revision: 338137 URL: http://llvm.org/viewvc/llvm-project?rev=338137=rev Log: [ASTMatchers] Introduce a matcher for `ObjCIvarExpr`, support getting it's declaration. ObjCIvarExpr is *not* a subclass of MemberExpr, and a separate matcher is required to support it. Adding a hasDeclaration support as well, as it's not very useful without it. Differential Revision: https://reviews.llvm.org/D49701 Modified: cfe/trunk/docs/LibASTMatchersReference.html cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp Modified: cfe/trunk/docs/LibASTMatchersReference.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=338137=338136=338137=diff == --- cfe/trunk/docs/LibASTMatchersReference.html (original) +++ cfe/trunk/docs/LibASTMatchersReference.html Fri Jul 27 10:26:11 2018 @@ -1267,6 +1267,20 @@ Example matches @finally +Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtobjcIvarRefExprMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCIvarRefExpr.html;>ObjCIvarRefExpr... +Matches a reference to an ObjCIvar. + +Example: matches "a" in "init" method: +@implementation A { + NSString *a; +} +- (void) init { + a = @"hello"; +} +} + + + Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtobjcMessageExprMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html;>ObjCMessageExpr... Matches ObjectiveC Message invocation expressions. @@ -4251,6 +4265,7 @@ The associated declaration is: - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor - for CXXNewExpr, the declaration of the operator new +- for ObjCIvarExpr, the declaration of the ivar For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given @@ -4547,6 +4562,7 @@ The associated declaration is: - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor - for CXXNewExpr, the declaration of the operator new +- for ObjCIvarExpr, the declaration of the ivar For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given @@ -4750,6 +4766,7 @@ The associated declaration is: - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor - for CXXNewExpr, the declaration of the operator new +- for ObjCIvarExpr, the declaration of the ivar For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given @@ -4900,6 +4917,7 @@ The associated declaration is: - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor - for CXXNewExpr, the declaration of the operator new +- for ObjCIvarExpr, the declaration of the ivar For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given @@ -5061,6 +5079,7 @@ The associated declaration is: - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor - for CXXNewExpr, the declaration of the operator new +- for ObjCIvarExpr, the declaration of the ivar For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given @@ -5247,6 +5266,7 @@ The associated declaration is: - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor - for CXXNewExpr, the declaration of the operator new +- for ObjCIvarExpr, the declaration of the ivar For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given @@ -5667,6 +5687,7 @@ The associated declaration is: - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor - for CXXNewExpr, the declaration of the operator new +- for ObjCIvarExpr, the declaration of the ivar For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given @@ -5700,6 +5721,7 @@ The associated declaration is: - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor - for CXXNewExpr, the declaration of the operator new +- for ObjCIvarExpr, the declaration of the ivar For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given @@ -5733,6 +5755,7 @@ The associated declaration is: - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor - for
[PATCH] D49701: [ASTMatchers] Introduce a matcher for `ObjCIvarExpr`, support getting it's declaration
This revision was automatically updated to reflect the committed changes. Closed by commit rL338137: [ASTMatchers] Introduce a matcher for `ObjCIvarExpr`, support getting its… (authored by george.karpenkov, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D49701?vs=157520=157705#toc Repository: rL LLVM https://reviews.llvm.org/D49701 Files: cfe/trunk/docs/LibASTMatchersReference.html cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp Index: cfe/trunk/docs/LibASTMatchersReference.html === --- cfe/trunk/docs/LibASTMatchersReference.html +++ cfe/trunk/docs/LibASTMatchersReference.html @@ -1267,6 +1267,20 @@ +Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtobjcIvarRefExprMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCIvarRefExpr.html;>ObjCIvarRefExpr... +Matches a reference to an ObjCIvar. + +Example: matches "a" in "init" method: +@implementation A { + NSString *a; +} +- (void) init { + a = @"hello"; +} +} + + + Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtobjcMessageExprMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html;>ObjCMessageExpr... Matches ObjectiveC Message invocation expressions. @@ -4251,6 +4265,7 @@ - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor - for CXXNewExpr, the declaration of the operator new +- for ObjCIvarExpr, the declaration of the ivar For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given @@ -4547,6 +4562,7 @@ - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor - for CXXNewExpr, the declaration of the operator new +- for ObjCIvarExpr, the declaration of the ivar For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given @@ -4750,6 +4766,7 @@ - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor - for CXXNewExpr, the declaration of the operator new +- for ObjCIvarExpr, the declaration of the ivar For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given @@ -4900,6 +4917,7 @@ - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor - for CXXNewExpr, the declaration of the operator new +- for ObjCIvarExpr, the declaration of the ivar For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given @@ -5061,6 +5079,7 @@ - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor - for CXXNewExpr, the declaration of the operator new +- for ObjCIvarExpr, the declaration of the ivar For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given @@ -5247,6 +5266,7 @@ - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor - for CXXNewExpr, the declaration of the operator new +- for ObjCIvarExpr, the declaration of the ivar For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given @@ -5667,6 +5687,7 @@ - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor - for CXXNewExpr, the declaration of the operator new +- for ObjCIvarExpr, the declaration of the ivar For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given @@ -5700,6 +5721,7 @@ - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor - for CXXNewExpr, the declaration of the operator new +- for ObjCIvarExpr, the declaration of the ivar For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given @@ -5733,6 +5755,7 @@ - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor - for CXXNewExpr, the declaration of the operator new +- for ObjCIvarExpr, the declaration of the ivar For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given @@ -6093,6 +6116,7 @@ - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor - for CXXNewExpr, the declaration of the operator new +- for ObjCIvarExpr, the declaration of the ivar For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given @@
[PATCH] D47154: Try to make builtin address space declarations not useless
yaxunl added a comment. In https://reviews.llvm.org/D47154#1108813, @tra wrote: > CUDA does not expose explicit AS on clang size. All pointers are treated as > generic and we infer specific address space only in LLVM. > `__nvvm_atom_*_[sg]_*` builtins should probably be removed as they are > indeed useless without pointers with explicit AS and NVCC itself does not > have such builtins either. Instead, we should convert the generic AS builtin > to address-space specific instruction somewhere in LLVM. > > Using `attribute((address_space())` should probably produce an error during > CUDA compilation. Sometimes we need to call functions defined in our device library which is written in OpenCL. Some function have pointer arguments in non-zero address space. To declare these functions in CUDA/HIP we need to use `__attribute__((address_space()))`. We use C-style cast to cast pointers in CUDA/HIP to a non-zero address space and pass them to the functions. I think `__attribute__((address_space()))` is still needed for this situation. https://reviews.llvm.org/D47154 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49758: [clangd] allow clients to pass in compilationDatabaseChanges in the 'workspace/didChangeConfiguration' request
arphaman added a comment. In https://reviews.llvm.org/D49758#1178056, @ilya-biryukov wrote: > In https://reviews.llvm.org/D49758#1177747, @arphaman wrote: > > > In https://reviews.llvm.org/D49758#1174629, @ilya-biryukov wrote: > > > > > The mode of operation where compile commands come from the client seems > > > useful, but I wonder if there's any value in mixing it with > > > `compile_commands.json` and other CDB plugins. > > > Do you plan to use the overridden commands in conjunction with CDB > > > plugins or do you want the client to exclusively control the compile > > > commands? > > > > > > The client will control the commands exclusively. > > > Maybe a cleaner design would be to untangle the two use-cases and control > them with a flag to clangd? > I.e. we can have two implementations of compilation databases in clangd: > > - one that uses clang tooling capabilities, i.e. reads compile_commands.json, > etc. > - one that gets all compile commands from the protocol and won't use the > clang tooling. The command-line arg to clangd will control which > implementation is used. > > The advantage is that we don't have to think about interactions between the > clang plugins and explicit overrides and it should be easier to make sure > that we don't accidentally read compilation args from the wrong place. Would > also help to keep DirectoryBasedCompilationDatabase a bit simpler, and the > other implementation would be extremely simple. WDYT? Sounds good to me. I'll update the patch to do that. I'll add the flag as well. We won't be setting this flag directly though, our XPC protocol will assume it, but that's fine for us. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D49758 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D49898: Make test/Driver/baremetal.cpp work with linkers other than lld
LGTM Jon On Thu, Jul 26, 2018 at 10:12 PM David Greene via Phabricator < revi...@reviews.llvm.org> wrote: > greened created this revision. > greened added reviewers: jroelofs, hans, probinson, ismail, rtrieu. > Herald added a subscriber: cfe-commits. > > This test fails if clang is configure with, for example, gold as the > default linker. It does not appear that this test really relies on lld so > make the checks accept ld, ld.gold and ld.bfd too. > > > Repository: > rC Clang > > https://reviews.llvm.org/D49898 > > Files: > test/Driver/baremetal.cpp > > > Index: test/Driver/baremetal.cpp > === > --- test/Driver/baremetal.cpp > +++ test/Driver/baremetal.cpp > @@ -10,7 +10,7 @@ > // CHECK-V6M-C-SAME: "-internal-isystem" > "[[SYSROOT]]{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1" > // CHECk-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include" > // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp" > -// CHECK-V6M-C-NEXT: "{{[^"]*}}ld.lld{{(\.exe)?}}" "{{.*}}.o" "-Bstatic" > +// CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" > "{{.*}}.o" "-Bstatic" > // CHECK-V6M-C-SAME: > "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal" > // CHECK-V6M-C-SAME: "-T" "semihosted.lds" > "-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for" > // CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a" > @@ -32,7 +32,7 @@ > // RUN: -target armv6m-none-eabi \ > // RUN: --sysroot=%S/Inputs/baremetal_arm \ > // RUN: | FileCheck --check-prefix=CHECK-V6M-DEFAULTCXX %s > -// CHECK-V6M-DEFAULTCXX: "{{[^"]*}}ld.lld{{(\.exe)?}}" "{{.*}}.o" > "-Bstatic" > +// CHECK-V6M-DEFAULTCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" > "{{.*}}.o" "-Bstatic" > // CHECK-V6M-DEFAULTCXX-SAME: > "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal" > // CHECK-V6M-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind" > // CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a" > @@ -45,7 +45,7 @@ > // RUN: | FileCheck --check-prefix=CHECK-V6M-LIBCXX %s > // CHECK-V6M-LIBCXX-NOT: "-internal-isystem" > "{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}{{[^v].*}}" > // CHECK-V6M-LIBCXX: "-internal-isystem" > "{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1" > -// CHECK-V6M-LIBCXX: "{{[^"]*}}ld.lld{{(\.exe)?}}" "{{.*}}.o" "-Bstatic" > +// CHECK-V6M-LIBCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" > "{{.*}}.o" "-Bstatic" > // CHECK-V6M-LIBCXX-SAME: > "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal" > // CHECK-V6M-LIBCXX-SAME: "-lc++" "-lc++abi" "-lunwind" > // CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a" > @@ -58,7 +58,7 @@ > // RUN: | FileCheck --check-prefix=CHECK-V6M-LIBSTDCXX %s > // CHECK-V6M-LIBSTDCXX-NOT: "-internal-isystem" > "{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1" > // CHECK-V6M-LIBSTDCXX: "-internal-isystem" > "{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}6.0.0" > -// CHECK-V6M-LIBSTDCXX: "{{[^"]*}}ld.lld{{(\.exe)?}}" "{{.*}}.o" > "-Bstatic" > +// CHECK-V6M-LIBSTDCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" > "{{.*}}.o" "-Bstatic" > // CHECK-V6M-LIBSTDCXX-SAME: > "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal" > // CHECK-V6M-LIBSTDCXX-SAME: "-lstdc++" "-lsupc++" "-lunwind" > // CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a" > @@ -69,7 +69,7 @@ > // RUN: --sysroot=%S/Inputs/baremetal_arm \ > // RUN: -nodefaultlibs \ > // RUN: | FileCheck --check-prefix=CHECK-V6M-NDL %s > -// CHECK-V6M-NDL: "{{[^"]*}}ld.lld{{(\.exe)?}}" "{{.*}}.o" "-Bstatic" > +// CHECK-V6M-NDL: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" > "{{.*}}.o" "-Bstatic" > // CHECK-V6M-NDL-SAME: > "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal" > "-o" "{{.*}}.o" > > // RUN: %clangxx -target arm-none-eabi -v 2>&1 \ > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits