Re: [PATCH] D42966: Fix USR generation in the presence of #line directives or linemarkes
> > Why wasn't there a file for function parameter? Function parameters *are* > declared in some file, or am I missing something? > > They are declared in some file defined by the line markers; the file are not registered in the SourceManager as actual files, so getting the FileEntry will always fail, that's why I changed it to get the PresumedLoc. More general question is: how do we want USRs for function parameters to > work, specifically should USR of the same param of different declarations > be the same or different? > That's a good point, this patch will generated different names for the same function param if a function is first defined then declared somewhere else. I guess it should follow the USR generation pattern for FunctionDecls, what do you think? -- Mikhail Ramalho. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45755: [Sema] Do not match function type with const T in template argument deduction
rjmccall accepted this revision. rjmccall added a comment. This revision is now accepted and ready to land. Fix seems right. Repository: rC Clang https://reviews.llvm.org/D45755 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46042: Cap vector alignment at 16 for all Darwin platforms
rjmccall created this revision. Herald added a reviewer: javed.absar. Herald added subscribers: cfe-commits, kristof.beyls. This fixes two major problems: - We were not capping vector alignment as desired on 32-bit ARM. - We were using different alignments based on the AVX settings on Intel, so we did not have a consistent ABI. This is an ABI break, but we think we can get away with it because vectors tend to be used mostly in inline code (which is why not having a consistent ABI has not proven disastrous on Intel). Intel's AVX types are specified as having 32-byte / 64-byte alignment, so align them explicitly instead of relying on the base ABI rule. Note that this sort of attribute is stripped from template arguments in template substitution, so there's a possibility that code templated over vectors will produce inadequately-aligned objects. Repository: rC Clang https://reviews.llvm.org/D46042 Files: lib/Basic/Targets/OSTargets.h lib/Basic/Targets/X86.h lib/CodeGen/CGBuiltin.cpp lib/Headers/avx512fintrin.h lib/Headers/avxintrin.h test/CodeGen/arm-swiftcall.c test/CodeGen/vector-alignment.c test/CodeGenCXX/align-avx-complete-objects.cpp Index: test/CodeGenCXX/align-avx-complete-objects.cpp === --- test/CodeGenCXX/align-avx-complete-objects.cpp +++ test/CodeGenCXX/align-avx-complete-objects.cpp @@ -12,7 +12,7 @@ return r[0]; } -// CHECK: [[R:%.*]] = alloca <8 x float>, align 32 +// CHECK: [[R:%.*]] = alloca <8 x float>, align 16 // CHECK-NEXT: [[CALL:%.*]] = call i8* @_Znwm(i64 32) // CHECK-NEXT: [[ZERO:%.*]] = bitcast i8* [[CALL]] to <8 x float>* // CHECK-NEXT: store <8 x float>* [[ZERO]], <8 x float>** [[P:%.*]], align 8 @@ -22,8 +22,8 @@ // CHECK-NEXT: store volatile <8 x float> [[TWO]], <8 x float>* [[THREE]], align 16 // CHECK-NEXT: [[FOUR:%.*]] = load <8 x float>*, <8 x float>** [[P]], align 8 // CHECK-NEXT: [[FIVE:%.*]] = load volatile <8 x float>, <8 x float>* [[FOUR]], align 16 -// CHECK-NEXT: store <8 x float> [[FIVE]], <8 x float>* [[R]], align 32 -// CHECK-NEXT: [[SIX:%.*]] = load <8 x float>, <8 x float>* [[R]], align 32 +// CHECK-NEXT: store <8 x float> [[FIVE]], <8 x float>* [[R]], align 16 +// CHECK-NEXT: [[SIX:%.*]] = load <8 x float>, <8 x float>* [[R]], align 16 // CHECK-NEXT: [[VECEXT:%.*]] = extractelement <8 x float> [[SIX]], i32 0 // CHECK-NEXT: ret float [[VECEXT]] Index: test/CodeGen/vector-alignment.c === --- test/CodeGen/vector-alignment.c +++ test/CodeGen/vector-alignment.c @@ -1,38 +1,68 @@ // RUN: %clang_cc1 -w -triple x86_64-apple-darwin10 \ -// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=ALL --check-prefix=SSE +// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=ALL --check-prefix=DARWIN_SSE // RUN: %clang_cc1 -w -triple i386-apple-darwin10 \ -// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=ALL --check-prefix=SSE +// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=ALL --check-prefix=DARWIN_SSE // RUN: %clang_cc1 -w -triple x86_64-apple-darwin10 -target-feature +avx \ -// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=ALL --check-prefix=AVX +// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=ALL --check-prefix=DARWIN_AVX // RUN: %clang_cc1 -w -triple i386-apple-darwin10 -target-feature +avx \ -// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=ALL --check-prefix=AVX +// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=ALL --check-prefix=DARWIN_AVX // RUN: %clang_cc1 -w -triple x86_64-apple-darwin10 -target-feature +avx512f \ -// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=ALL --check-prefix=AVX512 +// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=ALL --check-prefix=DARWIN_AVX512 // RUN: %clang_cc1 -w -triple i386-apple-darwin10 -target-feature +avx512f \ -// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=ALL --check-prefix=AVX512 +// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=ALL --check-prefix=DARWIN_AVX512 +// RUN: %clang_cc1 -w -triple armv7-apple-ios10 \ +// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=ALL --check-prefix=DARWIN_ARM32 +// RUN: %clang_cc1 -w -triple arm64-apple-ios10 \ +// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=ALL --check-prefix=DARWIN_ARM64 + +// RUN: %clang_cc1 -w -triple x86_64-pc-linux \ +// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=ALL --check-prefix=GENERIC +// RUN: %clang_cc1 -w -triple i386-pc-linux \ +// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=ALL --check-prefix=GENERIC +// RUN: %clang_cc1 -w -triple x86_64-pc-linux -target-feature +avx \ +// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=ALL --check-prefix=GENERIC +// RUN: %clang_cc1 -w -triple i386-pc-linux -target-feature +avx \ +// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=ALL --check-prefix=GENERIC +// RUN: %cl
r330798 - [NFC] Make dependent parameter non-deducible, so that we are forced to use the default template parameter.
Author: faisalv Date: Tue Apr 24 20:54:20 2018 New Revision: 330798 URL: http://llvm.org/viewvc/llvm-project?rev=330798&view=rev Log: [NFC] Make dependent parameter non-deducible, so that we are forced to use the default template parameter. This might provide users with more graceful diagnostics if they should ever try and call this function with non-ConceptDecls. Modified: cfe/trunk/include/clang/Sema/DeclSpec.h Modified: cfe/trunk/include/clang/Sema/DeclSpec.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=330798&r1=330797&r2=330798&view=diff == --- cfe/trunk/include/clang/Sema/DeclSpec.h (original) +++ cfe/trunk/include/clang/Sema/DeclSpec.h Tue Apr 24 20:54:20 2018 @@ -699,7 +699,8 @@ public: // This function can only be instantiated with ConceptDecl. We made it a // template so that ConceptDecl only has to be defined where this is called. template - void setConceptRep(ConceptDeclTy *Rep) { + void + setConceptRep(typename llvm::identity::argument_type *Rep) { static_assert(std::is_same::value, "Must only be instantiated with ConceptDecl"); assert(isConceptSpecified() && "DeclSpec does not store a concept"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330796 - Fix rC330794 - a parameter that should have been dependent was inadvertently not -
Author: faisalv Date: Tue Apr 24 20:28:23 2018 New Revision: 330796 URL: http://llvm.org/viewvc/llvm-project?rev=330796&view=rev Log: Fix rC330794 - a parameter that should have been dependent was inadvertently not - and compiled in MSVC - but not so for the other bots. The fix was to make it dependent as intended. Modified: cfe/trunk/include/clang/Sema/DeclSpec.h Modified: cfe/trunk/include/clang/Sema/DeclSpec.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=330796&r1=330795&r2=330796&view=diff == --- cfe/trunk/include/clang/Sema/DeclSpec.h (original) +++ cfe/trunk/include/clang/Sema/DeclSpec.h Tue Apr 24 20:28:23 2018 @@ -520,6 +520,8 @@ public: return cast_or_null(DeclRep); } + + Expr *getRepAsExpr() const { assert(isExprRep((TST) TypeSpecType) && "DeclSpec does not store an expr"); return ExprRep; @@ -697,7 +699,7 @@ public: // This function can only be instantiated with ConceptDecl. We made it a // template so that ConceptDecl only has to be defined where this is called. template - void setConceptRep(ConceptDecl *Rep) { + void setConceptRep(ConceptDeclTy *Rep) { static_assert(std::is_same::value, "Must only be instantiated with ConceptDecl"); assert(isConceptSpecified() && "DeclSpec does not store a concept"); @@ -706,7 +708,7 @@ public: "once, and usually right after DeclRep was set to null"); DeclRep = Rep; } - + void UpdateTypeRep(ParsedType Rep) { assert(isTypeRep((TST) TypeSpecType)); TypeRep = Rep; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330795 - Fix lit test kernel-call.cu failure on ps4 due to dso_local
Author: yaxunl Date: Tue Apr 24 20:16:07 2018 New Revision: 330795 URL: http://llvm.org/viewvc/llvm-project?rev=330795&view=rev Log: Fix lit test kernel-call.cu failure on ps4 due to dso_local Modified: cfe/trunk/test/CodeGenCUDA/kernel-call.cu Modified: cfe/trunk/test/CodeGenCUDA/kernel-call.cu URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/kernel-call.cu?rev=330795&r1=330794&r2=330795&view=diff == --- cfe/trunk/test/CodeGenCUDA/kernel-call.cu (original) +++ cfe/trunk/test/CodeGenCUDA/kernel-call.cu Tue Apr 24 20:16:07 2018 @@ -4,14 +4,14 @@ #include "Inputs/cuda.h" -// CHECK-LABEL: define void @_Z2g1i +// CHECK-LABEL: define{{.*}} void @_Z2g1i // HIP: call{{.*}}hipSetupArgument // HIP: call{{.*}}hipLaunchByPtr // CUDA: call{{.*}}cudaSetupArgument // CUDA: call{{.*}}cudaLaunch __global__ void g1(int x) {} -// CHECK-LABEL: define i32 @main +// CHECK-LABEL: define{{.*}} i32 @main int main(void) { // HIP: call{{.*}}hipConfigureCall // CUDA: call{{.*}}cudaConfigureCall ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330794 - [c++2a] [concepts] Add rudimentary parsing support for template concept declarations
Author: faisalv Date: Tue Apr 24 19:42:26 2018 New Revision: 330794 URL: http://llvm.org/viewvc/llvm-project?rev=330794&view=rev Log: [c++2a] [concepts] Add rudimentary parsing support for template concept declarations This patch is a tweak of changyu's patch: https://reviews.llvm.org/D40381. It differs in that the recognition of the 'concept' token is moved into the machinery that recognizes declaration-specifiers - this allows us to leverage the attribute handling machinery more seamlessly. See the test file to get a sense of the basic parsing that this patch supports. There is much more work to be done before concepts are usable... Thanks Changyu! Added: cfe/trunk/test/Parser/cxx2a-concept-declaration.cpp Removed: cfe/trunk/test/Parser/cxx-concept-declaration.cpp Modified: cfe/trunk/include/clang/AST/DeclTemplate.h cfe/trunk/include/clang/AST/RecursiveASTVisitor.h cfe/trunk/include/clang/Basic/DeclNodes.td cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Basic/TemplateKinds.h cfe/trunk/include/clang/Parse/Parser.h cfe/trunk/include/clang/Sema/DeclSpec.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/include/clang/Serialization/ASTBitCodes.h cfe/trunk/lib/AST/ASTDumper.cpp cfe/trunk/lib/AST/DeclBase.cpp cfe/trunk/lib/AST/DeclTemplate.cpp cfe/trunk/lib/CodeGen/CGDecl.cpp cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/Parse/ParseDecl.cpp cfe/trunk/lib/Parse/ParseDeclCXX.cpp cfe/trunk/lib/Parse/ParseObjc.cpp cfe/trunk/lib/Parse/ParseTemplate.cpp cfe/trunk/lib/Parse/ParseTentative.cpp cfe/trunk/lib/Parse/Parser.cpp cfe/trunk/lib/Sema/DeclSpec.cpp cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaDeclCXX.cpp cfe/trunk/lib/Sema/SemaTemplate.cpp cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp cfe/trunk/lib/Serialization/ASTCommon.cpp cfe/trunk/lib/Serialization/ASTReaderDecl.cpp cfe/trunk/lib/Serialization/ASTWriter.cpp cfe/trunk/lib/Serialization/ASTWriterDecl.cpp cfe/trunk/tools/libclang/CIndex.cpp Modified: cfe/trunk/include/clang/AST/DeclTemplate.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=330794&r1=330793&r2=330794&view=diff == --- cfe/trunk/include/clang/AST/DeclTemplate.h (original) +++ cfe/trunk/include/clang/AST/DeclTemplate.h Tue Apr 24 19:42:26 2018 @@ -3015,6 +3015,46 @@ public: static bool classofKind(Kind K) { return K == VarTemplate; } }; +/// \brief Represents a C++2a ([temp] p1) concept-definition. +class ConceptDecl : public TemplateDecl { +protected: + Expr *ConstraintExpr; + + ConceptDecl(DeclContext *DC, + SourceLocation NameLoc, DeclarationName Name, + TemplateParameterList *Params, + Expr *ConstraintExpr) + : TemplateDecl(nullptr, Concept, DC, NameLoc, Name, Params), +ConstraintExpr(ConstraintExpr) {}; +public: + static ConceptDecl *Create(ASTContext &C, DeclContext *DC, + SourceLocation NameLoc, DeclarationName Name, + TemplateParameterList *Params, + Expr *ConstraintExpr); + static ConceptDecl *CreateDeserialized(ASTContext &C, unsigned ID); + + Expr *getConstraintExpr() const { +return ConstraintExpr; + } + + void setConstraintExpr(Expr *CE) { +ConstraintExpr = CE; + } + + SourceRange getSourceRange() const override LLVM_READONLY { +return SourceRange(getTemplateParameters()->getTemplateLoc(), + getConstraintExpr()->getLocEnd()); + } + + // Implement isa/cast/dyncast/etc. + static bool classof(const Decl *D) { return classofKind(D->getKind()); } + static bool classofKind(Kind K) { return K == Concept; } + + friend class ASTReader; + friend class ASTDeclReader; + friend class ASTDeclWriter; +}; + inline NamedDecl *getAsNamedDecl(TemplateParameter P) { if (auto *PD = P.dyn_cast()) return PD; Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=330794&r1=330793&r2=330794&view=diff == --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original) +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Tue Apr 24 19:42:26 2018 @@ -1722,6 +1722,13 @@ DEF_TRAVERSE_TMPL_DECL(Class) DEF_TRAVERSE_TMPL_DECL(Var) DEF_TRAVERSE_TMPL_DECL(Function) +DEF_TRAVERSE_DECL(ConceptDecl, { + TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); + TRY_TO(TraverseStmt(D->getConstraintExpr())); + // FIXME: Traverse all the concept specializations (once we implement forming + // template-ids with them). +}) + DEF_TRAVERSE_DECL(TemplateTemplateParmDecl, {
r330793 - Fix failure in lit test kernel-call.cu
Author: yaxunl Date: Tue Apr 24 19:34:04 2018 New Revision: 330793 URL: http://llvm.org/viewvc/llvm-project?rev=330793&view=rev Log: Fix failure in lit test kernel-call.cu There is signext on ppc64. Just remove check for function argument. Modified: cfe/trunk/test/CodeGenCUDA/kernel-call.cu Modified: cfe/trunk/test/CodeGenCUDA/kernel-call.cu URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/kernel-call.cu?rev=330793&r1=330792&r2=330793&view=diff == --- cfe/trunk/test/CodeGenCUDA/kernel-call.cu (original) +++ cfe/trunk/test/CodeGenCUDA/kernel-call.cu Tue Apr 24 19:34:04 2018 @@ -4,7 +4,7 @@ #include "Inputs/cuda.h" -// CHECK-LABEL: define void @_Z2g1i(i32 %x) +// CHECK-LABEL: define void @_Z2g1i // HIP: call{{.*}}hipSetupArgument // HIP: call{{.*}}hipLaunchByPtr // CUDA: call{{.*}}cudaSetupArgument ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45294: [libcxx] [test] Remove non-portable assertions from filebuf tests
BillyONeal added a comment. @mclow.lists Are you OK with this one? It's conceptually similar to the previous review. https://reviews.llvm.org/D45294 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45715: [libcxx] [test] Remove nonportable that errc::is_a_directory produces "Is a directory" from ios_base::failure tests
BillyONeal closed this revision. BillyONeal added a comment. D:\msvc\src\qa\VC\Libs\libcxx\upstream>git svn dcommit Committing to https://llvm.org/svn/llvm-project/libcxx/trunk ... Authentication realm: https://llvm.org:443 LLVM Subversion repository Password for 'bion': M test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_char_pointer_error_code.pass.cpp M test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp Committed r330791 M test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_char_pointer_error_code.pass.cpp M test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp r330791 = efac6e5df9109748822bd3b5b533b35257a110f4 (refs/remotes/llvm/master) No changes between e69aef2e1f9cb3ad085a9ddcc2f432f8f7c8c182 and refs/remotes/llvm/master Resetting to the latest refs/remotes/llvm/master https://reviews.llvm.org/D45715 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r330791 - [libcxx] [test] Remove nonportable that errc::is_a_directory produces "Is a directory" from ios_base::failure tests
Author: bion Date: Tue Apr 24 18:58:55 2018 New Revision: 330791 URL: http://llvm.org/viewvc/llvm-project?rev=330791&view=rev Log: [libcxx] [test] Remove nonportable that errc::is_a_directory produces "Is a directory" from ios_base::failure tests These io_error asserts that std::errc::is_a_directory has message "Is a directory". On MSVC++ it reports "is a directory" (with a lowercase I). That doesn't matter for the ios_failure component being tested, so just implement in terms of system_category().message(). Reviewed as https://reviews.llvm.org/D45715 Modified: libcxx/trunk/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_char_pointer_error_code.pass.cpp libcxx/trunk/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp Modified: libcxx/trunk/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_char_pointer_error_code.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_char_pointer_error_code.pass.cpp?rev=330791&r1=330790&r2=330791&view=diff == --- libcxx/trunk/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_char_pointer_error_code.pass.cpp (original) +++ libcxx/trunk/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_char_pointer_error_code.pass.cpp Tue Apr 24 18:58:55 2018 @@ -15,6 +15,7 @@ #include #include +#include #include int main() @@ -25,7 +26,8 @@ int main() assert(se.code() == std::make_error_code(std::errc::is_a_directory)); std::string what_message(se.what()); assert(what_message.find(what_arg) != std::string::npos); -assert(what_message.find("Is a directory") != std::string::npos); + assert(what_message.find(std::generic_category().message(static_cast +(std::errc::is_a_directory))) != std::string::npos); } { std::string what_arg("io test message"); Modified: libcxx/trunk/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp?rev=330791&r1=330790&r2=330791&view=diff == --- libcxx/trunk/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp (original) +++ libcxx/trunk/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp Tue Apr 24 18:58:55 2018 @@ -15,6 +15,7 @@ #include #include +#include #include int main() @@ -28,7 +29,8 @@ int main() assert(se.code() == std::make_error_code(std::errc::is_a_directory)); std::string what_message(se.what()); assert(what_message.find(what_arg) != std::string::npos); -assert(what_message.find("Is a directory") != std::string::npos); + assert(what_message.find(std::generic_category().message(static_cast +(std::errc::is_a_directory))) != std::string::npos); } { std::string what_arg("io test message"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44882: [clangd] Implementation of workspace/symbol request
malaperle added a comment. In https://reviews.llvm.org/D44882#1077516, @sammccall wrote: > It makes sense, but @bkramer came up with some deep magic in > https://reviews.llvm.org/rL330754 so I think we're actually good now. Nice! Thanks @bkramer ! Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D44882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45601: Warn on bool* to bool conversion
rjmccall added a comment. I agree that this is one of those warnings that just can't be done in any reasonable way. https://reviews.llvm.org/D45601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46037: [analyzer] pr37166, pr37139: Disable constructor inlining when lifetime extension through aggregate initialization occurs.
NoQ updated this revision to Diff 143850. NoQ added a comment. Add a test similar to pr37166. It should be actually fixed now with this patch. Essentially, we may also be lifetime-extended by an array of aggregate structures (with arbitrary amounts of interleaving array and aggregate structure brace-initializers). https://reviews.llvm.org/D46037 Files: include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h lib/StaticAnalyzer/Core/ExprEngineCXX.cpp lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp test/Analysis/lifetime-extension.cpp Index: test/Analysis/lifetime-extension.cpp === --- test/Analysis/lifetime-extension.cpp +++ test/Analysis/lifetime-extension.cpp @@ -147,6 +147,37 @@ // FIXME: Should be TRUE. Should not warn about garbage value. clang_analyzer_eval(after == before); // expected-warning{{UNKNOWN}} } + +struct A { // A is an aggregate. + const C &c; +}; + +void f6() { + C *after, *before; + { +A a{C(true, &after, &before)}; + } + // FIXME: Should be TRUE. Should not warn about garbage value. + clang_analyzer_eval(after == before); // expected-warning{{UNKNOWN}} +} + +void f7() { + C *after, *before; + { +A a = {C(true, &after, &before)}; + } + // FIXME: Should be TRUE. Should not warn about garbage value. + clang_analyzer_eval(after == before); // expected-warning{{UNKNOWN}} +} + +void f8() { + C *after, *before; + { +A a[2] = {C(false, nullptr, nullptr), C(true, &after, &before)}; + } + // FIXME: Should be TRUE. Should not warn about garbage value. + clang_analyzer_eval(after == before); // expected-warning{{UNKNOWN}} +} } // end namespace maintain_original_object_address_on_lifetime_extension namespace maintain_original_object_address_on_move { Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp === --- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp +++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp @@ -699,6 +699,11 @@ // within it to a reference, automatic destructors don't work properly. if (CallOpts.IsTemporaryLifetimeExtendedViaSubobject) return CIP_DisallowedOnce; + + // If the temporary is lifetime-extended by binding it to a reference-typ + // field within an aggregate, automatic destructors don't work properly. + if (CallOpts.IsTemporaryLifetimeExtendedViaAggregate) +return CIP_DisallowedOnce; } break; Index: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp === --- lib/StaticAnalyzer/Core/ExprEngineCXX.cpp +++ lib/StaticAnalyzer/Core/ExprEngineCXX.cpp @@ -180,14 +180,25 @@ } case ConstructionContext::TemporaryObjectKind: { const auto *TOCC = cast(CC); - // See if we're lifetime-extended via our field. If so, take a note. - // Because automatic destructors aren't quite working in this case. if (const auto *MTE = TOCC->getMaterializedTemporaryExpr()) { if (const ValueDecl *VD = MTE->getExtendingDecl()) { - assert(VD->getType()->isReferenceType()); - if (VD->getType()->getPointeeType().getCanonicalType() != - MTE->GetTemporaryExpr()->getType().getCanonicalType()) { -CallOpts.IsTemporaryLifetimeExtendedViaSubobject = true; + // Pattern-match various forms of lifetime extension that aren't + // currently supported by the CFG. + // FIXME: Is there a better way to retrieve this information from + // the MaterializeTemporaryExpr? + assert(MTE->getStorageDuration() != SD_FullExpression); + if (VD->getType()->isReferenceType()) { +assert(VD->getType()->isReferenceType()); +if (VD->getType()->getPointeeType().getCanonicalType() != +MTE->GetTemporaryExpr()->getType().getCanonicalType()) { + // We're lifetime-extended via our field. Automatic destructors + // aren't quite working in this case. + CallOpts.IsTemporaryLifetimeExtendedViaSubobject = true; +} + } else { +// We're lifetime-extended by a surrounding aggregate. +// Automatic destructors aren't quite working in this case. +CallOpts.IsTemporaryLifetimeExtendedViaAggregate = true; } } } Index: include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h === --- include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h @@ -110,6 +110,11 @@ /// 'const int &x = C().x;'. bool IsTemporaryLifetimeExtendedViaSubobject = false; +/// This call is a constructor for a temporary that is lifetime-extended +/// by binding it to a reference-type field within an aggregate, +/// for example
[PATCH] D46037: [analyzer] pr37166, pr37139: Disable constructor inlining when lifetime extension through aggregate initialization occurs.
NoQ created this revision. NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet. Herald added subscribers: cfe-commits, rnkovacs, baloghadamsoftware. This hotfix is similar to https://reviews.llvm.org/D43689 (and needs a follow-up similar to https://reviews.llvm.org/D44238 and https://reviews.llvm.org/D44239). CFG again doesn't provide us with correct automatic destructors, this time it's in the following code: struct A { const C &c; }; void foo() { A a = { C(); } } In this code `a` is an aggregate, so it doesn't require construction or destruction. Instead, `C()` is lifetime-extended until the end of `a`'s scope. Additionally, we used to crash on my defensive "i know C++" assertion (no, i don't). Repository: rC Clang https://reviews.llvm.org/D46037 Files: include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h lib/StaticAnalyzer/Core/ExprEngineCXX.cpp lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp test/Analysis/lifetime-extension.cpp Index: test/Analysis/lifetime-extension.cpp === --- test/Analysis/lifetime-extension.cpp +++ test/Analysis/lifetime-extension.cpp @@ -147,6 +147,30 @@ // FIXME: Should be TRUE. Should not warn about garbage value. clang_analyzer_eval(after == before); // expected-warning{{UNKNOWN}} } + +void f6() { + C *after, *before; + { +struct A { // A is an aggregate. + const C &c; +}; +A a{C(true, &after, &before)}; + } + // FIXME: Should be TRUE. Should not warn about garbage value. + clang_analyzer_eval(after == before); // expected-warning{{UNKNOWN}} +} + +void f7() { + C *after, *before; + { +struct A { // A is an aggregate. + const C &c; +}; +A a = {C(true, &after, &before)}; + } + // FIXME: Should be TRUE. Should not warn about garbage value. + clang_analyzer_eval(after == before); // expected-warning{{UNKNOWN}} +} } // end namespace maintain_original_object_address_on_lifetime_extension namespace maintain_original_object_address_on_move { Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp === --- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp +++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp @@ -699,6 +699,11 @@ // within it to a reference, automatic destructors don't work properly. if (CallOpts.IsTemporaryLifetimeExtendedViaSubobject) return CIP_DisallowedOnce; + + // If the temporary is lifetime-extended by binding it to a reference-typ + // field within an aggregate, automatic destructors don't work properly. + if (CallOpts.IsTemporaryLifetimeExtendedViaAggregate) +return CIP_DisallowedOnce; } break; Index: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp === --- lib/StaticAnalyzer/Core/ExprEngineCXX.cpp +++ lib/StaticAnalyzer/Core/ExprEngineCXX.cpp @@ -180,14 +180,22 @@ } case ConstructionContext::TemporaryObjectKind: { const auto *TOCC = cast(CC); - // See if we're lifetime-extended via our field. If so, take a note. - // Because automatic destructors aren't quite working in this case. if (const auto *MTE = TOCC->getMaterializedTemporaryExpr()) { if (const ValueDecl *VD = MTE->getExtendingDecl()) { - assert(VD->getType()->isReferenceType()); - if (VD->getType()->getPointeeType().getCanonicalType() != - MTE->GetTemporaryExpr()->getType().getCanonicalType()) { -CallOpts.IsTemporaryLifetimeExtendedViaSubobject = true; + if (const auto *RD = VD->getType()->getAsCXXRecordDecl()) { +// We're lifetime-extended by a surrounding aggregate. +// Automatic destructors aren't quite working in this case. +assert(RD->isAggregate()); +assert(RD != CE->getConstructor()->getParent()); +CallOpts.IsTemporaryLifetimeExtendedViaAggregate = true; + } else { +assert(VD->getType()->isReferenceType()); +if (VD->getType()->getPointeeType().getCanonicalType() != +MTE->GetTemporaryExpr()->getType().getCanonicalType()) { + // We're lifetime-extended via our field. Automatic destructors + // aren't quite working in this case. + CallOpts.IsTemporaryLifetimeExtendedViaSubobject = true; +} } } } Index: include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h === --- include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h @@ -110,6 +110,11 @@ /// 'const int &x = C().x;'. bool IsTemporaryLifetimeExtendedViaSubobject = false; +/// This call is a constructor for a temporary that is lifetime-exte
[PATCH] D44984: [HIP] Add hip input kind and codegen for kernel launching
This revision was automatically updated to reflect the committed changes. Closed by commit rL330790: [HIP] Add hip input kind and codegen for kernel launching (authored by yaxunl, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D44984?vs=143800&id=143849#toc Repository: rL LLVM https://reviews.llvm.org/D44984 Files: cfe/trunk/include/clang/Basic/IdentifierTable.h cfe/trunk/include/clang/Basic/LangOptions.def cfe/trunk/include/clang/Frontend/FrontendOptions.h cfe/trunk/include/clang/Frontend/LangStandards.def cfe/trunk/lib/CodeGen/CGCUDANV.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/lib/Frontend/FrontendActions.cpp cfe/trunk/lib/Frontend/InitPreprocessor.cpp cfe/trunk/lib/Sema/SemaCUDA.cpp cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/test/CodeGenCUDA/Inputs/cuda.h cfe/trunk/test/CodeGenCUDA/device-stub.cu cfe/trunk/test/CodeGenCUDA/kernel-call.cu Index: cfe/trunk/lib/CodeGen/CGCUDANV.cpp === --- cfe/trunk/lib/CodeGen/CGCUDANV.cpp +++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp @@ -55,6 +55,8 @@ llvm::FunctionType *getRegisterGlobalsFnTy() const; llvm::FunctionType *getCallbackFnTy() const; llvm::FunctionType *getRegisterLinkedBinaryFnTy() const; + std::string addPrefixToName(StringRef FuncName) const; + std::string addUnderscoredPrefixToName(StringRef FuncName) const; /// Creates a function to register all kernel stubs generated in this module. llvm::Function *makeRegisterGlobalsFn(); @@ -114,6 +116,18 @@ } +std::string CGNVCUDARuntime::addPrefixToName(StringRef FuncName) const { + if (CGM.getLangOpts().HIP) +return ((Twine("hip") + Twine(FuncName)).str()); + return ((Twine("cuda") + Twine(FuncName)).str()); +} +std::string +CGNVCUDARuntime::addUnderscoredPrefixToName(StringRef FuncName) const { + if (CGM.getLangOpts().HIP) +return ((Twine("__hip") + Twine(FuncName)).str()); + return ((Twine("__cuda") + Twine(FuncName)).str()); +} + CGNVCUDARuntime::CGNVCUDARuntime(CodeGenModule &CGM) : CGCUDARuntime(CGM), Context(CGM.getLLVMContext()), TheModule(CGM.getModule()), @@ -133,15 +147,21 @@ llvm::Constant *CGNVCUDARuntime::getSetupArgumentFn() const { // cudaError_t cudaSetupArgument(void *, size_t, size_t) llvm::Type *Params[] = {VoidPtrTy, SizeTy, SizeTy}; - return CGM.CreateRuntimeFunction(llvm::FunctionType::get(IntTy, - Params, false), - "cudaSetupArgument"); + return CGM.CreateRuntimeFunction( + llvm::FunctionType::get(IntTy, Params, false), + addPrefixToName("SetupArgument")); } llvm::Constant *CGNVCUDARuntime::getLaunchFn() const { - // cudaError_t cudaLaunch(char *) - return CGM.CreateRuntimeFunction( - llvm::FunctionType::get(IntTy, CharPtrTy, false), "cudaLaunch"); + if (CGM.getLangOpts().HIP) { +// hipError_t hipLaunchByPtr(char *); +return CGM.CreateRuntimeFunction( +llvm::FunctionType::get(IntTy, CharPtrTy, false), "hipLaunchByPtr"); + } else { +// cudaError_t cudaLaunch(char *); +return CGM.CreateRuntimeFunction( +llvm::FunctionType::get(IntTy, CharPtrTy, false), "cudaLaunch"); + } } llvm::FunctionType *CGNVCUDARuntime::getRegisterGlobalsFnTy() const { @@ -222,7 +242,7 @@ llvm::Function *RegisterKernelsFunc = llvm::Function::Create( getRegisterGlobalsFnTy(), llvm::GlobalValue::InternalLinkage, - "__cuda_register_globals", &TheModule); + addUnderscoredPrefixToName("_register_globals"), &TheModule); llvm::BasicBlock *EntryBB = llvm::BasicBlock::Create(Context, "entry", RegisterKernelsFunc); CGBuilderTy Builder(CGM, Context); @@ -235,7 +255,7 @@ VoidPtrTy,VoidPtrTy, VoidPtrTy, VoidPtrTy, IntTy->getPointerTo()}; llvm::Constant *RegisterFunc = CGM.CreateRuntimeFunction( llvm::FunctionType::get(IntTy, RegisterFuncParams, false), - "__cudaRegisterFunction"); + addUnderscoredPrefixToName("RegisterFunction")); // Extract GpuBinaryHandle passed as the first argument passed to // __cuda_register_globals() and generate __cudaRegisterFunction() call for @@ -259,7 +279,7 @@ IntTy,IntTy}; llvm::Constant *RegisterVar = CGM.CreateRuntimeFunction( llvm::FunctionType::get(IntTy, RegisterVarParams, false), - "__cudaRegisterVar"); + addUnderscoredPrefixToName("RegisterVar")); for (auto &Pair : DeviceVars) { llvm::GlobalVariable *Var = Pair.first; unsigned Flags = Pair.second; @@ -305,7 +325,7 @@ // void ** __cudaRegisterFatBinary(void *); llvm::Constant *RegisterFatbinFunc = CGM.CreateRuntimeFunction( llvm::FunctionType::get(VoidPtrPtrTy, VoidPtrTy, false), - "__cudaRegisterFatBinary"); + addUnderscoredPrefixToName("RegisterFatBinary")); // struct { int magic, int version, voi
r330790 - [HIP] Add hip input kind and codegen for kernel launching
Author: yaxunl Date: Tue Apr 24 18:10:37 2018 New Revision: 330790 URL: http://llvm.org/viewvc/llvm-project?rev=330790&view=rev Log: [HIP] Add hip input kind and codegen for kernel launching HIP is a language similar to CUDA (https://github.com/ROCm-Developer-Tools/HIP/blob/master/docs/markdown/hip_kernel_language.md ). The language syntax is very similar, which allows a hip program to be compiled as a CUDA program by Clang. The main difference is the host API. HIP has a set of vendor neutral host API which can be implemented on different platforms. Currently there is open source implementation of HIP runtime on amdgpu target (https://github.com/ROCm-Developer-Tools/HIP). This patch adds support of input kind and language standard hip. When hip file is compiled, both LangOpts.CUDA and LangOpts.HIP is turned on. This allows compilation of hip program as CUDA in most cases and only special handling of hip program is needed LangOpts.HIP is checked. This patch also adds support of kernel launching of HIP program using HIP host API. When -x hip is not specified, there is no behaviour change for CUDA. Patch by Greg Rodgers. Revised and lit test added by Yaxun Liu. Differential Revision: https://reviews.llvm.org/D44984 Modified: cfe/trunk/include/clang/Basic/IdentifierTable.h cfe/trunk/include/clang/Basic/LangOptions.def cfe/trunk/include/clang/Frontend/FrontendOptions.h cfe/trunk/include/clang/Frontend/LangStandards.def cfe/trunk/lib/CodeGen/CGCUDANV.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/lib/Frontend/FrontendActions.cpp cfe/trunk/lib/Frontend/InitPreprocessor.cpp cfe/trunk/lib/Sema/SemaCUDA.cpp cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/test/CodeGenCUDA/Inputs/cuda.h cfe/trunk/test/CodeGenCUDA/device-stub.cu cfe/trunk/test/CodeGenCUDA/kernel-call.cu Modified: cfe/trunk/include/clang/Basic/IdentifierTable.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/IdentifierTable.h?rev=330790&r1=330789&r2=330790&view=diff == --- cfe/trunk/include/clang/Basic/IdentifierTable.h (original) +++ cfe/trunk/include/clang/Basic/IdentifierTable.h Tue Apr 24 18:10:37 2018 @@ -98,6 +98,12 @@ public: memcmp(getNameStart(), Str, StrLen-1) == 0; } + /// \brief Return true if this is the identifier for the specified StringRef. + bool isStr(llvm::StringRef Str) const { +llvm::StringRef ThisStr(getNameStart(), getLength()); +return ThisStr == Str; + } + /// \brief Return the beginning of the actual null-terminated string for this /// identifier. const char *getNameStart() const { Modified: cfe/trunk/include/clang/Basic/LangOptions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=330790&r1=330789&r2=330790&view=diff == --- cfe/trunk/include/clang/Basic/LangOptions.def (original) +++ cfe/trunk/include/clang/Basic/LangOptions.def Tue Apr 24 18:10:37 2018 @@ -195,6 +195,7 @@ LANGOPT(NativeHalfType, 1, 0, "Nativ LANGOPT(NativeHalfArgsAndReturns, 1, 0, "Native half args and returns") LANGOPT(HalfArgsAndReturns, 1, 0, "half args and returns") LANGOPT(CUDA , 1, 0, "CUDA") +LANGOPT(HIP , 1, 0, "HIP") LANGOPT(OpenMP, 32, 0, "OpenMP support and version of OpenMP (31, 40 or 45)") LANGOPT(OpenMPSimd, 1, 0, "Use SIMD only OpenMP support.") LANGOPT(OpenMPUseTLS , 1, 0, "Use TLS for threadprivates or runtime calls") Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=330790&r1=330789&r2=330790&view=diff == --- cfe/trunk/include/clang/Frontend/FrontendOptions.h (original) +++ cfe/trunk/include/clang/Frontend/FrontendOptions.h Tue Apr 24 18:10:37 2018 @@ -161,6 +161,7 @@ public: OpenCL, CUDA, RenderScript, +HIP, ///@} }; Modified: cfe/trunk/include/clang/Frontend/LangStandards.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/LangStandards.def?rev=330790&r1=330789&r2=330790&view=diff == --- cfe/trunk/include/clang/Frontend/LangStandards.def (original) +++ cfe/trunk/include/clang/Frontend/LangStandards.def Tue Apr 24 18:10:37 2018 @@ -168,6 +168,10 @@ LANGSTANDARD_ALIAS_DEPR(opencl20, "CL2.0 LANGSTANDARD(cuda, "cuda", CUDA, "NVIDIA CUDA(tm)", LineComment | CPlusPlus | Digraphs) +// HIP +LANGSTANDARD(hip, "hip", HIP, "HIP", + LineComment | CPlusPlus | Digraphs) + #undef LANGSTANDARD #undef LANGSTANDARD_ALIAS #undef LANGSTANDARD_ALIAS_DEPR Modified: cfe/trunk/lib/CodeGen/CGCUDANV.cpp URL: http://llvm.org/vi
r330789 - [ODRHash] Hash template arguments of methods.
Author: rtrieu Date: Tue Apr 24 17:31:15 2018 New Revision: 330789 URL: http://llvm.org/viewvc/llvm-project?rev=330789&view=rev Log: [ODRHash] Hash template arguments of methods. Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td cfe/trunk/lib/AST/ODRHash.cpp cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/test/Modules/odr_hash.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=330789&r1=330788&r2=330789&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Tue Apr 24 17:31:15 2018 @@ -211,6 +211,12 @@ def err_module_odr_violation_mismatch_de "with %ordinal6 parameter with%select{out|}7 a default argument|" "%select{method %5|constructor|destructor}4 " "with %ordinal6 parameter with a default argument|" + "%select{method %5|constructor|destructor}4 " +"with %select{no |}6template arguments|" + "%select{method %5|constructor|destructor}4 " +"with %6 template argument%s6|" + "%select{method %5|constructor|destructor}4 " +"with %6 for %ordinal7 template argument|" "%select{typedef|type alias}4 name %5|" "%select{typedef|type alias}4 %5 with underlying type %6|" "data member with name %4|" @@ -258,6 +264,12 @@ def note_module_odr_violation_mismatch_d "with %ordinal4 parameter with%select{out|}5 a default argument|" "%select{method %3|constructor|destructor}2 " "with %ordinal4 parameter with a different default argument|" + "%select{method %3|constructor|destructor}2 " +"with %select{no |}4template arguments|" + "%select{method %3|constructor|destructor}2 " +"with %4 template argument%s4|" + "%select{method %3|constructor|destructor}2 " +"with %4 for %ordinal5 template argument|" "%select{typedef|type alias}2 name %3|" "%select{typedef|type alias}2 %3 with different underlying type %4|" "data member with name %2|" Modified: cfe/trunk/lib/AST/ODRHash.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=330789&r1=330788&r2=330789&view=diff == --- cfe/trunk/lib/AST/ODRHash.cpp (original) +++ cfe/trunk/lib/AST/ODRHash.cpp Tue Apr 24 17:31:15 2018 @@ -148,6 +148,8 @@ void ODRHash::AddTemplateArgument(Templa AddQualType(TA.getAsType()); break; case TemplateArgument::Declaration: + AddDecl(TA.getAsDecl()); + break; case TemplateArgument::NullPtr: case TemplateArgument::Integral: break; @@ -330,6 +332,15 @@ public: AddQualType(D->getReturnType()); +const auto* SpecializationArgs = D->getTemplateSpecializationArgs(); +Hash.AddBoolean(SpecializationArgs); +if (SpecializationArgs) { + ID.AddInteger(SpecializationArgs->size()); + for (const TemplateArgument &TA : SpecializationArgs->asArray()) { +Hash.AddTemplateArgument(TA); + } +} + Inherited::VisitFunctionDecl(D); } Modified: cfe/trunk/lib/Serialization/ASTReader.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=330789&r1=330788&r2=330789&view=diff == --- cfe/trunk/lib/Serialization/ASTReader.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Apr 24 17:31:15 2018 @@ -9450,6 +9450,12 @@ void ASTReader::diagnoseOdrViolations() return Hash.CalculateHash(); }; + auto ComputeTemplateArgumentODRHash = [&Hash](const TemplateArgument &TA) { +Hash.clear(); +Hash.AddTemplateArgument(TA); +return Hash.CalculateHash(); + }; + // Issue any pending ODR-failure diagnostics. for (auto &Merge : OdrMergeFailures) { // If we've already pointed out a specific problem with this class, don't @@ -9948,6 +9954,9 @@ void ASTReader::diagnoseOdrViolations() MethodParameterName, MethodParameterSingleDefaultArgument, MethodParameterDifferentDefaultArgument, +MethodNoTemplateArguments, +MethodDifferentNumberTemplateArguments, +MethodDifferentTemplateArgument, TypedefName, TypedefType, VarName, @@ -10370,6 +10379,89 @@ void ASTReader::diagnoseOdrViolations() break; } +const auto *FirstTemplateArgs = +FirstMethod->getTemplateSpecializationArgs(); +const auto *SecondTemplateArgs = +SecondMethod->getTemplateSpecializationArgs(); + +if ((FirstTemplateArgs && !SecondTemplateArgs) || +(!FirstTemplateArgs && SecondTemplateArgs)) { + ODRDiagError(FirstMethod->getLocation(), + FirstMethod->getSourceRange(), MethodNoTemplateArgumen
[PATCH] D44882: [clangd] Implementation of workspace/symbol request
sammccall added a subscriber: bkramer. sammccall added a comment. In https://reviews.llvm.org/D44882#1076927, @malaperle wrote: > In https://reviews.llvm.org/D44882#1076864, @sammccall wrote: > > > So this fails if there's no standard library available without flags, which > > is the case in google's test environment to ensure hermeticity :-( > > > > In the short-term, we've disabled the test internally - did it trigger any > > buildbot failures? > > In the medium term we should probably find a better way to test this :( > > > No buildbot failures yet. But I suggest we just remove the test and add it > back when we collect more symbols, i.e. in main files. WDYT? It makes sense, but @bkramer came up with some deep magic in https://reviews.llvm.org/rL330754 so I think we're actually good now. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D44882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46035: [clangd] Fix unicode handling, using UTF-16 where LSP requires it.
sammccall updated this revision to Diff 143838. sammccall added a comment. Remove some debugging junk, tweak a comment. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D46035 Files: clangd/ClangdServer.cpp clangd/ClangdUnit.cpp clangd/ClangdUnit.h clangd/CodeComplete.cpp clangd/Protocol.h clangd/SourceCode.cpp clangd/SourceCode.h clangd/XRefs.cpp test/clangd/rename.test unittests/clangd/ClangdUnitTests.cpp unittests/clangd/DraftStoreTests.cpp unittests/clangd/SourceCodeTests.cpp Index: unittests/clangd/SourceCodeTests.cpp === --- unittests/clangd/SourceCodeTests.cpp +++ unittests/clangd/SourceCodeTests.cpp @@ -24,9 +24,10 @@ return arg.line == Line && arg.character == Col; } +// The = → 🡆 below are ASCII (1 byte), BMP (3 bytes), and astral (4 bytes). const char File[] = R"(0:0 = 0 -1:0 = 8 -2:0 = 16)"; +1:0 → 8 +2:0 🡆 18)"; /// A helper to make tests easier to read. Position position(int line, int character) { @@ -66,25 +67,31 @@ EXPECT_THAT_EXPECTED(positionToOffset(File, position(1, 3), false), HasValue(11)); EXPECT_THAT_EXPECTED(positionToOffset(File, position(1, 6)), - HasValue(14)); // last character + HasValue(16)); // last character EXPECT_THAT_EXPECTED(positionToOffset(File, position(1, 7)), - HasValue(15)); // the newline itself + HasValue(17)); // the newline itself EXPECT_THAT_EXPECTED(positionToOffset(File, position(1, 8)), - HasValue(15)); // out of range + HasValue(17)); // out of range EXPECT_THAT_EXPECTED(positionToOffset(File, position(1, 8), false), Failed()); // out of range // last line EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, -1)), Failed()); // out of range EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 0)), - HasValue(16)); // first character + HasValue(18)); // first character EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 3)), - HasValue(19)); // middle character - EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 7)), - HasValue(23)); // last character + HasValue(21)); // middle character + EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 5), false), + Failed()); // middle of surrogate pair + EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 5)), + HasValue(26)); // middle of surrogate pair + EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 6), false), + HasValue(26)); // end of surrogate pair EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 8)), - HasValue(24)); // EOF - EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 9), false), + HasValue(28)); // last character + EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 9)), + HasValue(29)); // EOF + EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 10), false), Failed()); // out of range // line out of bounds EXPECT_THAT_EXPECTED(positionToOffset(File, position(3, 0)), Failed()); @@ -97,14 +104,19 @@ EXPECT_THAT(offsetToPosition(File, 6), Pos(0, 6)) << "end of first line"; EXPECT_THAT(offsetToPosition(File, 7), Pos(0, 7)) << "first newline"; EXPECT_THAT(offsetToPosition(File, 8), Pos(1, 0)) << "start of second line"; - EXPECT_THAT(offsetToPosition(File, 11), Pos(1, 3)) << "in second line"; - EXPECT_THAT(offsetToPosition(File, 14), Pos(1, 6)) << "end of second line"; - EXPECT_THAT(offsetToPosition(File, 15), Pos(1, 7)) << "second newline"; - EXPECT_THAT(offsetToPosition(File, 16), Pos(2, 0)) << "start of last line"; - EXPECT_THAT(offsetToPosition(File, 19), Pos(2, 3)) << "in last line"; - EXPECT_THAT(offsetToPosition(File, 23), Pos(2, 7)) << "end of last line"; - EXPECT_THAT(offsetToPosition(File, 24), Pos(2, 8)) << "EOF"; - EXPECT_THAT(offsetToPosition(File, 25), Pos(2, 8)) << "out of bounds"; + EXPECT_THAT(offsetToPosition(File, 12), Pos(1, 4)) << "before BMP char"; + EXPECT_THAT(offsetToPosition(File, 13), Pos(1, 5)) << "in BMP char"; + EXPECT_THAT(offsetToPosition(File, 15), Pos(1, 5)) << "after BMP char"; + EXPECT_THAT(offsetToPosition(File, 16), Pos(1, 6)) << "end of second line"; + EXPECT_THAT(offsetToPosition(File, 17), Pos(1, 7)) << "second newline"; + EXPECT_THAT(offsetToPosition(File, 18), Pos(2, 0)) << "start of last line"; + EXPECT_THAT(offsetToPosition(File, 21), Pos(2, 3)) << "in last line"; + EXPECT_THAT(offsetToPosition(File, 22), Pos(2, 4)) << "before astral char"; + EXPECT_THAT(offsetToPosition(File, 24), Pos(2, 6)) << "in astral char"; + EXPECT_THAT(offsetToPosition(File, 26), Pos(2,
[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen or wcslen
Charusso added a comment. In https://reviews.llvm.org/D45050#1071897, @xbolva00 wrote: > Shouldn't it catch in curl also this code? > > urllen = strlen(url_clone); > > > > memcpy(newest, url_clone, urllen); > > Edit: if possible, report these bugs to project developers :) Thanks for your idea @xbolva00, I will implement this feature, but currently I have problems with parens which cause ugly fix-its. After the review I will share the results with the devs. In https://reviews.llvm.org/D45050#1071926, @xbolva00 wrote: > Another idea if you want to implement it - check fopen. > > FILE *f = fopen("file", "r"); // read only > fputs("str", f); // we are writing -> boom, sigsegv or something like that. Thanks for your sharing but I think I will move forward to Static Analyzer with my own projects. https://reviews.llvm.org/D45050 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46035: [clangd] Fix unicode handling, using UTF-16 where LSP requires it.
sammccall created this revision. sammccall added a reviewer: hokein. Herald added subscribers: cfe-commits, jkorous, MaskRay, ioeric, ilya-biryukov, klimek. The Language Server Protocol unfortunately mandates that locations in files be represented by line/column pairs, where the "column" is actually an index into the UTF-16-encoded text of the line. (This is because VSCode is written in JavaScript, which is UTF-16-native). Internally clangd treats source files at UTF-8, the One True Encoding, and generally deals with byte offsets (though there are exceptions). Before this patch, conversions between offsets and LSP Position pretended that Position.character was UTF-8 bytes, which is only true for ASCII lines. Now we examine the text to convert correctly (but don't actually need to transcode it, due to some nice details of the encodings). The updated functions in SourceCode are the blessed way to interact with the Position.character field, and anything else is likely to be wrong. So I also updated the other accesses: - CodeComplete needs a "clang-style" line/column, with column in utf-8 bytes. This is now converted via Position -> offset -> clang line/column (a new function is added to SourceCode.h for the second conversion). - getBeginningOfIdentifier skipped backwards in UTF-16 space, which is will behave badly when it splits a surrogate pair. Skipping backwards in UTF-8 coordinates gives the lexer a fighting chance of getting this right. While here, I clarified(?) the logic comments, fixed a bug with identifiers containing digits, simplified the signature slightly and added a test. This seems likely to cause problems with editors that have the same bug, and treat the protocol as if columns are UTF-8 bytes. But we can find and fix those. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D46035 Files: clangd/ClangdServer.cpp clangd/ClangdUnit.cpp clangd/ClangdUnit.h clangd/CodeComplete.cpp clangd/Protocol.h clangd/SourceCode.cpp clangd/SourceCode.h clangd/XRefs.cpp test/clangd/rename.test unittests/clangd/ClangdUnitTests.cpp unittests/clangd/DraftStoreTests.cpp unittests/clangd/SourceCodeTests.cpp Index: unittests/clangd/SourceCodeTests.cpp === --- unittests/clangd/SourceCodeTests.cpp +++ unittests/clangd/SourceCodeTests.cpp @@ -24,9 +24,10 @@ return arg.line == Line && arg.character == Col; } +// The = → 🡆 below are ASCII (1 byte), BMP (3 bytes), and astral (4 bytes). const char File[] = R"(0:0 = 0 -1:0 = 8 -2:0 = 16)"; +1:0 → 8 +2:0 🡆 18)"; /// A helper to make tests easier to read. Position position(int line, int character) { @@ -66,25 +67,31 @@ EXPECT_THAT_EXPECTED(positionToOffset(File, position(1, 3), false), HasValue(11)); EXPECT_THAT_EXPECTED(positionToOffset(File, position(1, 6)), - HasValue(14)); // last character + HasValue(16)); // last character EXPECT_THAT_EXPECTED(positionToOffset(File, position(1, 7)), - HasValue(15)); // the newline itself + HasValue(17)); // the newline itself EXPECT_THAT_EXPECTED(positionToOffset(File, position(1, 8)), - HasValue(15)); // out of range + HasValue(17)); // out of range EXPECT_THAT_EXPECTED(positionToOffset(File, position(1, 8), false), Failed()); // out of range // last line EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, -1)), Failed()); // out of range EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 0)), - HasValue(16)); // first character + HasValue(18)); // first character EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 3)), - HasValue(19)); // middle character - EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 7)), - HasValue(23)); // last character + HasValue(21)); // middle character + EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 5), false), + Failed()); // middle of surrogate pair + EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 5)), + HasValue(26)); // middle of surrogate pair + EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 6), false), + HasValue(26)); // end of surrogate pair EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 8)), - HasValue(24)); // EOF - EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 9), false), + HasValue(28)); // last character + EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 9)), + HasValue(29)); // EOF + EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 10), false), Failed()); // out of range // line out of bo
[PATCH] D44984: [HIP] Add hip input kind and codegen for kernel launching
rjmccall accepted this revision. rjmccall added a comment. Thank you. https://reviews.llvm.org/D44984 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46035: [clangd] Fix unicode handling, using UTF-16 where LSP requires it.
sammccall updated this revision to Diff 143836. sammccall added a comment. clang-format Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D46035 Files: clangd/ClangdServer.cpp clangd/ClangdUnit.cpp clangd/ClangdUnit.h clangd/CodeComplete.cpp clangd/Protocol.h clangd/SourceCode.cpp clangd/SourceCode.h clangd/XRefs.cpp test/clangd/rename.test unittests/clangd/ClangdUnitTests.cpp unittests/clangd/DraftStoreTests.cpp unittests/clangd/SourceCodeTests.cpp Index: unittests/clangd/SourceCodeTests.cpp === --- unittests/clangd/SourceCodeTests.cpp +++ unittests/clangd/SourceCodeTests.cpp @@ -24,9 +24,10 @@ return arg.line == Line && arg.character == Col; } +// The = → 🡆 below are ASCII (1 byte), BMP (3 bytes), and astral (4 bytes). const char File[] = R"(0:0 = 0 -1:0 = 8 -2:0 = 16)"; +1:0 → 8 +2:0 🡆 18)"; /// A helper to make tests easier to read. Position position(int line, int character) { @@ -66,25 +67,31 @@ EXPECT_THAT_EXPECTED(positionToOffset(File, position(1, 3), false), HasValue(11)); EXPECT_THAT_EXPECTED(positionToOffset(File, position(1, 6)), - HasValue(14)); // last character + HasValue(16)); // last character EXPECT_THAT_EXPECTED(positionToOffset(File, position(1, 7)), - HasValue(15)); // the newline itself + HasValue(17)); // the newline itself EXPECT_THAT_EXPECTED(positionToOffset(File, position(1, 8)), - HasValue(15)); // out of range + HasValue(17)); // out of range EXPECT_THAT_EXPECTED(positionToOffset(File, position(1, 8), false), Failed()); // out of range // last line EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, -1)), Failed()); // out of range EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 0)), - HasValue(16)); // first character + HasValue(18)); // first character EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 3)), - HasValue(19)); // middle character - EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 7)), - HasValue(23)); // last character + HasValue(21)); // middle character + EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 5), false), + Failed()); // middle of surrogate pair + EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 5)), + HasValue(26)); // middle of surrogate pair + EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 6), false), + HasValue(26)); // end of surrogate pair EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 8)), - HasValue(24)); // EOF - EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 9), false), + HasValue(28)); // last character + EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 9)), + HasValue(29)); // EOF + EXPECT_THAT_EXPECTED(positionToOffset(File, position(2, 10), false), Failed()); // out of range // line out of bounds EXPECT_THAT_EXPECTED(positionToOffset(File, position(3, 0)), Failed()); @@ -97,14 +104,19 @@ EXPECT_THAT(offsetToPosition(File, 6), Pos(0, 6)) << "end of first line"; EXPECT_THAT(offsetToPosition(File, 7), Pos(0, 7)) << "first newline"; EXPECT_THAT(offsetToPosition(File, 8), Pos(1, 0)) << "start of second line"; - EXPECT_THAT(offsetToPosition(File, 11), Pos(1, 3)) << "in second line"; - EXPECT_THAT(offsetToPosition(File, 14), Pos(1, 6)) << "end of second line"; - EXPECT_THAT(offsetToPosition(File, 15), Pos(1, 7)) << "second newline"; - EXPECT_THAT(offsetToPosition(File, 16), Pos(2, 0)) << "start of last line"; - EXPECT_THAT(offsetToPosition(File, 19), Pos(2, 3)) << "in last line"; - EXPECT_THAT(offsetToPosition(File, 23), Pos(2, 7)) << "end of last line"; - EXPECT_THAT(offsetToPosition(File, 24), Pos(2, 8)) << "EOF"; - EXPECT_THAT(offsetToPosition(File, 25), Pos(2, 8)) << "out of bounds"; + EXPECT_THAT(offsetToPosition(File, 12), Pos(1, 4)) << "before BMP char"; + EXPECT_THAT(offsetToPosition(File, 13), Pos(1, 5)) << "in BMP char"; + EXPECT_THAT(offsetToPosition(File, 15), Pos(1, 5)) << "after BMP char"; + EXPECT_THAT(offsetToPosition(File, 16), Pos(1, 6)) << "end of second line"; + EXPECT_THAT(offsetToPosition(File, 17), Pos(1, 7)) << "second newline"; + EXPECT_THAT(offsetToPosition(File, 18), Pos(2, 0)) << "start of last line"; + EXPECT_THAT(offsetToPosition(File, 21), Pos(2, 3)) << "in last line"; + EXPECT_THAT(offsetToPosition(File, 22), Pos(2, 4)) << "before astral char"; + EXPECT_THAT(offsetToPosition(File, 24), Pos(2, 6)) << "in astral char"; + EXPECT_THAT(offsetToPosition(File, 26), Pos(2, 6)) << "after astral char"; + E
[PATCH] D46033: add check for long double for __builtin_dump_struct
paulsemel created this revision. paulsemel added a reviewer: aaron.ballman. This patch adds a test for long double format. Repository: rC Clang https://reviews.llvm.org/D46033 Files: test/CodeGen/dump-struct-builtin.c Index: test/CodeGen/dump-struct-builtin.c === --- test/CodeGen/dump-struct-builtin.c +++ test/CodeGen/dump-struct-builtin.c @@ -107,6 +107,12 @@ // CHECK-NEXT: [[FORMAT_U17:@[0-9]+]] = private unnamed_addr constant [6 x i8] c"%hhd\0A\00" // CHECK-NEXT: [[END_STRUCT_U17:@[0-9]+]] = private unnamed_addr constant [3 x i8] c"}\0A\00" +// CHECK: @unit18.a = private unnamed_addr constant %struct.U18A { x86_fp80 0xK3FFF8FCD67FD3F5B6000 }, align 16 +// CHECK-NEXT: [[STRUCT_STR_U18:@[0-9]+]] = private unnamed_addr constant [15 x i8] c"struct U18A {\0A\00" +// CHECK-NEXT: [[FIELD_U18:@[0-9]+]] = private unnamed_addr constant [17 x i8] c"long double a : \00" +// CHECK-NEXT: [[FORMAT_U18:@[0-9]+]] = private unnamed_addr constant [5 x i8] c"%Lf\0A\00" +// CHECK-NEXT: [[END_STRUCT_U18:@[0-9]+]] = private unnamed_addr constant [3 x i8] c"}\0A\00" + int printf(const char *fmt, ...) { return 0; } @@ -417,6 +423,24 @@ __builtin_dump_struct(&a, &printf); } +void unit18() { + struct U18A { +long double a; + }; + + struct U18A a = { + .a = 1.123456, + }; + + // CHECK: call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* [[STRUCT_STR_U18]], i32 0, i32 0)) + // CHECK: [[RES1:%[0-9]+]] = getelementptr inbounds %struct.U18A, %struct.U18A* %a, i32 0, i32 0 + // CHECK: call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* [[FIELD_U18]], i32 0, i32 0)) + // CHECK: [[LOAD1:%[0-9]+]] = load x86_fp80, x86_fp80* [[RES1]], + // CHECK: call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* [[FORMAT_U18]], i32 0, i32 0), x86_fp80 [[LOAD1]]) + // CHECK: call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* [[END_STRUCT_U18]], i32 0, i32 0) + __builtin_dump_struct(&a, &printf); +} + void test1() { struct T1A { int a; Index: test/CodeGen/dump-struct-builtin.c === --- test/CodeGen/dump-struct-builtin.c +++ test/CodeGen/dump-struct-builtin.c @@ -107,6 +107,12 @@ // CHECK-NEXT: [[FORMAT_U17:@[0-9]+]] = private unnamed_addr constant [6 x i8] c"%hhd\0A\00" // CHECK-NEXT: [[END_STRUCT_U17:@[0-9]+]] = private unnamed_addr constant [3 x i8] c"}\0A\00" +// CHECK: @unit18.a = private unnamed_addr constant %struct.U18A { x86_fp80 0xK3FFF8FCD67FD3F5B6000 }, align 16 +// CHECK-NEXT: [[STRUCT_STR_U18:@[0-9]+]] = private unnamed_addr constant [15 x i8] c"struct U18A {\0A\00" +// CHECK-NEXT: [[FIELD_U18:@[0-9]+]] = private unnamed_addr constant [17 x i8] c"long double a : \00" +// CHECK-NEXT: [[FORMAT_U18:@[0-9]+]] = private unnamed_addr constant [5 x i8] c"%Lf\0A\00" +// CHECK-NEXT: [[END_STRUCT_U18:@[0-9]+]] = private unnamed_addr constant [3 x i8] c"}\0A\00" + int printf(const char *fmt, ...) { return 0; } @@ -417,6 +423,24 @@ __builtin_dump_struct(&a, &printf); } +void unit18() { + struct U18A { +long double a; + }; + + struct U18A a = { + .a = 1.123456, + }; + + // CHECK: call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* [[STRUCT_STR_U18]], i32 0, i32 0)) + // CHECK: [[RES1:%[0-9]+]] = getelementptr inbounds %struct.U18A, %struct.U18A* %a, i32 0, i32 0 + // CHECK: call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* [[FIELD_U18]], i32 0, i32 0)) + // CHECK: [[LOAD1:%[0-9]+]] = load x86_fp80, x86_fp80* [[RES1]], + // CHECK: call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* [[FORMAT_U18]], i32 0, i32 0), x86_fp80 [[LOAD1]]) + // CHECK: call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* [[END_STRUCT_U18]], i32 0, i32 0) + __builtin_dump_struct(&a, &printf); +} + void test1() { struct T1A { int a; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen or wcslen
Charusso updated this revision to Diff 143825. Charusso marked an inline comment as done. Charusso added a comment. Defined an option to switch off the `_s` suffixed functions usage. https://reviews.llvm.org/D45050 Files: clang-tidy/bugprone/BugproneTidyModule.cpp clang-tidy/bugprone/CMakeLists.txt clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp clang-tidy/bugprone/NotNullTerminatedResultCheck.h docs/ReleaseNotes.rst docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst docs/clang-tidy/checks/list.rst test/clang-tidy/bugprone-not-null-terminated-result-strlen-before-safe.c test/clang-tidy/bugprone-not-null-terminated-result-strlen-safe.c test/clang-tidy/bugprone-not-null-terminated-result-wcslen-before-safe.c test/clang-tidy/bugprone-not-null-terminated-result-wcslen-safe.c Index: test/clang-tidy/bugprone-not-null-terminated-result-wcslen-safe.c === --- /dev/null +++ test/clang-tidy/bugprone-not-null-terminated-result-wcslen-safe.c @@ -0,0 +1,150 @@ +// RUN: %check_clang_tidy %s bugprone-not-null-terminated-result %t -- \ +// RUN: -- -std=c11 + +typedef unsigned int size_t; +typedef unsigned int wchar_t; +typedef int errno_t; +size_t wcslen(const wchar_t *); +wchar_t *wcschr(const wchar_t *, int); +errno_t *wcsncpy_s(wchar_t *, const wchar_t *, size_t); + +void *alloca(size_t); +void *calloc(size_t, size_t); +void *malloc(size_t); +void *realloc(void *, size_t); + +void *wmemcpy(void *, const void *, size_t); +errno_t wmemcpy_s(void *, size_t, const void *, size_t); +void *wmemchr(const void *, int, size_t); +void *wmemmove(void *, const void *, size_t); +errno_t wmemmove_s(void *, size_t, const void *, size_t); +void *wmemset(void *, int, size_t); + +int wcsncmp(const wchar_t *, const wchar_t *, size_t); +size_t wcsxfrm(wchar_t *, const wchar_t *, size_t); + + +void bad_alloca(wchar_t *dest, const wchar_t *src) { + dest = (wchar_t *)alloca(wcslen(src)); + // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: memory allocated by 'alloca' is insufficient to hold the null terminator [bugprone-not-null-terminated-result] + // CHECK-FIXES: alloca(wcslen(src) + 1); +} + +void good_alloca(wchar_t *dest, const wchar_t *src) { + dest = (wchar_t *)alloca(wcslen(src) + 1); +} + +void bad_calloc(wchar_t *dest, const wchar_t *src) { + dest = (wchar_t *)calloc(wcslen(src), sizeof(wchar_t)); + // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: memory allocated by 'calloc' is insufficient to hold the null terminator [bugprone-not-null-terminated-result] + // CHECK-FIXES: calloc((wcslen(src) + 1), sizeof(wchar_t)); +} + +void good_calloc(wchar_t *dest, const wchar_t *src) { + dest = (wchar_t *)calloc((wcslen(src) + 1), sizeof(wchar_t)); +} + +void bad_malloc(wchar_t *dest, const wchar_t *src) { + dest = (wchar_t *)malloc(wcslen(src) * 2); + // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: memory allocated by 'malloc' is insufficient to hold the null terminator [bugprone-not-null-terminated-result] + // CHECK-FIXES: malloc((wcslen(src) * 2) + 1); +} + +void good_malloc(wchar_t *dest, const wchar_t *src) { + dest = (wchar_t *)malloc((wcslen(src) * 2) + 1); +} + +void bad_realloc(wchar_t *dest, const wchar_t *src) { + dest = (wchar_t *)realloc(dest, (wcslen(dest) + wcslen(src))); + // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: memory allocated by 'realloc' is insufficient to hold the null terminator [bugprone-not-null-terminated-result] + // CHECK-FIXES: realloc(dest, (wcslen(dest) + (wcslen(src) + 1))); +} + +void good_realloc(wchar_t *dest, const wchar_t *src) { + dest = (wchar_t *)realloc(dest, (wcslen(dest) + (wcslen(src) + 1))); +} + +void bad_wmemcpy(wchar_t *dest, const wchar_t *src) { + wmemcpy(dest, src, wcslen(src)); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'wmemcpy' is not null-terminated [bugprone-not-null-terminated-result] + // CHECK-FIXES: wcsncpy_s(dest, src, wcslen(src)); +} + +void good_wmemcpy_safe(wchar_t *dest, const wchar_t *src) { + wcsncpy_s(dest, src, wcslen(src)); +} + +void bad_wmemcpy_s(wchar_t *dest, const wchar_t *src) { + wmemcpy_s(dest, wcslen(dest), src, wcslen(src)); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'wmemcpy_s' is not null-terminated [bugprone-not-null-terminated-result] + // CHECK-FIXES: wcsncpy_s(dest, src, wcslen(src)); +} + +void good_wmemcpy_s(wchar_t *dest, const wchar_t *src) { + wcsncpy_s(dest, src, wcslen(src)); +} + +void bad_wmemchr(wchar_t *dest, const wchar_t *src) { + dest = (wchar_t *)wmemchr(src, '\0', wcslen(src)); + // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: the result from calling 'wmemchr' is not null-terminated [bugprone-not-null-terminated-result] + // CHECK-FIXES: wcschr(src, '\0'); +} + +void good_wmemchr(wchar_t *dest, const wchar_t *src) { + dest = wcschr(src, '\0'); +} + +void bad_wmemmove(wchar_t *dest, const wchar_t *src) { + wmemmove(dest, src, wcslen(src)); + // CHECK-MESSAGES: :[[
[PATCH] D46015: [OpenCL] Add separate read_only and write_only pipe IR types
AlexeySotkin added inline comments. Comment at: lib/CodeGen/CGOpenCLRuntime.h:65 virtual llvm::Type *getPipeType(const PipeType *T); + virtual llvm::Type *getPipeType(const PipeType *T, StringRef Name, + llvm::Type *&PipeTy); I'm not sure that it is a good idea to make this function public, as its parameter supposed to be a reference to protected member. Repository: rC Clang https://reviews.llvm.org/D46015 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46015: [OpenCL] Add separate read_only and write_only pipe IR types
AlexeySotkin added a comment. It is not clear why we need two versions of get_pipe_num_packets and get_pipe_max_packets builtins. There is only one instruction per builtin in the SPIR-V spec. I think splitting the IR type is enough for translation to SPIR-V purposes. Repository: rC Clang https://reviews.llvm.org/D46015 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46030: [TargetInfo] Sort target features before passing them to the backend
efriedma updated this revision to Diff 143821. efriedma added a comment. Add REQUIRES line to testcase. Repository: rC Clang https://reviews.llvm.org/D46030 Files: lib/Basic/Targets.cpp test/CodeGen/arm-build-attributes.c Index: test/CodeGen/arm-build-attributes.c === --- /dev/null +++ test/CodeGen/arm-build-attributes.c @@ -0,0 +1,4 @@ +// RUN: %clang --target=arm-none-eabi -x c - -o - -S < %s -mcpu=cortex-a5 -mfpu=vfpv4-d16 | FileCheck %s +// REQUIRES: arm-registered-target +// CHECK: .fpu vfpv4-d16 +void foo() {} Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -638,6 +638,7 @@ Opts->Features.clear(); for (const auto &F : Features) Opts->Features.push_back((F.getValue() ? "+" : "-") + F.getKey().str()); + llvm::sort(Opts->Features.begin(), Opts->Features.end()); if (!Target->handleTargetFeatures(Opts->Features, Diags)) return nullptr; Index: test/CodeGen/arm-build-attributes.c === --- /dev/null +++ test/CodeGen/arm-build-attributes.c @@ -0,0 +1,4 @@ +// RUN: %clang --target=arm-none-eabi -x c - -o - -S < %s -mcpu=cortex-a5 -mfpu=vfpv4-d16 | FileCheck %s +// REQUIRES: arm-registered-target +// CHECK: .fpu vfpv4-d16 +void foo() {} Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -638,6 +638,7 @@ Opts->Features.clear(); for (const auto &F : Features) Opts->Features.push_back((F.getValue() ? "+" : "-") + F.getKey().str()); + llvm::sort(Opts->Features.begin(), Opts->Features.end()); if (!Target->handleTargetFeatures(Opts->Features, Diags)) return nullptr; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46030: [TargetInfo] Sort target features before passing them to the backend
efriedma created this revision. efriedma added reviewers: fhahn, SjoerdMeijer. Herald added a reviewer: javed.absar. Herald added a subscriber: kristof.beyls. Passing the features in random order will lead to unpredictable results when some of the features are related (like the architecture-version feature on ARM). It might be possible to fix this particular case in the ARM target code, to avoid adding overlapping target features. But we should probably be sorting in any case: the behavior shouldn't depend on StringMap's hashing algorithm. Repository: rC Clang https://reviews.llvm.org/D46030 Files: lib/Basic/Targets.cpp test/CodeGen/arm-build-attributes.c Index: test/CodeGen/arm-build-attributes.c === --- /dev/null +++ test/CodeGen/arm-build-attributes.c @@ -0,0 +1,3 @@ +// RUN: %clang --target=arm-none-eabi -x c - -o - -S < %s -mcpu=cortex-a5 -mfpu=vfpv4-d16 | FileCheck %s +// CHECK: .fpu vfpv4-d16 +void foo() {} Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -638,6 +638,7 @@ Opts->Features.clear(); for (const auto &F : Features) Opts->Features.push_back((F.getValue() ? "+" : "-") + F.getKey().str()); + llvm::sort(Opts->Features.begin(), Opts->Features.end()); if (!Target->handleTargetFeatures(Opts->Features, Diags)) return nullptr; Index: test/CodeGen/arm-build-attributes.c === --- /dev/null +++ test/CodeGen/arm-build-attributes.c @@ -0,0 +1,3 @@ +// RUN: %clang --target=arm-none-eabi -x c - -o - -S < %s -mcpu=cortex-a5 -mfpu=vfpv4-d16 | FileCheck %s +// CHECK: .fpu vfpv4-d16 +void foo() {} Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -638,6 +638,7 @@ Opts->Features.clear(); for (const auto &F : Features) Opts->Features.push_back((F.getValue() ? "+" : "-") + F.getKey().str()); + llvm::sort(Opts->Features.begin(), Opts->Features.end()); if (!Target->handleTargetFeatures(Opts->Features, Diags)) return nullptr; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330780 - Revert "[Driver] Android triples are not aliases for other triples."
Author: danalbert Date: Tue Apr 24 15:06:40 2018 New Revision: 330780 URL: http://llvm.org/viewvc/llvm-project?rev=330780&view=rev Log: Revert "[Driver] Android triples are not aliases for other triples." Revering while I diagnose the failures. This reverts commit 82dc3bf2157da280420f80e654292cb05e0dc5f7. Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp cfe/trunk/test/Driver/android-ndk-standalone.cpp Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=330780&r1=330779&r2=330780&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Tue Apr 24 15:06:40 2018 @@ -1816,20 +1816,22 @@ void Generic_GCC::GCCInstallationDetecto // lifetime or initialization issues. static const char *const AArch64LibDirs[] = {"/lib64", "/lib"}; static const char *const AArch64Triples[] = { - "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-redhat-linux", - "aarch64-suse-linux"}; + "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-linux-android", + "aarch64-redhat-linux", "aarch64-suse-linux"}; static const char *const AArch64beLibDirs[] = {"/lib"}; static const char *const AArch64beTriples[] = {"aarch64_be-none-linux-gnu", "aarch64_be-linux-gnu"}; static const char *const ARMLibDirs[] = {"/lib"}; - static const char *const ARMTriples[] = {"arm-linux-gnueabi"}; + static const char *const ARMTriples[] = {"arm-linux-gnueabi", + "arm-linux-androideabi"}; static const char *const ARMHFTriples[] = {"arm-linux-gnueabihf", "armv7hl-redhat-linux-gnueabi", "armv6hl-suse-linux-gnueabi", "armv7hl-suse-linux-gnueabi"}; static const char *const ARMebLibDirs[] = {"/lib"}; - static const char *const ARMebTriples[] = {"armeb-linux-gnueabi"}; + static const char *const ARMebTriples[] = {"armeb-linux-gnueabi", + "armeb-linux-androideabi"}; static const char *const ARMebHFTriples[] = { "armeb-linux-gnueabihf", "armebv7hl-redhat-linux-gnueabi"}; @@ -1839,14 +1841,16 @@ void Generic_GCC::GCCInstallationDetecto "x86_64-pc-linux-gnu","x86_64-redhat-linux6E", "x86_64-redhat-linux","x86_64-suse-linux", "x86_64-manbo-linux-gnu", "x86_64-linux-gnu", - "x86_64-slackware-linux", "x86_64-unknown-linux"}; + "x86_64-slackware-linux", "x86_64-linux-android", + "x86_64-unknown-linux"}; static const char *const X32LibDirs[] = {"/libx32"}; static const char *const X86LibDirs[] = {"/lib32", "/lib"}; static const char *const X86Triples[] = { "i686-linux-gnu", "i686-pc-linux-gnu", "i486-linux-gnu", "i386-linux-gnu", "i386-redhat-linux6E", "i686-redhat-linux", "i586-redhat-linux","i386-redhat-linux", "i586-suse-linux", - "i486-slackware-linux", "i686-montavista-linux", "i586-linux-gnu"}; + "i486-slackware-linux", "i686-montavista-linux", "i686-linux-android", + "i586-linux-gnu"}; static const char *const MIPSLibDirs[] = {"/lib"}; static const char *const MIPSTriples[] = {"mips-linux-gnu", "mips-mti-linux", @@ -1865,6 +1869,13 @@ void Generic_GCC::GCCInstallationDetecto "mips64el-linux-gnu", "mips-mti-linux-gnu", "mips-img-linux-gnu", "mips64el-linux-gnuabi64"}; + static const char *const MIPSELAndroidLibDirs[] = {"/lib", "/libr2", + "/libr6"}; + static const char *const MIPSELAndroidTriples[] = {"mipsel-linux-android"}; + static const char *const MIPS64ELAndroidLibDirs[] = {"/lib64", "/lib", + "/libr2", "/libr6"}; + static const char *const MIPS64ELAndroidTriples[] = { + "mips64el-linux-android"}; static const char *const PPCLibDirs[] = {"/lib32", "/lib"}; static const char *const PPCTriples[] = { @@ -1941,66 +1952,6 @@ void Generic_GCC::GCCInstallationDetecto return; } - // Android targets should not use GNU/Linux tools or libraries. - if (TargetTriple.isAndroid()) { -static const char *const AArch64AndroidTriples[] = { -"aarch64-linux-android"}; -static const char *const ARMAndroidTriples[] = {"arm-linux-androideabi"}; -static const char *const MIPSELAndroidTriples[] = {"mipsel-linux-android"}; -static const char *const MIPS64ELAndroidTriples[] = { -"mips64el-linux-android"}; -static const char *const X86AndroidTriples[] = {"i686-linux-android"}; -static const char *const X86_64AndroidTriples[] = {"x86_64-linux-android"}; - -switch (TargetTriple.getArch()) { -case llvm::Triple::aarch
[PATCH] D45470: Emit an error when mixing and
vsapsai updated this revision to Diff 143817. vsapsai added a comment. - Tighten up a test with expected-error per review comment. https://reviews.llvm.org/D45470 Files: clang/lib/Headers/stdatomic.h clang/test/Headers/stdatomic.cpp libcxx/include/atomic libcxx/test/libcxx/atomics/c_compatibility.fail.cpp Index: libcxx/test/libcxx/atomics/c_compatibility.fail.cpp === --- /dev/null +++ libcxx/test/libcxx/atomics/c_compatibility.fail.cpp @@ -0,0 +1,36 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// +// +// UNSUPPORTED: libcpp-has-no-threads +// +// + +// Test that including fails to compile when we want to use C atomics +// in C++ and have corresponding macro defined. + +// XFAIL: with_system_cxx_lib=macosx10.13 +// XFAIL: with_system_cxx_lib=macosx10.12 +// XFAIL: with_system_cxx_lib=macosx10.11 +// XFAIL: with_system_cxx_lib=macosx10.10 +// XFAIL: with_system_cxx_lib=macosx10.9 +// XFAIL: with_system_cxx_lib=macosx10.8 +// XFAIL: with_system_cxx_lib=macosx10.7 + +// MODULES_DEFINES: __ALLOW_STDC_ATOMICS_IN_CXX__ +#ifndef __ALLOW_STDC_ATOMICS_IN_CXX__ +#define __ALLOW_STDC_ATOMICS_IN_CXX__ +#endif + +#include +// expected-error@atomic:* {{ is incompatible with the C++ standard library}} + +int main() +{ +} + Index: libcxx/include/atomic === --- libcxx/include/atomic +++ libcxx/include/atomic @@ -555,6 +555,9 @@ #if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) #error is not implemented #endif +#ifdef __ALLOW_STDC_ATOMICS_IN_CXX__ +#error is incompatible with the C++ standard library +#endif #if _LIBCPP_STD_VER > 14 # define __cpp_lib_atomic_is_always_lock_free 201603L Index: clang/test/Headers/stdatomic.cpp === --- /dev/null +++ clang/test/Headers/stdatomic.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 %s -verify +// RUN: %clang_cc1 -D__ALLOW_STDC_ATOMICS_IN_CXX__ %s -verify + +#include + +#ifndef __ALLOW_STDC_ATOMICS_IN_CXX__ +// expected-error@stdatomic.h:* {{ is incompatible with the C++ standard library}} +#else +// expected-no-diagnostics +#endif Index: clang/lib/Headers/stdatomic.h === --- clang/lib/Headers/stdatomic.h +++ clang/lib/Headers/stdatomic.h @@ -31,6 +31,10 @@ # include_next #else +#if !defined(__ALLOW_STDC_ATOMICS_IN_CXX__) && defined(__cplusplus) +#error " is incompatible with the C++ standard library; define __ALLOW_STDC_ATOMICS_IN_CXX__ to proceed." +#endif + #include #include Index: libcxx/test/libcxx/atomics/c_compatibility.fail.cpp === --- /dev/null +++ libcxx/test/libcxx/atomics/c_compatibility.fail.cpp @@ -0,0 +1,36 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// +// +// UNSUPPORTED: libcpp-has-no-threads +// +// + +// Test that including fails to compile when we want to use C atomics +// in C++ and have corresponding macro defined. + +// XFAIL: with_system_cxx_lib=macosx10.13 +// XFAIL: with_system_cxx_lib=macosx10.12 +// XFAIL: with_system_cxx_lib=macosx10.11 +// XFAIL: with_system_cxx_lib=macosx10.10 +// XFAIL: with_system_cxx_lib=macosx10.9 +// XFAIL: with_system_cxx_lib=macosx10.8 +// XFAIL: with_system_cxx_lib=macosx10.7 + +// MODULES_DEFINES: __ALLOW_STDC_ATOMICS_IN_CXX__ +#ifndef __ALLOW_STDC_ATOMICS_IN_CXX__ +#define __ALLOW_STDC_ATOMICS_IN_CXX__ +#endif + +#include +// expected-error@atomic:* {{ is incompatible with the C++ standard library}} + +int main() +{ +} + Index: libcxx/include/atomic === --- libcxx/include/atomic +++ libcxx/include/atomic @@ -555,6 +555,9 @@ #if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) #error is not implemented #endif +#ifdef __ALLOW_STDC_ATOMICS_IN_CXX__ +#error is incompatible with the C++ standard library +#endif #if _LIBCPP_STD_VER > 14 # define __cpp_lib_atomic_is_always_lock_free 201603L Index: clang/test/Headers/stdatomic.cpp === --- /dev/null +++ clang/test/Headers/stdatomic.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 %s -verify +// RUN: %clang_cc1 -D__ALLOW_STDC_AT
[clang-tools-extra] r330772 - [clang-tidy] Improve bugprone-unused-return-value check
Author: jbcoe Date: Tue Apr 24 14:25:16 2018 New Revision: 330772 URL: http://llvm.org/viewvc/llvm-project?rev=330772&view=rev Log: [clang-tidy] Improve bugprone-unused-return-value check Summary: Add support for checking class template member functions. Also add the following functions to be checked by default: - std::unique_ptr::release - std::basic_string::empty - std::vector::empty Reviewers: alexfh, hokein, aaron.ballman, ilya-biryukov Reviewed By: aaron.ballman Subscribers: jbcoe, xazax.hun, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D45891 Patch by khuttun (Kalle Huttunen) Modified: clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-unused-return-value.rst clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-return-value-custom.cpp clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-return-value.cpp Modified: clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp?rev=330772&r1=330771&r2=330772&view=diff == --- clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp Tue Apr 24 14:25:16 2018 @@ -19,14 +19,32 @@ namespace clang { namespace tidy { namespace bugprone { +namespace { + +// Matches functions that are instantiated from a class template member function +// matching InnerMatcher. Functions not instantiated from a class template +// member function are matched directly with InnerMatcher. +AST_MATCHER_P(FunctionDecl, isInstantiatedFrom, Matcher, + InnerMatcher) { + FunctionDecl *InstantiatedFrom = Node.getInstantiatedFromMemberFunction(); + return InnerMatcher.matches(InstantiatedFrom ? *InstantiatedFrom : Node, + Finder, Builder); +} + +} // namespace + UnusedReturnValueCheck::UnusedReturnValueCheck(llvm::StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), - CheckedFunctions(Options.get("CheckedFunctions", "::std::async;" - "::std::launder;" - "::std::remove;" - "::std::remove_if;" - "::std::unique")) {} + CheckedFunctions(Options.get("CheckedFunctions", + "::std::async;" + "::std::launder;" + "::std::remove;" + "::std::remove_if;" + "::std::unique;" + "::std::unique_ptr::release;" + "::std::basic_string::empty;" + "::std::vector::empty")) {} void UnusedReturnValueCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { Options.store(Opts, "CheckedFunctions", CheckedFunctions); @@ -35,11 +53,11 @@ void UnusedReturnValueCheck::storeOption void UnusedReturnValueCheck::registerMatchers(MatchFinder *Finder) { auto FunVec = utils::options::parseStringList(CheckedFunctions); auto MatchedCallExpr = expr(ignoringImplicit(ignoringParenImpCasts( - callExpr( - callee(functionDecl( - // Don't match void overloads of checked functions. - unless(returns(voidType())), hasAnyName(std::vector( - FunVec.begin(), FunVec.end()) + callExpr(callee(functionDecl( + // Don't match void overloads of checked functions. + unless(returns(voidType())), + isInstantiatedFrom(hasAnyName( + std::vector(FunVec.begin(), FunVec.end())) .bind("match"; auto UnusedInCompoundStmt = Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-unused-return-value.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-unused-return-value.rst?rev=330772&r1=330771&r2=330772&view=diff == --- clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-unused-return-value.rst (original) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-unused-return-value.rst Tue Apr 24 14:25:16 2018 @@ -11,7 +11,7 @@ Options .. option:: CheckedFunctions Semicolon-separated list of functions to check. Defaults to - ``::std::async;::std::launder;::std::remove;::std::remove_if;::std::unique``. + ``::std::async;::std::launder;::std::remove
[PATCH] D45891: [clang-tidy] Improve bugprone-unused-return-value check
This revision was automatically updated to reflect the committed changes. Closed by commit rCTE330772: [clang-tidy] Improve bugprone-unused-return-value check (authored by jbcoe, committed by ). Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45891 Files: clang-tidy/bugprone/UnusedReturnValueCheck.cpp docs/clang-tidy/checks/bugprone-unused-return-value.rst test/clang-tidy/bugprone-unused-return-value-custom.cpp test/clang-tidy/bugprone-unused-return-value.cpp Index: test/clang-tidy/bugprone-unused-return-value.cpp === --- test/clang-tidy/bugprone-unused-return-value.cpp +++ test/clang-tidy/bugprone-unused-return-value.cpp @@ -24,6 +24,34 @@ template ForwardIt unique(ForwardIt, ForwardIt); +template +struct default_delete; + +template > +struct unique_ptr { + T *release() noexcept; +}; + +template +struct char_traits; + +template +struct allocator; + +template , + typename Allocator = allocator> +struct basic_string { + bool empty() const; +}; + +typedef basic_string string; + +template > +struct vector { + bool empty() const noexcept; +}; + // the check should be able to match std lib calls even if the functions are // declared inside inline namespaces inline namespace v1 { @@ -64,6 +92,18 @@ std::unique(nullptr, nullptr); // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value] + std::unique_ptr UPtr; + UPtr.release(); + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value] + + std::string Str; + Str.empty(); + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value] + + std::vector Vec; + Vec.empty(); + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value] + // test discarding return values inside different kinds of statements auto Lambda = [] { std::remove(nullptr, nullptr, 1); }; @@ -137,6 +177,15 @@ auto UniqueRetval = std::unique(nullptr, nullptr); + std::unique_ptr UPtrNoWarning; + auto ReleaseRetval = UPtrNoWarning.release(); + + std::string StrNoWarning; + auto StrEmptyRetval = StrNoWarning.empty(); + + std::vector VecNoWarning; + auto VecEmptyRetval = VecNoWarning.empty(); + // test using the return value in different kinds of expressions useFuture(std::async(increment, 42)); std::launder(&FNoWarning)->f(); Index: test/clang-tidy/bugprone-unused-return-value-custom.cpp === --- test/clang-tidy/bugprone-unused-return-value-custom.cpp +++ test/clang-tidy/bugprone-unused-return-value-custom.cpp @@ -1,7 +1,7 @@ // RUN: %check_clang_tidy %s bugprone-unused-return-value %t \ // RUN: -config='{CheckOptions: \ // RUN: [{key: bugprone-unused-return-value.CheckedFunctions, \ -// RUN:value: "::fun;::ns::Outer::Inner::memFun;::ns::Type::staticFun"}]}' \ +// RUN:value: "::fun;::ns::Outer::Inner::memFun;::ns::Type::staticFun;::ns::ClassTemplate::memFun;::ns::ClassTemplate::staticFun"}]}' \ // RUN: -- namespace std { @@ -34,6 +34,12 @@ static Retval staticFun(); }; +template +struct ClassTemplate { + Retval memFun(); + static Retval staticFun(); +}; + } // namespace ns int fun(); @@ -60,6 +66,13 @@ ns::Type::staticFun(); // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value] + + ns::ClassTemplate ObjA4; + ObjA4.memFun(); + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value] + + ns::ClassTemplate::staticFun(); + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value] } void noWarning() { @@ -70,13 +83,18 @@ auto R3 = ns::Type::staticFun(); + ns::ClassTemplate ObjB2; + auto R4 = ObjB2.memFun(); + + auto R5 = ns::ClassTemplate::staticFun(); + // test calling a void overload of a checked function fun(5); // test discarding return value of functions that are not configured to be checked int I = 1; std::launder(&I); - ns::Type ObjB2; - ObjB2.memFun(); + ns::Type ObjB3; + ObjB3.memFun(); } Index: clang-tidy/bugprone/UnusedReturnValueCheck.cpp === --- clang-tidy/bugprone/UnusedReturnValueCheck.cpp +++ clang-tidy/bugprone/UnusedReturnValueCheck.cpp @@ -19,27 +19,45 @@ namespace tidy { namespace bugprone { +namespace { + +// Matches functions that are instantiated from a class template member function +// matching InnerMatcher. Functions not instantiated from a class template +// member function are matched directly with InnerMatcher. +AST_MATCHER_P(FunctionDecl, isInstantia
[PATCH] D45597: [Driver] Android triples are not aliases for other triples.
This revision was automatically updated to reflect the committed changes. Closed by commit rC330770: [Driver] Android triples are not aliases for other triples. (authored by danalbert, committed by ). Changed prior to commit: https://reviews.llvm.org/D45597?vs=142281&id=143807#toc Repository: rC Clang https://reviews.llvm.org/D45597 Files: lib/Driver/ToolChains/Gnu.cpp test/Driver/android-ndk-standalone.cpp Index: lib/Driver/ToolChains/Gnu.cpp === --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -1816,22 +1816,20 @@ // lifetime or initialization issues. static const char *const AArch64LibDirs[] = {"/lib64", "/lib"}; static const char *const AArch64Triples[] = { - "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-linux-android", - "aarch64-redhat-linux", "aarch64-suse-linux"}; + "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-redhat-linux", + "aarch64-suse-linux"}; static const char *const AArch64beLibDirs[] = {"/lib"}; static const char *const AArch64beTriples[] = {"aarch64_be-none-linux-gnu", "aarch64_be-linux-gnu"}; static const char *const ARMLibDirs[] = {"/lib"}; - static const char *const ARMTriples[] = {"arm-linux-gnueabi", - "arm-linux-androideabi"}; + static const char *const ARMTriples[] = {"arm-linux-gnueabi"}; static const char *const ARMHFTriples[] = {"arm-linux-gnueabihf", "armv7hl-redhat-linux-gnueabi", "armv6hl-suse-linux-gnueabi", "armv7hl-suse-linux-gnueabi"}; static const char *const ARMebLibDirs[] = {"/lib"}; - static const char *const ARMebTriples[] = {"armeb-linux-gnueabi", - "armeb-linux-androideabi"}; + static const char *const ARMebTriples[] = {"armeb-linux-gnueabi"}; static const char *const ARMebHFTriples[] = { "armeb-linux-gnueabihf", "armebv7hl-redhat-linux-gnueabi"}; @@ -1841,16 +1839,14 @@ "x86_64-pc-linux-gnu","x86_64-redhat-linux6E", "x86_64-redhat-linux","x86_64-suse-linux", "x86_64-manbo-linux-gnu", "x86_64-linux-gnu", - "x86_64-slackware-linux", "x86_64-linux-android", - "x86_64-unknown-linux"}; + "x86_64-slackware-linux", "x86_64-unknown-linux"}; static const char *const X32LibDirs[] = {"/libx32"}; static const char *const X86LibDirs[] = {"/lib32", "/lib"}; static const char *const X86Triples[] = { "i686-linux-gnu", "i686-pc-linux-gnu", "i486-linux-gnu", "i386-linux-gnu", "i386-redhat-linux6E", "i686-redhat-linux", "i586-redhat-linux","i386-redhat-linux", "i586-suse-linux", - "i486-slackware-linux", "i686-montavista-linux", "i686-linux-android", - "i586-linux-gnu"}; + "i486-slackware-linux", "i686-montavista-linux", "i586-linux-gnu"}; static const char *const MIPSLibDirs[] = {"/lib"}; static const char *const MIPSTriples[] = {"mips-linux-gnu", "mips-mti-linux", @@ -1869,13 +1865,6 @@ "mips64el-linux-gnu", "mips-mti-linux-gnu", "mips-img-linux-gnu", "mips64el-linux-gnuabi64"}; - static const char *const MIPSELAndroidLibDirs[] = {"/lib", "/libr2", - "/libr6"}; - static const char *const MIPSELAndroidTriples[] = {"mipsel-linux-android"}; - static const char *const MIPS64ELAndroidLibDirs[] = {"/lib64", "/lib", - "/libr2", "/libr6"}; - static const char *const MIPS64ELAndroidTriples[] = { - "mips64el-linux-android"}; static const char *const PPCLibDirs[] = {"/lib32", "/lib"}; static const char *const PPCTriples[] = { @@ -1952,6 +1941,66 @@ return; } + // Android targets should not use GNU/Linux tools or libraries. + if (TargetTriple.isAndroid()) { +static const char *const AArch64AndroidTriples[] = { +"aarch64-linux-android"}; +static const char *const ARMAndroidTriples[] = {"arm-linux-androideabi"}; +static const char *const MIPSELAndroidTriples[] = {"mipsel-linux-android"}; +static const char *const MIPS64ELAndroidTriples[] = { +"mips64el-linux-android"}; +static const char *const X86AndroidTriples[] = {"i686-linux-android"}; +static const char *const X86_64AndroidTriples[] = {"x86_64-linux-android"}; + +switch (TargetTriple.getArch()) { +case llvm::Triple::aarch64: + LibDirs.append(begin(AArch64LibDirs), end(AArch64LibDirs)); + TripleAliases.append(begin(AArch64AndroidTriples), + end(AArch64AndroidTriples)); + break; +case llvm::Triple::arm: +case llvm::Triple::thumb: + LibDirs.append(begin(ARMLibDirs), end(ARMLibDirs)); + TripleAliases.append(begin(ARMAndro
r330770 - [Driver] Android triples are not aliases for other triples.
Author: danalbert Date: Tue Apr 24 14:18:37 2018 New Revision: 330770 URL: http://llvm.org/viewvc/llvm-project?rev=330770&view=rev Log: [Driver] Android triples are not aliases for other triples. Summary: Android targets should never use tools/libraries for non-Android targets or vice versa. Reviewers: srhines, george.burgess.iv, eugenis Reviewed By: eugenis Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D45597 Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp cfe/trunk/test/Driver/android-ndk-standalone.cpp Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=330770&r1=330769&r2=330770&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Tue Apr 24 14:18:37 2018 @@ -1816,22 +1816,20 @@ void Generic_GCC::GCCInstallationDetecto // lifetime or initialization issues. static const char *const AArch64LibDirs[] = {"/lib64", "/lib"}; static const char *const AArch64Triples[] = { - "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-linux-android", - "aarch64-redhat-linux", "aarch64-suse-linux"}; + "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-redhat-linux", + "aarch64-suse-linux"}; static const char *const AArch64beLibDirs[] = {"/lib"}; static const char *const AArch64beTriples[] = {"aarch64_be-none-linux-gnu", "aarch64_be-linux-gnu"}; static const char *const ARMLibDirs[] = {"/lib"}; - static const char *const ARMTriples[] = {"arm-linux-gnueabi", - "arm-linux-androideabi"}; + static const char *const ARMTriples[] = {"arm-linux-gnueabi"}; static const char *const ARMHFTriples[] = {"arm-linux-gnueabihf", "armv7hl-redhat-linux-gnueabi", "armv6hl-suse-linux-gnueabi", "armv7hl-suse-linux-gnueabi"}; static const char *const ARMebLibDirs[] = {"/lib"}; - static const char *const ARMebTriples[] = {"armeb-linux-gnueabi", - "armeb-linux-androideabi"}; + static const char *const ARMebTriples[] = {"armeb-linux-gnueabi"}; static const char *const ARMebHFTriples[] = { "armeb-linux-gnueabihf", "armebv7hl-redhat-linux-gnueabi"}; @@ -1841,16 +1839,14 @@ void Generic_GCC::GCCInstallationDetecto "x86_64-pc-linux-gnu","x86_64-redhat-linux6E", "x86_64-redhat-linux","x86_64-suse-linux", "x86_64-manbo-linux-gnu", "x86_64-linux-gnu", - "x86_64-slackware-linux", "x86_64-linux-android", - "x86_64-unknown-linux"}; + "x86_64-slackware-linux", "x86_64-unknown-linux"}; static const char *const X32LibDirs[] = {"/libx32"}; static const char *const X86LibDirs[] = {"/lib32", "/lib"}; static const char *const X86Triples[] = { "i686-linux-gnu", "i686-pc-linux-gnu", "i486-linux-gnu", "i386-linux-gnu", "i386-redhat-linux6E", "i686-redhat-linux", "i586-redhat-linux","i386-redhat-linux", "i586-suse-linux", - "i486-slackware-linux", "i686-montavista-linux", "i686-linux-android", - "i586-linux-gnu"}; + "i486-slackware-linux", "i686-montavista-linux", "i586-linux-gnu"}; static const char *const MIPSLibDirs[] = {"/lib"}; static const char *const MIPSTriples[] = {"mips-linux-gnu", "mips-mti-linux", @@ -1869,13 +1865,6 @@ void Generic_GCC::GCCInstallationDetecto "mips64el-linux-gnu", "mips-mti-linux-gnu", "mips-img-linux-gnu", "mips64el-linux-gnuabi64"}; - static const char *const MIPSELAndroidLibDirs[] = {"/lib", "/libr2", - "/libr6"}; - static const char *const MIPSELAndroidTriples[] = {"mipsel-linux-android"}; - static const char *const MIPS64ELAndroidLibDirs[] = {"/lib64", "/lib", - "/libr2", "/libr6"}; - static const char *const MIPS64ELAndroidTriples[] = { - "mips64el-linux-android"}; static const char *const PPCLibDirs[] = {"/lib32", "/lib"}; static const char *const PPCTriples[] = { @@ -1952,6 +1941,66 @@ void Generic_GCC::GCCInstallationDetecto return; } + // Android targets should not use GNU/Linux tools or libraries. + if (TargetTriple.isAndroid()) { +static const char *const AArch64AndroidTriples[] = { +"aarch64-linux-android"}; +static const char *const ARMAndroidTriples[] = {"arm-linux-androideabi"}; +static const char *const MIPSELAndroidTriples[] = {"mipsel-linux-android"}; +static const char *const MIPS64ELAndroidTriples[] = { +"mips64el-linux-android"}; +static const char *const X86AndroidTriples[] = {"i686-linux-android"}; +static co
[PATCH] D45932: [clang-tidy][modernize-raw-string-literal] Don't replace upper ASCII with raw literals
zinovy.nis added inline comments. Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:71 + // supported by specific code pages only. + if (Bytes.find_if_not(isASCII) != StringRef::npos) +return false; aaron.ballman wrote: > zinovy.nis wrote: > > aaron.ballman wrote: > > > zinovy.nis wrote: > > > > aaron.ballman wrote: > > > > > I am starting to think that this functionality should be refactored > > > > > because the check is now O(N^2) in the worst case because all of the > > > > > bytes of the string need to be touched twice. It would be nice for > > > > > performance reasons to combine this so that there's only a single > > > > > pass over all of the characters. > > > > > > > > > > What do you think? > > > > Sorry, but why O(N^2)? `isASCII` is O(1), it's just `return C<=127`. > > > > `find_if_not` is O(N). > > > The `find_if_not()` call you add touches every character in the string to > > > see if it's ASCII and it all characters are ASCII, then > > > `containsEscape()` calls `find()` which touches every character again > > > (assuming the searched character is never encountered). > > > > > > Looking a bit deeper, `isRawStringLiteral()` also calls `find()`, but it > > > asserts that the character is found, so not every character is touched in > > > the string and it should find a the searched character quite quickly. > > OK, I'll see how to combine theses checks into a single one. > > > > But anyway I see only 2*O(N), not O(N^2) here. > Oh, derp, that's my thinko -- sorry! You are correct, that's 2 * O(N) and not > O(N^2). May be we can use here [[ http://en.cppreference.com/w/cpp/string/byte/isprint | std::isprint ]] https://reviews.llvm.org/D45932 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45407: [StaticAnalyzer] Added notes to the plist output
NoQ added a comment. Yup thanks!~ Repository: rC Clang https://reviews.llvm.org/D45407 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45407: [StaticAnalyzer] Added notes to the plist output
This revision was automatically updated to reflect the committed changes. Closed by commit rL330766: [analyzer] Add support for the note diagnostic pieces to plist output format. (authored by dergachev, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D45407?vs=141505&id=143802#toc Repository: rL LLVM https://reviews.llvm.org/D45407 Files: cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp cfe/trunk/test/Analysis/copypaste/plist-diagnostics.cpp Index: cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp === --- cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp @@ -84,6 +84,41 @@ PP.getLangOpts(), true)); } +static void EmitRanges(raw_ostream &o, + const ArrayRef Ranges, + const FIDMap& FM, + const SourceManager &SM, + const LangOptions &LangOpts, + unsigned indent) { + + if (Ranges.empty()) +return; + + Indent(o, indent) << "ranges\n"; + Indent(o, indent) << "\n"; + ++indent; + for (auto &R : Ranges) +EmitRange(o, SM, + Lexer::getAsCharRange(SM.getExpansionRange(R), SM, LangOpts), + FM, indent + 1); + --indent; + Indent(o, indent) << "\n"; +} + +static void EmitMessage(raw_ostream &o, StringRef Message, unsigned indent) { + // Output the text. + assert(!Message.empty()); + Indent(o, indent) << "extended_message\n"; + Indent(o, indent); + EmitString(o, Message) << '\n'; + + // Output the short text. + // FIXME: Really use a short string. + Indent(o, indent) << "message\n"; + Indent(o, indent); + EmitString(o, Message) << '\n'; +} + static void ReportControlFlow(raw_ostream &o, const PathDiagnosticControlFlowPiece& P, const FIDMap& FM, @@ -138,7 +173,7 @@ Indent(o, indent) << "\n"; } -static void ReportEvent(raw_ostream &o, const PathDiagnosticPiece& P, +static void ReportEvent(raw_ostream &o, const PathDiagnosticEventPiece& P, const FIDMap& FM, const SourceManager &SM, const LangOptions &LangOpts, @@ -163,34 +198,14 @@ // Output the ranges (if any). ArrayRef Ranges = P.getRanges(); - - if (!Ranges.empty()) { -Indent(o, indent) << "ranges\n"; -Indent(o, indent) << "\n"; -++indent; -for (auto &R : Ranges) - EmitRange(o, SM, -Lexer::getAsCharRange(SM.getExpansionRange(R), SM, LangOpts), -FM, indent + 1); ---indent; -Indent(o, indent) << "\n"; - } + EmitRanges(o, Ranges, FM, SM, LangOpts, indent); // Output the call depth. Indent(o, indent) << "depth"; EmitInteger(o, depth) << '\n'; // Output the text. - assert(!P.getString().empty()); - Indent(o, indent) << "extended_message\n"; - Indent(o, indent); - EmitString(o, P.getString()) << '\n'; - - // Output the short text. - // FIXME: Really use a short string. - Indent(o, indent) << "message\n"; - Indent(o, indent); - EmitString(o, P.getString()) << '\n'; + EmitMessage(o, P.getString(), indent); // Finish up. --indent; @@ -246,6 +261,34 @@ } } +static void ReportNote(raw_ostream &o, const PathDiagnosticNotePiece& P, +const FIDMap& FM, +const SourceManager &SM, +const LangOptions &LangOpts, +unsigned indent, +unsigned depth) { + + Indent(o, indent) << "\n"; + ++indent; + + // Output the location. + FullSourceLoc L = P.getLocation().asLocation(); + + Indent(o, indent) << "location\n"; + EmitLocation(o, SM, L, FM, indent); + + // Output the ranges (if any). + ArrayRef Ranges = P.getRanges(); + EmitRanges(o, Ranges, FM, SM, LangOpts, indent); + + // Output the text. + EmitMessage(o, P.getString(), indent); + + // Finish up. + --indent; + Indent(o, indent); o << "\n"; +} + static void ReportDiag(raw_ostream &o, const PathDiagnosticPiece& P, const FIDMap& FM, const SourceManager &SM, const LangOptions &LangOpts) { @@ -271,15 +314,16 @@ indent, depth); break; case PathDiagnosticPiece::Event: - ReportEvent(o, cast(P), FM, SM, LangOpts, + ReportEvent(o, cast(P), FM, SM, LangOpts, indent, depth, isKeyEvent); break; case PathDiagnosticPiece::Macro: ReportMacro(o, cast(P), FM, SM, LangOpts, indent, depth); break; case PathDiagnosticPiece::Note: - // FIXME: Extend the plist format to support those. + ReportNote(o, cast(P), FM, SM, LangOpts, + indent, depth); break; } } @@ -364,15 +408,39 @@ for (std::
[PATCH] D45407: [StaticAnalyzer] Added notes to the plist output
This revision was automatically updated to reflect the committed changes. Closed by commit rC330766: [analyzer] Add support for the note diagnostic pieces to plist output format. (authored by dergachev, committed by ). Repository: rC Clang https://reviews.llvm.org/D45407 Files: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp test/Analysis/copypaste/plist-diagnostics.cpp Index: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp === --- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp +++ lib/StaticAnalyzer/Core/PlistDiagnostics.cpp @@ -84,6 +84,41 @@ PP.getLangOpts(), true)); } +static void EmitRanges(raw_ostream &o, + const ArrayRef Ranges, + const FIDMap& FM, + const SourceManager &SM, + const LangOptions &LangOpts, + unsigned indent) { + + if (Ranges.empty()) +return; + + Indent(o, indent) << "ranges\n"; + Indent(o, indent) << "\n"; + ++indent; + for (auto &R : Ranges) +EmitRange(o, SM, + Lexer::getAsCharRange(SM.getExpansionRange(R), SM, LangOpts), + FM, indent + 1); + --indent; + Indent(o, indent) << "\n"; +} + +static void EmitMessage(raw_ostream &o, StringRef Message, unsigned indent) { + // Output the text. + assert(!Message.empty()); + Indent(o, indent) << "extended_message\n"; + Indent(o, indent); + EmitString(o, Message) << '\n'; + + // Output the short text. + // FIXME: Really use a short string. + Indent(o, indent) << "message\n"; + Indent(o, indent); + EmitString(o, Message) << '\n'; +} + static void ReportControlFlow(raw_ostream &o, const PathDiagnosticControlFlowPiece& P, const FIDMap& FM, @@ -138,7 +173,7 @@ Indent(o, indent) << "\n"; } -static void ReportEvent(raw_ostream &o, const PathDiagnosticPiece& P, +static void ReportEvent(raw_ostream &o, const PathDiagnosticEventPiece& P, const FIDMap& FM, const SourceManager &SM, const LangOptions &LangOpts, @@ -163,34 +198,14 @@ // Output the ranges (if any). ArrayRef Ranges = P.getRanges(); - - if (!Ranges.empty()) { -Indent(o, indent) << "ranges\n"; -Indent(o, indent) << "\n"; -++indent; -for (auto &R : Ranges) - EmitRange(o, SM, -Lexer::getAsCharRange(SM.getExpansionRange(R), SM, LangOpts), -FM, indent + 1); ---indent; -Indent(o, indent) << "\n"; - } + EmitRanges(o, Ranges, FM, SM, LangOpts, indent); // Output the call depth. Indent(o, indent) << "depth"; EmitInteger(o, depth) << '\n'; // Output the text. - assert(!P.getString().empty()); - Indent(o, indent) << "extended_message\n"; - Indent(o, indent); - EmitString(o, P.getString()) << '\n'; - - // Output the short text. - // FIXME: Really use a short string. - Indent(o, indent) << "message\n"; - Indent(o, indent); - EmitString(o, P.getString()) << '\n'; + EmitMessage(o, P.getString(), indent); // Finish up. --indent; @@ -246,6 +261,34 @@ } } +static void ReportNote(raw_ostream &o, const PathDiagnosticNotePiece& P, +const FIDMap& FM, +const SourceManager &SM, +const LangOptions &LangOpts, +unsigned indent, +unsigned depth) { + + Indent(o, indent) << "\n"; + ++indent; + + // Output the location. + FullSourceLoc L = P.getLocation().asLocation(); + + Indent(o, indent) << "location\n"; + EmitLocation(o, SM, L, FM, indent); + + // Output the ranges (if any). + ArrayRef Ranges = P.getRanges(); + EmitRanges(o, Ranges, FM, SM, LangOpts, indent); + + // Output the text. + EmitMessage(o, P.getString(), indent); + + // Finish up. + --indent; + Indent(o, indent); o << "\n"; +} + static void ReportDiag(raw_ostream &o, const PathDiagnosticPiece& P, const FIDMap& FM, const SourceManager &SM, const LangOptions &LangOpts) { @@ -271,15 +314,16 @@ indent, depth); break; case PathDiagnosticPiece::Event: - ReportEvent(o, cast(P), FM, SM, LangOpts, + ReportEvent(o, cast(P), FM, SM, LangOpts, indent, depth, isKeyEvent); break; case PathDiagnosticPiece::Macro: ReportMacro(o, cast(P), FM, SM, LangOpts, indent, depth); break; case PathDiagnosticPiece::Note: - // FIXME: Extend the plist format to support those. + ReportNote(o, cast(P), FM, SM, LangOpts, + indent, depth); break; } } @@ -364,15 +408,39 @@ for (std::vector::iterator DI=Diags.begin(), DE = Diags.end(); DI!=DE; ++DI) { -o << " \n" - " path\n"; +o << " \n"; const PathDiagnostic *D = *DI;
r330766 - [analyzer] Add support for the note diagnostic pieces to plist output format.
Author: dergachev Date: Tue Apr 24 13:45:48 2018 New Revision: 330766 URL: http://llvm.org/viewvc/llvm-project?rev=330766&view=rev Log: [analyzer] Add support for the note diagnostic pieces to plist output format. Note diagnostic pieces are an additional way of highlighting code sections to the user. They aren't part of the normal path diagnostic sequence. They can also be attached to path-insensitive reports. Notes are already supported by the text output and scan-build. Expanding our machine-readable plist output format to be able to represent notes opens up the possibility for various analyzer GUIs to pick them up. Patch by Umann Kristóf! Differential Revision: https://reviews.llvm.org/D45407 Modified: cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp cfe/trunk/test/Analysis/copypaste/plist-diagnostics.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp?rev=330766&r1=330765&r2=330766&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp Tue Apr 24 13:45:48 2018 @@ -84,6 +84,41 @@ void ento::createPlistMultiFileDiagnosti PP.getLangOpts(), true)); } +static void EmitRanges(raw_ostream &o, + const ArrayRef Ranges, + const FIDMap& FM, + const SourceManager &SM, + const LangOptions &LangOpts, + unsigned indent) { + + if (Ranges.empty()) +return; + + Indent(o, indent) << "ranges\n"; + Indent(o, indent) << "\n"; + ++indent; + for (auto &R : Ranges) +EmitRange(o, SM, + Lexer::getAsCharRange(SM.getExpansionRange(R), SM, LangOpts), + FM, indent + 1); + --indent; + Indent(o, indent) << "\n"; +} + +static void EmitMessage(raw_ostream &o, StringRef Message, unsigned indent) { + // Output the text. + assert(!Message.empty()); + Indent(o, indent) << "extended_message\n"; + Indent(o, indent); + EmitString(o, Message) << '\n'; + + // Output the short text. + // FIXME: Really use a short string. + Indent(o, indent) << "message\n"; + Indent(o, indent); + EmitString(o, Message) << '\n'; +} + static void ReportControlFlow(raw_ostream &o, const PathDiagnosticControlFlowPiece& P, const FIDMap& FM, @@ -138,7 +173,7 @@ static void ReportControlFlow(raw_ostrea Indent(o, indent) << "\n"; } -static void ReportEvent(raw_ostream &o, const PathDiagnosticPiece& P, +static void ReportEvent(raw_ostream &o, const PathDiagnosticEventPiece& P, const FIDMap& FM, const SourceManager &SM, const LangOptions &LangOpts, @@ -163,34 +198,14 @@ static void ReportEvent(raw_ostream &o, // Output the ranges (if any). ArrayRef Ranges = P.getRanges(); - - if (!Ranges.empty()) { -Indent(o, indent) << "ranges\n"; -Indent(o, indent) << "\n"; -++indent; -for (auto &R : Ranges) - EmitRange(o, SM, -Lexer::getAsCharRange(SM.getExpansionRange(R), SM, LangOpts), -FM, indent + 1); ---indent; -Indent(o, indent) << "\n"; - } + EmitRanges(o, Ranges, FM, SM, LangOpts, indent); // Output the call depth. Indent(o, indent) << "depth"; EmitInteger(o, depth) << '\n'; // Output the text. - assert(!P.getString().empty()); - Indent(o, indent) << "extended_message\n"; - Indent(o, indent); - EmitString(o, P.getString()) << '\n'; - - // Output the short text. - // FIXME: Really use a short string. - Indent(o, indent) << "message\n"; - Indent(o, indent); - EmitString(o, P.getString()) << '\n'; + EmitMessage(o, P.getString(), indent); // Finish up. --indent; @@ -246,6 +261,34 @@ static void ReportMacro(raw_ostream &o, } } +static void ReportNote(raw_ostream &o, const PathDiagnosticNotePiece& P, +const FIDMap& FM, +const SourceManager &SM, +const LangOptions &LangOpts, +unsigned indent, +unsigned depth) { + + Indent(o, indent) << "\n"; + ++indent; + + // Output the location. + FullSourceLoc L = P.getLocation().asLocation(); + + Indent(o, indent) << "location\n"; + EmitLocation(o, SM, L, FM, indent); + + // Output the ranges (if any). + ArrayRef Ranges = P.getRanges(); + EmitRanges(o, Ranges, FM, SM, LangOpts, indent); + + // Output the text. + EmitMessage(o, P.getString(), indent); + + // Finish up. + --indent; + Indent(o, indent); o << "\n"; +} + static void ReportDiag(raw_ostream &o, const PathDiagnosticPiece& P, const FIDMap& FM, const SourceManager &SM, co
Re: r313784 - Remove offset size check in nullptr arithmetic handling
On 20 Sep 2017, at 20:06, Andrew Kaylor via cfe-commits wrote: > > Author: akaylor > Date: Wed Sep 20 11:06:44 2017 > New Revision: 313784 > > URL: http://llvm.org/viewvc/llvm-project?rev=313784&view=rev > Log: > Remove offset size check in nullptr arithmetic handling > > Differential Revision: https://reviews.llvm.org/D37042 Hi Andrew, Interestingly, this change (and its related r313666) break PHP 5.6's opcache module, as reported in https://bugs.freebsd.org/227723. PHP 5 uses a construct like to the following, to store multiple items in a 'variable' struct [1]: typedef struct TV { long tmp; char tmp3[30]; } temp_variable; #define EX_TMP_VAR(ex, n) ((temp_variable*)(((char*)(ex)) + ((int)(n #define EX_TMP_VAR_NUM(ex, n) (EX_TMP_VAR(ex, 0) - (1 + (n))) #define VAR_NUM(v) ((unsigned int)(EX_TMP_VAR_NUM(0, 0) - EX_TMP_VAR(0, v))) Invoking the VAR_NUM() macro gives different answers before and after r313784, e.g. at r313783: VAR_NUM(-100) -> 1 At r313784: VAR_NUM(-100) -> 0xf99c I proposed a workaround which avoids the null pointer arithmetic, but can you shed any light as to why your changes seem to make matters worse for PHP, while they seem to have been intended to make this kind of construct work better instead? -Dimitry [1] See also: https://github.com/php/php-src/blob/PHP-5.6/Zend/zend_compile.h#L417 and: https://github.com/php/php-src/blob/PHP-5.6/ext/opcache/Optimizer/zend_optimizer_internal.h#L28 signature.asc Description: Message signed with OpenPGP ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38680: [libunwind] Fix handling of DW_CFA_GNU_args_size
mstorsjo added a comment. In https://reviews.llvm.org/D38680#1077262, @joerg wrote: > I'm back to the point where I can't reproduce the problem :( Can we start > providing an actual failing test case? It's annoying to debug a problem when > you can't reproduce it. My testcase that triggers the issue is available at https://martin.st/temp/hello-exception.cpp. With this input file, I can produce the DW_CFA_GNU_args_size opcodes with this command: `clang -target i386-netbsd -O3 -fomit-frame-pointer -S -o - hello-exception.cpp` (tested with both clang 4.0 and current trunk). https://reviews.llvm.org/D38680 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44984: [HIP] Add hip input kind and codegen for kernel launching
yaxunl updated this revision to Diff 143800. yaxunl marked 5 inline comments as done. yaxunl added a comment. Add back HIP related changes to the tests. https://reviews.llvm.org/D44984 Files: include/clang/Basic/IdentifierTable.h include/clang/Basic/LangOptions.def include/clang/Frontend/FrontendOptions.h include/clang/Frontend/LangStandards.def lib/CodeGen/CGCUDANV.cpp lib/Frontend/CompilerInvocation.cpp lib/Frontend/FrontendActions.cpp lib/Frontend/InitPreprocessor.cpp lib/Sema/SemaCUDA.cpp lib/Sema/SemaDecl.cpp test/CodeGenCUDA/Inputs/cuda.h test/CodeGenCUDA/device-stub.cu test/CodeGenCUDA/kernel-call.cu Index: test/CodeGenCUDA/kernel-call.cu === --- test/CodeGenCUDA/kernel-call.cu +++ test/CodeGenCUDA/kernel-call.cu @@ -1,11 +1,20 @@ -// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s --check-prefixes=CUDA,CHECK +// RUN: %clang_cc1 -x hip -emit-llvm %s -o - | FileCheck %s --check-prefixes=HIP,CHECK + #include "Inputs/cuda.h" +// CHECK-LABEL: define void @_Z2g1i(i32 %x) +// HIP: call{{.*}}hipSetupArgument +// HIP: call{{.*}}hipLaunchByPtr +// CUDA: call{{.*}}cudaSetupArgument +// CUDA: call{{.*}}cudaLaunch __global__ void g1(int x) {} +// CHECK-LABEL: define i32 @main int main(void) { - // CHECK: call{{.*}}cudaConfigureCall + // HIP: call{{.*}}hipConfigureCall + // CUDA: call{{.*}}cudaConfigureCall // CHECK: icmp // CHECK: br // CHECK: call{{.*}}g1 Index: test/CodeGenCUDA/device-stub.cu === --- test/CodeGenCUDA/device-stub.cu +++ test/CodeGenCUDA/device-stub.cu @@ -1,8 +1,20 @@ // RUN: echo "GPU binary would be here" > %t -// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -fcuda-include-gpubinary %t -o - | FileCheck %s -// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -fcuda-include-gpubinary %t -o - -DNOGLOBALS \ +// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ +// RUN: -fcuda-include-gpubinary %t -o - \ +// RUN: | FileCheck -check-prefixes=CHECK,CUDA %s +// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ +// RUN: -fcuda-include-gpubinary %t -o - -DNOGLOBALS \ // RUN: | FileCheck %s -check-prefix=NOGLOBALS -// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=NOGPUBIN +// RUN: %clang_cc1 -triple x86_64-linux-gnu -x hip -emit-llvm %s -o - \ +// RUN: | FileCheck %s -check-prefix=NOGPUBIN +// RUN: %clang_cc1 -triple x86_64-linux-gnu -x hip -emit-llvm %s \ +// RUN: -fcuda-include-gpubinary %t -o - \ +// RUN: | FileCheck -check-prefixes=CHECK,HIP %s +// RUN: %clang_cc1 -triple x86_64-linux-gnu -x hip -emit-llvm %s \ +// RUN: -fcuda-include-gpubinary %t -o - -DNOGLOBALS \ +// RUN: | FileCheck %s -check-prefix=NOGLOBALS +// RUN: %clang_cc1 -triple x86_64-linux-gnu -x hip -emit-llvm %s -o - \ +// RUN: | FileCheck %s -check-prefix=NOGPUBIN #include "Inputs/cuda.h" @@ -48,67 +60,74 @@ // CHECK: private unnamed_addr constant{{.*GPU binary would be here.*}}\00" // CHECK-SAME: section ".nv_fatbin", align 8 // * constant struct that wraps GPU binary -// CHECK: @__cuda_fatbin_wrapper = internal constant { i32, i32, i8*, i8* } +// CUDA: @__[[PREFIX:cuda]]_fatbin_wrapper = internal constant +// CUDA-SAME: { i32, i32, i8*, i8* } +// HIP: @__[[PREFIX:hip]]_fatbin_wrapper = internal constant +// HIP-SAME: { i32, i32, i8*, i8* } // CHECK-SAME: { i32 1180844977, i32 1, {{.*}}, i8* null } // CHECK-SAME: section ".nvFatBinSegment" // * variable to save GPU binary handle after initialization -// CHECK: @__cuda_gpubin_handle = internal global i8** null +// CHECK: @__[[PREFIX]]_gpubin_handle = internal global i8** null // * Make sure our constructor/destructor was added to global ctor/dtor list. -// CHECK: @llvm.global_ctors = appending global {{.*}}@__cuda_module_ctor -// CHECK: @llvm.global_dtors = appending global {{.*}}@__cuda_module_dtor +// CHECK: @llvm.global_ctors = appending global {{.*}}@__[[PREFIX]]_module_ctor +// CHECK: @llvm.global_dtors = appending global {{.*}}@__[[PREFIX]]_module_dtor // Test that we build the correct number of calls to cudaSetupArgument followed // by a call to cudaLaunch. // CHECK: define{{.*}}kernelfunc -// CHECK: call{{.*}}cudaSetupArgument -// CHECK: call{{.*}}cudaSetupArgument -// CHECK: call{{.*}}cudaSetupArgument -// CHECK: call{{.*}}cudaLaunch +// CHECK: call{{.*}}[[PREFIX]]SetupArgument +// CHECK: call{{.*}}[[PREFIX]]SetupArgument +// CHECK: call{{.*}}[[PREFIX]]SetupArgument +// CHECK: call{{.*}}[[PREFIX]]Launch __global__ void kernelfunc(int i, int j, int k) {} // Test that we've built correct kernel launch sequence. // CHECK: define{{.*}}hostfunc -// CHECK: call{{.*}}cudaConfigureCall +// CHECK: call{{.*}}[[PREFIX]]ConfigureCall // CHECK: call{{.*}}kernelfunc void hostfunc(void) { kernelfunc<<<1, 1>>>(1, 1, 1); } #endif
[PATCH] D38680: [libunwind] Fix handling of DW_CFA_GNU_args_size
joerg added a comment. I'm back to the point where I can't reproduce the problem :( Can we start providing an actual failing test case? It's annoying to debug a problem when you can't reproduce it. https://reviews.llvm.org/D38680 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45839: [analyzer] Add support for WebKit "unified sources".
NoQ added a comment. Aha, ok, yeah, that sounds like a lot, thank you. I think i'll follow up with a separate commit that will enable first-level-code-file-include analysis in all files under an on-by-default `-analyzer-config` flag, would that make sense? https://reviews.llvm.org/D45839 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44984: [HIP] Add hip input kind and codegen for kernel launching
yaxunl marked 2 inline comments as done. yaxunl added inline comments. Comment at: test/CodeGenCUDA/device-stub.cu:2-8 +// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ +// RUN: -fcuda-include-gpubinary %t -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ +// RUN: -fcuda-include-gpubinary %t -o - -DNOGLOBALS \ // RUN: | FileCheck %s -check-prefix=NOGLOBALS -// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=NOGPUBIN +// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - \ +// RUN: | FileCheck %s -check-prefix=NOGPUBIN tra wrote: > tra wrote: > > The changes in this file do not seem to have anything related to the code > > changes in this patch. > > Did you intend to add some HIP tests here? > Do you need these changes? Sorry, some changes about HIP were lost during revision. I will get back those changes. https://reviews.llvm.org/D44984 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34331: func.wrap.func.con: Unset function before destroying anything
vsapsai updated this revision to Diff 143797. vsapsai added a comment. - Move tests to test/std. https://reviews.llvm.org/D34331 Files: libcxx/include/__functional_03 libcxx/include/functional libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign_reentrant.pass.cpp Index: libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign_reentrant.pass.cpp === --- /dev/null +++ libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign_reentrant.pass.cpp @@ -0,0 +1,46 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// + +// class function + +// function& operator=(nullptr_t); + +#include +#include + +#include "test_macros.h" + +struct A +{ + static std::function global; + static bool cancel; + + ~A() { +DoNotOptimize(cancel); +if (cancel) + global = nullptr; + } + void operator()() {} +}; + +std::function A::global; +bool A::cancel = false; + +int main() +{ + A::global = A(); + assert(A::global.target()); + + // Check that we don't recurse in A::~A(). + A::cancel = true; + A::global = nullptr; + assert(!A::global.target()); +} Index: libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp === --- /dev/null +++ libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp @@ -0,0 +1,46 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// + +// class function + +// function& operator=(function &&); + +#include +#include + +#include "test_macros.h" + +struct A +{ + static std::function global; + static bool cancel; + + ~A() { +DoNotOptimize(cancel); +if (cancel) + global = std::function(nullptr); + } + void operator()() {} +}; + +std::function A::global; +bool A::cancel = false; + +int main() +{ + A::global = A(); + assert(A::global.target()); + + // Check that we don't recurse in A::~A(). + A::cancel = true; + A::global = std::function(nullptr); + assert(!A::global.target()); +} Index: libcxx/include/functional === --- libcxx/include/functional +++ libcxx/include/functional @@ -1818,11 +1818,7 @@ function<_Rp(_ArgTypes...)>& function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT { -if ((void *)__f_ == &__buf_) -__f_->destroy(); -else if (__f_) -__f_->destroy_deallocate(); -__f_ = 0; +*this = nullptr; if (__f.__f_ == 0) __f_ = 0; else if ((void *)__f.__f_ == &__f.__buf_) @@ -1842,11 +1838,12 @@ function<_Rp(_ArgTypes...)>& function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT { -if ((void *)__f_ == &__buf_) -__f_->destroy(); -else if (__f_) -__f_->destroy_deallocate(); +__base* __t = __f_; __f_ = 0; +if ((void *)__t == &__buf_) +__t->destroy(); +else if (__t) +__t->destroy_deallocate(); return *this; } Index: libcxx/include/__functional_03 === --- libcxx/include/__functional_03 +++ libcxx/include/__functional_03 @@ -600,19 +600,23 @@ function<_Rp()>& function<_Rp()>::operator=(const function& __f) { -function(__f).swap(*this); +if (__f) +function(__f).swap(*this); +else +*this = nullptr; return *this; } template function<_Rp()>& function<_Rp()>::operator=(nullptr_t) { -if (__f_ == (__base*)&__buf_) -__f_->destroy(); -else if (__f_) -__f_->destroy_deallocate(); +__base* __t = __f_; __f_ = 0; +if (__t == (__base*)&__buf_) +__t->destroy(); +else if (__t) +__t->destroy_deallocate(); return *this; } @@ -876,19 +880,23 @@ function<_Rp(_A0)>& function<_Rp(_A0)>::operator=(const function& __f) { -function(__f).swap(*this); +if (__f) +function(__f).swap(*this); +else +*this = nullptr; return *this; } template function<_Rp(_A0)>& function<_Rp(_A0)>
[PATCH] D45891: [clang-tidy] Improve bugprone-unused-return-value check
khuttun added a comment. Thank you! Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45891 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D42966: Fix USR generation in the presence of #line directives or linemarkes
mikhail.ramalho added a subscriber: arphaman. mikhail.ramalho added a comment. > Why wasn't there a file for function parameter? Function parameters *are* > declared in some file, or am I missing something? They are declared in some file defined by the line markers; the file are not registered in the SourceManager as actual files, so getting the FileEntry will always fail, that's why I changed it to get the PresumedLoc. More general question is: how do we want USRs for function parameters to > work, specifically should USR of the same param of different declarations > be the same or different? That's a good point, this patch will generated different names for the same function param if a function is first defined then declared somewhere else. I guess it should follow the USR generation pattern for FunctionDecls, what do you think? Repository: rC Clang https://reviews.llvm.org/D42966 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45865: [Sema] Emit -Warray-bounds for multiple levels of subscript expressions.
aaron.ballman closed this revision. aaron.ballman added a comment. Committed in r330759, thank you for the patch! https://reviews.llvm.org/D45865 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330759 - Improve -Warray-bounds to handle multiple array extents rather than only handling the top-most array extent.
Author: aaronballman Date: Tue Apr 24 12:21:04 2018 New Revision: 330759 URL: http://llvm.org/viewvc/llvm-project?rev=330759&view=rev Log: Improve -Warray-bounds to handle multiple array extents rather than only handling the top-most array extent. Patch by Bevin Hansson. Modified: cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/SemaCXX/array-bounds.cpp cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp Modified: cfe/trunk/lib/Sema/SemaChecking.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=330759&r1=330758&r2=330759&view=diff == --- cfe/trunk/lib/Sema/SemaChecking.cpp (original) +++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Apr 24 12:21:04 2018 @@ -11277,7 +11277,12 @@ void Sema::CheckArrayAccess(const Expr * const ArraySubscriptExpr *ASE = cast(expr); CheckArrayAccess(ASE->getBase(), ASE->getIdx(), ASE, AllowOnePastEnd > 0); -return; +expr = ASE->getBase(); +break; + } + case Stmt::MemberExprClass: { +expr = cast(expr)->getBase(); +break; } case Stmt::OMPArraySectionExprClass: { const OMPArraySectionExpr *ASE = cast(expr); Modified: cfe/trunk/test/SemaCXX/array-bounds.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/array-bounds.cpp?rev=330759&r1=330758&r2=330759&view=diff == --- cfe/trunk/test/SemaCXX/array-bounds.cpp (original) +++ cfe/trunk/test/SemaCXX/array-bounds.cpp Tue Apr 24 12:21:04 2018 @@ -269,3 +269,18 @@ int test_operator_overload_struct_array_ struct P x[10] = {0}; // expected-note {{array 'x' declared here}} return x[1] + x[11]; // expected-warning {{array index 11 is past the end of the array (which contains 10 elements)}} } + +int multi[2][2][2]; // expected-note 3 {{array 'multi' declared here}} +int test_multiarray() { + return multi[2][0][0] + // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}} + multi[0][2][0] + // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}} + multi[0][0][2]; // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}} +} + +struct multi_s { + int arr[4]; +}; +struct multi_s multi2[4]; // expected-note {{array 'multi2' declared here}} +int test_struct_multiarray() { + return multi2[4].arr[0]; // expected-warning {{array index 4 is past the end of the array (which contains 4 elements)}} +} Modified: cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp?rev=330759&r1=330758&r2=330759&view=diff == --- cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp (original) +++ cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp Tue Apr 24 12:21:04 2018 @@ -528,7 +528,7 @@ constexpr int xs6 = p[3]; // expected-er constexpr int xs0 = p[-3]; // ok constexpr int xs_1 = p[-4]; // expected-error {{constant expression}} expected-note {{cannot refer to element -1}} -constexpr int zs[2][2][2][2] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; +constexpr int zs[2][2][2][2] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; // expected-note {{array 'zs' declared here}} static_assert(zs[0][0][0][0] == 1, ""); static_assert(zs[1][1][1][1] == 16, ""); static_assert(zs[0][0][0][2] == 3, ""); // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end pointer}} @@ -536,7 +536,10 @@ static_assert((&zs[0][0][0][2])[-1] == 2 static_assert(**(**(zs + 1) + 1) == 11, ""); static_assert(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][-1] + 1) == 11, ""); // expected-error {{constant expression}} expected-note {{cannot refer to element -1 of array of 2 elements in a constant expression}} static_assert(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][2] - 2) == 11, ""); -constexpr int err_zs_1_2_0_0 = zs[1][2][0][0]; // expected-error {{constant expression}} expected-note {{cannot access array element of pointer past the end}} +constexpr int err_zs_1_2_0_0 = zs[1][2][0][0]; // \ +expected-error {{constant expression}} \ +expected-note {{cannot access array element of pointer past the end}} \ +expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}} constexpr int fail(const int &p) { return (&p)[64]; // expected-note {{cannot refer to element 64 of array of 2 elements}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46027: [clang-tidy] Fix PR35824
xazax.hun created this revision. xazax.hun added a reviewer: alexfh. Herald added subscribers: dkrupp, rnkovacs, baloghadamsoftware, whisperity. This approach will also introduce false negatives. A better approach would be to check if the null statement is the result of folding an `if constexpr`. The current AST API does not expose this information. A better fix might require AST patches on the clang side. An alternative version for the current approach is to overload `isConstexpr` matcher to `IfStmt`s. Which solution do you prefer? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D46027 Files: clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp Index: test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp === --- /dev/null +++ test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp @@ -0,0 +1,21 @@ +// RUN: %check_clang_tidy %s bugprone-suspicious-semicolon %t -- -- -std=c++17 + +void fail() +{ + int x = 0; + if(x > 5); (void)x; + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: potentially unintended semicolon [bugprone-suspicious-semicolon] + // CHECK-FIXES: if(x > 5) (void)x; +} + +template +int foo(int a) { +if constexpr(X > 0) { +return a; +} +return a + 1; +} + +int main(void) { +return foo<0>(1); +} Index: clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp === --- clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp +++ clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp @@ -45,12 +45,15 @@ unsigned SemicolonLine = SM.getSpellingLineNumber(LocStart); const auto *Statement = Result.Nodes.getNodeAs("stmt"); - const bool IsIfStmt = isa(Statement); + const auto *IfNode = dyn_cast(Statement); - if (!IsIfStmt && + if (!IfNode && SM.getSpellingLineNumber(Token.getLocation()) != SemicolonLine) return; + if (IfNode && IfNode->isConstexpr()) +return; + SourceLocation LocEnd = Semicolon->getLocEnd(); FileID FID = SM.getFileID(LocEnd); llvm::MemoryBuffer *Buffer = SM.getBuffer(FID, LocEnd); @@ -64,7 +67,7 @@ unsigned NewTokenIndent = SM.getSpellingColumnNumber(Token.getLocation()); unsigned NewTokenLine = SM.getSpellingLineNumber(Token.getLocation()); - if (!IsIfStmt && NewTokenIndent <= BaseIndent && + if (!IfNode && NewTokenIndent <= BaseIndent && Token.getKind() != tok::l_brace && NewTokenLine != SemicolonLine) return; Index: test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp === --- /dev/null +++ test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp @@ -0,0 +1,21 @@ +// RUN: %check_clang_tidy %s bugprone-suspicious-semicolon %t -- -- -std=c++17 + +void fail() +{ + int x = 0; + if(x > 5); (void)x; + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: potentially unintended semicolon [bugprone-suspicious-semicolon] + // CHECK-FIXES: if(x > 5) (void)x; +} + +template +int foo(int a) { +if constexpr(X > 0) { +return a; +} +return a + 1; +} + +int main(void) { +return foo<0>(1); +} Index: clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp === --- clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp +++ clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp @@ -45,12 +45,15 @@ unsigned SemicolonLine = SM.getSpellingLineNumber(LocStart); const auto *Statement = Result.Nodes.getNodeAs("stmt"); - const bool IsIfStmt = isa(Statement); + const auto *IfNode = dyn_cast(Statement); - if (!IsIfStmt && + if (!IfNode && SM.getSpellingLineNumber(Token.getLocation()) != SemicolonLine) return; + if (IfNode && IfNode->isConstexpr()) +return; + SourceLocation LocEnd = Semicolon->getLocEnd(); FileID FID = SM.getFileID(LocEnd); llvm::MemoryBuffer *Buffer = SM.getBuffer(FID, LocEnd); @@ -64,7 +67,7 @@ unsigned NewTokenIndent = SM.getSpellingColumnNumber(Token.getLocation()); unsigned NewTokenLine = SM.getSpellingLineNumber(Token.getLocation()); - if (!IsIfStmt && NewTokenIndent <= BaseIndent && + if (!IfNode && NewTokenIndent <= BaseIndent && Token.getKind() != tok::l_brace && NewTokenLine != SemicolonLine) return; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45470: Emit an error when mixing and
vsapsai planned changes to this revision. vsapsai added inline comments. Comment at: clang/test/Headers/stdatomic.cpp:4 + +#include + mclow.lists wrote: > Is there a reason we want to test this twice - once in clang and once in > libc++? > We can use `expected-error` in libc++ tests to check the error. > The idea was to test `` in clang and `` in libc++. Does that answer your question? I'm not sure I understood it correctly. Good suggestion to use `expected-error` in libc++ test, will add that. https://reviews.llvm.org/D45470 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45964: [Driver] Fix implicit config files from prefixed symlinks
mstorsjo updated this revision to Diff 143794. mstorsjo added a comment. Added an isEmpty() method. Btw, did you see https://bugs.llvm.org/show_bug.cgi?id=37196? That one feels quite a bit more convolved so I don't really know (so far) how to approach fixing that. https://reviews.llvm.org/D45964 Files: include/clang/Driver/ToolChain.h lib/Driver/Driver.cpp test/Driver/config-file3.c Index: test/Driver/config-file3.c === --- test/Driver/config-file3.c +++ test/Driver/config-file3.c @@ -27,6 +27,14 @@ // FULL-NAME: -Wundefined-func-template // FULL-NAME-NOT: -Werror // +//--- Invocation qqq-clang-g++ tries to find config file qqq-clang-g++.cfg even without -no-canonical-prefixes. +// (As the clang executable and symlink are in different directories, this +// requires specifying the path via --config-*-dir= though.) +// +// RUN: %T/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir=%T/testdmode -c %s -### 2>&1 | FileCheck %s -check-prefix SYMLINK +// +// SYMLINK: Configuration file: {{.*}}/testdmode/qqq-clang-g++.cfg +// //--- File specified by --config overrides config inferred from clang executable. // // RUN: %T/testdmode/qqq-clang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --config i386-qqq -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-EXPLICIT Index: lib/Driver/Driver.cpp === --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -129,7 +129,8 @@ void Driver::ParseDriverMode(StringRef ProgramName, ArrayRef Args) { - ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName); + if (ClangNameParts.isEmpty()) +ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName); setDriverModeFromOption(ClangNameParts.DriverMode); for (const char *ArgPtr : Args) { Index: include/clang/Driver/ToolChain.h === --- include/clang/Driver/ToolChain.h +++ include/clang/Driver/ToolChain.h @@ -78,6 +78,10 @@ bool IsRegistered) : TargetPrefix(Target), ModeSuffix(Suffix), DriverMode(Mode), TargetIsValid(IsRegistered) {} + + bool isEmpty() const { +return TargetPrefix.empty() && ModeSuffix.empty() && DriverMode == nullptr; + } }; /// ToolChain - Access to tools for a single platform. Index: test/Driver/config-file3.c === --- test/Driver/config-file3.c +++ test/Driver/config-file3.c @@ -27,6 +27,14 @@ // FULL-NAME: -Wundefined-func-template // FULL-NAME-NOT: -Werror // +//--- Invocation qqq-clang-g++ tries to find config file qqq-clang-g++.cfg even without -no-canonical-prefixes. +// (As the clang executable and symlink are in different directories, this +// requires specifying the path via --config-*-dir= though.) +// +// RUN: %T/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir=%T/testdmode -c %s -### 2>&1 | FileCheck %s -check-prefix SYMLINK +// +// SYMLINK: Configuration file: {{.*}}/testdmode/qqq-clang-g++.cfg +// //--- File specified by --config overrides config inferred from clang executable. // // RUN: %T/testdmode/qqq-clang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --config i386-qqq -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-EXPLICIT Index: lib/Driver/Driver.cpp === --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -129,7 +129,8 @@ void Driver::ParseDriverMode(StringRef ProgramName, ArrayRef Args) { - ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName); + if (ClangNameParts.isEmpty()) +ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName); setDriverModeFromOption(ClangNameParts.DriverMode); for (const char *ArgPtr : Args) { Index: include/clang/Driver/ToolChain.h === --- include/clang/Driver/ToolChain.h +++ include/clang/Driver/ToolChain.h @@ -78,6 +78,10 @@ bool IsRegistered) : TargetPrefix(Target), ModeSuffix(Suffix), DriverMode(Mode), TargetIsValid(IsRegistered) {} + + bool isEmpty() const { +return TargetPrefix.empty() && ModeSuffix.empty() && DriverMode == nullptr; + } }; /// ToolChain - Access to tools for a single platform. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44984: [HIP] Add hip input kind and codegen for kernel launching
tra added inline comments. Comment at: test/CodeGenCUDA/device-stub.cu:2-8 +// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ +// RUN: -fcuda-include-gpubinary %t -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ +// RUN: -fcuda-include-gpubinary %t -o - -DNOGLOBALS \ // RUN: | FileCheck %s -check-prefix=NOGLOBALS -// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=NOGPUBIN +// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - \ +// RUN: | FileCheck %s -check-prefix=NOGPUBIN tra wrote: > The changes in this file do not seem to have anything related to the code > changes in this patch. > Did you intend to add some HIP tests here? Do you need these changes? https://reviews.llvm.org/D44984 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44984: [HIP] Add hip input kind and codegen for kernel launching
yaxunl updated this revision to Diff 143792. yaxunl added a comment. Remove CodeGenModule argument from addPrefix* functions. https://reviews.llvm.org/D44984 Files: include/clang/Basic/IdentifierTable.h include/clang/Basic/LangOptions.def include/clang/Frontend/FrontendOptions.h include/clang/Frontend/LangStandards.def lib/CodeGen/CGCUDANV.cpp lib/Frontend/CompilerInvocation.cpp lib/Frontend/FrontendActions.cpp lib/Frontend/InitPreprocessor.cpp lib/Sema/SemaCUDA.cpp lib/Sema/SemaDecl.cpp test/CodeGenCUDA/device-stub.cu Index: test/CodeGenCUDA/device-stub.cu === --- test/CodeGenCUDA/device-stub.cu +++ test/CodeGenCUDA/device-stub.cu @@ -1,8 +1,11 @@ // RUN: echo "GPU binary would be here" > %t -// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -fcuda-include-gpubinary %t -o - | FileCheck %s -// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -fcuda-include-gpubinary %t -o - -DNOGLOBALS \ +// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ +// RUN: -fcuda-include-gpubinary %t -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ +// RUN: -fcuda-include-gpubinary %t -o - -DNOGLOBALS \ // RUN: | FileCheck %s -check-prefix=NOGLOBALS -// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=NOGPUBIN +// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - \ +// RUN: | FileCheck %s -check-prefix=NOGPUBIN #include "Inputs/cuda.h" @@ -77,10 +80,14 @@ // Test that we've built a function to register kernels and global vars. // CHECK: define internal void @__cuda_register_globals // CHECK: call{{.*}}cudaRegisterFunction(i8** %0, {{.*}}kernelfunc -// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}device_var{{.*}}i32 0, i32 4, i32 0, i32 0 -// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}constant_var{{.*}}i32 0, i32 4, i32 1, i32 0 -// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}ext_device_var{{.*}}i32 1, i32 4, i32 0, i32 0 -// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}ext_constant_var{{.*}}i32 1, i32 4, i32 1, i32 0 +// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}device_var{{.*}} +// CHECK-DAG-SAME: i32 0, i32 4, i32 0, i32 0 +// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}constant_var{{.*}} +// CHECK-DAG-SAME: i32 0, i32 4, i32 1, i32 0 +// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}ext_device_var{{.*}} +// CHECK-DAG-SAME: i32 1, i32 4, i32 0, i32 0 +// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}ext_constant_var{{.*}} +// CHECK-DAG-SAME: i32 1, i32 4, i32 1, i32 0 // CHECK: ret void // Test that we've built constructor.. Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -9056,11 +9056,13 @@ if (getLangOpts().CUDA) { IdentifierInfo *II = NewFD->getIdentifier(); -if (II && II->isStr("cudaConfigureCall") && !NewFD->isInvalidDecl() && +if (II && +II->isStr(getLangOpts().HIP ? "hipConfigureCall" +: "cudaConfigureCall") && +!NewFD->isInvalidDecl() && NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) { if (!R->getAs()->getReturnType()->isScalarType()) Diag(NewFD->getLocation(), diag::err_config_scalar_return); - Context.setcudaConfigureCallDecl(NewFD); } Index: lib/Sema/SemaCUDA.cpp === --- lib/Sema/SemaCUDA.cpp +++ lib/Sema/SemaCUDA.cpp @@ -42,8 +42,9 @@ SourceLocation GGGLoc) { FunctionDecl *ConfigDecl = Context.getcudaConfigureCallDecl(); if (!ConfigDecl) -return ExprError(Diag(oc, diag::err_undeclared_var_use) - << "cudaConfigureCall"); +return ExprError( +Diag(oc, diag::err_undeclared_var_use) +<< (getLangOpts().HIP ? "hipConfigureCall" : "cudaConfigureCall")); QualType ConfigQTy = ConfigDecl->getType(); DeclRefExpr *ConfigDR = new (Context) Index: lib/Frontend/InitPreprocessor.cpp === --- lib/Frontend/InitPreprocessor.cpp +++ lib/Frontend/InitPreprocessor.cpp @@ -471,8 +471,10 @@ // Not "standard" per se, but available even with the -undef flag. if (LangOpts.AsmPreprocessor) Builder.defineMacro("__ASSEMBLER__"); - if (LangOpts.CUDA) + if (LangOpts.CUDA && !LangOpts.HIP) Builder.defineMacro("__CUDA__"); + if (LangOpts.HIP) +Builder.defineMacro("__HIP__"); } /// Initialize the predefined C++ language feature test macros defined in Index: lib/Frontend/FrontendActions.cpp === --- lib/Frontend/FrontendActions.cpp +++ lib/Frontend/FrontendActions.cpp @@ -733,6 +733,7 @@ case InputKind::ObjCXX: case Input
[PATCH] D41316: [libcxx] Allow random_device to be built optionally
bcraig added a comment. For those that would prefer random device to not exist if it isn't cryptographically secure, please write a wg21 paper. I will gladly review such a paper, and if you need a presenter, then I will present it if I am attending. I won't be at Rapperswil, but I will be at San Diego. Stated differently, I agree with both Marshall and the other commenters on this page. I don't want busted random_devices to build, AND I want a standards compliant implementation. To some degree, this overlaps with http://wg21.link/P0829 . That (my) paper does not require random_device to exist in a freestanding environment. Repository: rCXX libc++ https://reviews.llvm.org/D41316 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45891: [clang-tidy] Improve bugprone-unused-return-value check
jbcoe added a comment. I can merge this for you. Congratulations on the commit! Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45891 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r330754 - [clangd] Commit a heinous crime to make test hermetic and not depend on the standard library being around.
Author: d0k Date: Tue Apr 24 11:40:44 2018 New Revision: 330754 URL: http://llvm.org/viewvc/llvm-project?rev=330754&view=rev Log: [clangd] Commit a heinous crime to make test hermetic and not depend on the standard library being around. Added: clang-tools-extra/trunk/test/clangd/Inputs/ clang-tools-extra/trunk/test/clangd/Inputs/sstream.h Modified: clang-tools-extra/trunk/test/clangd/symbols.test Added: clang-tools-extra/trunk/test/clangd/Inputs/sstream.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/Inputs/sstream.h?rev=330754&view=auto == --- clang-tools-extra/trunk/test/clangd/Inputs/sstream.h (added) +++ clang-tools-extra/trunk/test/clangd/Inputs/sstream.h Tue Apr 24 11:40:44 2018 @@ -0,0 +1,3 @@ +namespace std { +class basic_ostringstream {}; +} Modified: clang-tools-extra/trunk/test/clangd/symbols.test URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/symbols.test?rev=330754&r1=330753&r2=330754&view=diff == --- clang-tools-extra/trunk/test/clangd/symbols.test (original) +++ clang-tools-extra/trunk/test/clangd/symbols.test Tue Apr 24 11:40:44 2018 @@ -1,7 +1,7 @@ -# RUN: clangd -lit-test < %s | FileCheck %s +# RUN: env CPATH=%S/Inputs clangd -lit-test < %s | FileCheck %s {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"workspace":{"symbol":{"symbolKind":{"valueSet": [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26],"trace":"off"}} --- -{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"#include \nvoid foo(); int main() { foo(); }\n"}}} +{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"#include \nvoid foo(); int main() { foo(); }\n"}}} --- {"jsonrpc":"2.0","id":1,"method":"workspace/symbol","params":{"query":"std::basic_ostringstream"}} # CHECK: "id": 1, @@ -21,7 +21,7 @@ # CHECK-NEXT: "line": {{.*}} # CHECK-NEXT:} # CHECK-NEXT: }, -# CHECK-NEXT: "uri": "file://{{.*}}/sstream" +# CHECK-NEXT: "uri": "file://{{.*}}/sstream.h" # CHECK-NEXT:}, # CHECK-NEXT:"name": "basic_ostringstream" # CHECK-NEXT: } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45827: [CUDA] Enable CUDA compilation with CUDA-9.2
This revision was automatically updated to reflect the committed changes. Closed by commit rL330753: [CUDA] Enable CUDA compilation with CUDA-9.2 (authored by tra, committed by ). Herald added subscribers: llvm-commits, bixia. Changed prior to commit: https://reviews.llvm.org/D45827?vs=143124&id=143789#toc Repository: rL LLVM https://reviews.llvm.org/D45827 Files: cfe/trunk/include/clang/Basic/Cuda.h cfe/trunk/lib/Basic/Cuda.cpp cfe/trunk/lib/Driver/ToolChains/Cuda.cpp cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h Index: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp === --- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp +++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp @@ -57,6 +57,8 @@ return CudaVersion::CUDA_90; if (Major == 9 && Minor == 1) return CudaVersion::CUDA_91; + if (Major == 9 && Minor == 2) +return CudaVersion::CUDA_92; return CudaVersion::UNKNOWN; } Index: cfe/trunk/lib/Basic/Cuda.cpp === --- cfe/trunk/lib/Basic/Cuda.cpp +++ cfe/trunk/lib/Basic/Cuda.cpp @@ -20,6 +20,8 @@ return "9.0"; case CudaVersion::CUDA_91: return "9.1"; + case CudaVersion::CUDA_92: +return "9.2"; } llvm_unreachable("invalid enum"); } Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h === --- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h +++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h @@ -62,7 +62,7 @@ #include "cuda.h" #if !defined(CUDA_VERSION) #error "cuda.h did not define CUDA_VERSION" -#elif CUDA_VERSION < 7000 || CUDA_VERSION > 9010 +#elif CUDA_VERSION < 7000 || CUDA_VERSION > 9020 #error "Unsupported CUDA version!" #endif @@ -199,6 +199,11 @@ #endif #if CUDA_VERSION >= 9000 +// CUDA-9.2 needs host-side memcpy for some host functions in +// device_functions.hpp +#if CUDA_VERSION >= 9020 +#include +#endif #include "crt/math_functions.hpp" #else #include "math_functions.hpp" Index: cfe/trunk/include/clang/Basic/Cuda.h === --- cfe/trunk/include/clang/Basic/Cuda.h +++ cfe/trunk/include/clang/Basic/Cuda.h @@ -23,7 +23,8 @@ CUDA_80, CUDA_90, CUDA_91, - LATEST = CUDA_91, + CUDA_92, + LATEST = CUDA_92, }; const char *CudaVersionToString(CudaVersion V); Index: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp === --- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp +++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp @@ -57,6 +57,8 @@ return CudaVersion::CUDA_90; if (Major == 9 && Minor == 1) return CudaVersion::CUDA_91; + if (Major == 9 && Minor == 2) +return CudaVersion::CUDA_92; return CudaVersion::UNKNOWN; } Index: cfe/trunk/lib/Basic/Cuda.cpp === --- cfe/trunk/lib/Basic/Cuda.cpp +++ cfe/trunk/lib/Basic/Cuda.cpp @@ -20,6 +20,8 @@ return "9.0"; case CudaVersion::CUDA_91: return "9.1"; + case CudaVersion::CUDA_92: +return "9.2"; } llvm_unreachable("invalid enum"); } Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h === --- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h +++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h @@ -62,7 +62,7 @@ #include "cuda.h" #if !defined(CUDA_VERSION) #error "cuda.h did not define CUDA_VERSION" -#elif CUDA_VERSION < 7000 || CUDA_VERSION > 9010 +#elif CUDA_VERSION < 7000 || CUDA_VERSION > 9020 #error "Unsupported CUDA version!" #endif @@ -199,6 +199,11 @@ #endif #if CUDA_VERSION >= 9000 +// CUDA-9.2 needs host-side memcpy for some host functions in +// device_functions.hpp +#if CUDA_VERSION >= 9020 +#include +#endif #include "crt/math_functions.hpp" #else #include "math_functions.hpp" Index: cfe/trunk/include/clang/Basic/Cuda.h === --- cfe/trunk/include/clang/Basic/Cuda.h +++ cfe/trunk/include/clang/Basic/Cuda.h @@ -23,7 +23,8 @@ CUDA_80, CUDA_90, CUDA_91, - LATEST = CUDA_91, + CUDA_92, + LATEST = CUDA_92, }; const char *CudaVersionToString(CudaVersion V); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330753 - [CUDA] Enable CUDA compilation with CUDA-9.2
Author: tra Date: Tue Apr 24 11:23:19 2018 New Revision: 330753 URL: http://llvm.org/viewvc/llvm-project?rev=330753&view=rev Log: [CUDA] Enable CUDA compilation with CUDA-9.2 Differential Revision: https://reviews.llvm.org/D45827 Modified: cfe/trunk/include/clang/Basic/Cuda.h cfe/trunk/lib/Basic/Cuda.cpp cfe/trunk/lib/Driver/ToolChains/Cuda.cpp cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h Modified: cfe/trunk/include/clang/Basic/Cuda.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Cuda.h?rev=330753&r1=330752&r2=330753&view=diff == --- cfe/trunk/include/clang/Basic/Cuda.h (original) +++ cfe/trunk/include/clang/Basic/Cuda.h Tue Apr 24 11:23:19 2018 @@ -23,7 +23,8 @@ enum class CudaVersion { CUDA_80, CUDA_90, CUDA_91, - LATEST = CUDA_91, + CUDA_92, + LATEST = CUDA_92, }; const char *CudaVersionToString(CudaVersion V); Modified: cfe/trunk/lib/Basic/Cuda.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Cuda.cpp?rev=330753&r1=330752&r2=330753&view=diff == --- cfe/trunk/lib/Basic/Cuda.cpp (original) +++ cfe/trunk/lib/Basic/Cuda.cpp Tue Apr 24 11:23:19 2018 @@ -20,6 +20,8 @@ const char *CudaVersionToString(CudaVers return "9.0"; case CudaVersion::CUDA_91: return "9.1"; + case CudaVersion::CUDA_92: +return "9.2"; } llvm_unreachable("invalid enum"); } Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=330753&r1=330752&r2=330753&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Tue Apr 24 11:23:19 2018 @@ -57,6 +57,8 @@ static CudaVersion ParseCudaVersionFile( return CudaVersion::CUDA_90; if (Major == 9 && Minor == 1) return CudaVersion::CUDA_91; + if (Major == 9 && Minor == 2) +return CudaVersion::CUDA_92; return CudaVersion::UNKNOWN; } Modified: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h?rev=330753&r1=330752&r2=330753&view=diff == --- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h (original) +++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h Tue Apr 24 11:23:19 2018 @@ -62,7 +62,7 @@ #include "cuda.h" #if !defined(CUDA_VERSION) #error "cuda.h did not define CUDA_VERSION" -#elif CUDA_VERSION < 7000 || CUDA_VERSION > 9010 +#elif CUDA_VERSION < 7000 || CUDA_VERSION > 9020 #error "Unsupported CUDA version!" #endif @@ -199,6 +199,11 @@ inline __host__ double __signbitd(double #endif #if CUDA_VERSION >= 9000 +// CUDA-9.2 needs host-side memcpy for some host functions in +// device_functions.hpp +#if CUDA_VERSION >= 9020 +#include +#endif #include "crt/math_functions.hpp" #else #include "math_functions.hpp" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45179: [libc++] Add _LIBCPP_FORCE_NODISCARD define to force-enable nodiscard in pre-C++17
lebedev.ri added inline comments. Comment at: include/__config:1016 +// because GCC does not silence them via (void) cast. +#if __has_cpp_attribute(nodiscard) && _LIBCPP_STD_VER > 17 +# define _LIBCPP_NODISCARD [[nodiscard]] mclow.lists wrote: > lebedev.ri wrote: > > mclow.lists wrote: > > > `[[nodiscard]]` is a C++17 feature. This test should be `>=`, not `>`. > > Indeed, though the left hand side of the diff already specified > > `_LIBCPP_STD_VER > 17`. > > Interesting, isn't it. > That was because the flag `_LIBCPP_NODISCARD_AFTER_CXX17` was only active > post-c++17. > > Now we're talking about doing stuff in earlier standards, we should use > `[[nodiscard]]` for C++17 Oh, right, sorry! Comment at: include/__config:1026 +(_LIBCPP_STD_VER > 17 || defined(_LIBCPP_FORCE_NODISCARD)) +# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD #else mclow.lists wrote: > lebedev.ri wrote: > > mclow.lists wrote: > > > I wouldn't change this; just leave it as `[[nodiscard]]` > > But that would defy the purpose? > That's a fair point - but I don't want this to be anything but > `[[nodiscard]]` if we're compiling for C++2a or later. > > I don't want this to be anything but [[nodiscard]] **if we're compiling for > C++2a or later**. Aha, i see, ok. Repository: rCXX libc++ https://reviews.llvm.org/D45179 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41316: [libcxx] Allow random_device to be built optionally
mclow.lists added a comment. In https://reviews.llvm.org/D41316#1054968, @efriedma wrote: > Yes, the standard says you're allowed to throw an exception from the > random_device constructor, or use a PRNG with an arbitrary seed, or even just > return zeros from operator(). But none of those behaviors are actually > useful; the code will compile, but you won't get the expected randomness. So > I prefer this solution, even if it isn't strictly standard-compliant. I'd very much prefer something standards-compliant. Repository: rCXX libc++ https://reviews.llvm.org/D41316 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45179: [libc++] Add _LIBCPP_FORCE_NODISCARD define to force-enable nodiscard in pre-C++17
mclow.lists added inline comments. Comment at: include/__config:1016 +// because GCC does not silence them via (void) cast. +#if __has_cpp_attribute(nodiscard) && _LIBCPP_STD_VER > 17 +# define _LIBCPP_NODISCARD [[nodiscard]] lebedev.ri wrote: > mclow.lists wrote: > > `[[nodiscard]]` is a C++17 feature. This test should be `>=`, not `>`. > Indeed, though the left hand side of the diff already specified > `_LIBCPP_STD_VER > 17`. > Interesting, isn't it. That was because the flag `_LIBCPP_NODISCARD_AFTER_CXX17` was only active post-c++17. Now we're talking about doing stuff in earlier standards, we should use `[[nodiscard]]` for C++17 Comment at: include/__config:1026 +(_LIBCPP_STD_VER > 17 || defined(_LIBCPP_FORCE_NODISCARD)) +# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD #else lebedev.ri wrote: > mclow.lists wrote: > > I wouldn't change this; just leave it as `[[nodiscard]]` > But that would defy the purpose? That's a fair point - but I don't want this to be anything but `[[nodiscard]]` if we're compiling for C++2a or later. Repository: rCXX libc++ https://reviews.llvm.org/D45179 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45179: [libc++] Add _LIBCPP_FORCE_NODISCARD define to force-enable nodiscard in pre-C++17
lebedev.ri added inline comments. Comment at: include/__config:1016 +// because GCC does not silence them via (void) cast. +#if __has_cpp_attribute(nodiscard) && _LIBCPP_STD_VER > 17 +# define _LIBCPP_NODISCARD [[nodiscard]] mclow.lists wrote: > `[[nodiscard]]` is a C++17 feature. This test should be `>=`, not `>`. Indeed, though the left hand side of the diff already specified `_LIBCPP_STD_VER > 17`. Interesting, isn't it. Comment at: include/__config:1026 +(_LIBCPP_STD_VER > 17 || defined(_LIBCPP_FORCE_NODISCARD)) +# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD #else mclow.lists wrote: > I wouldn't change this; just leave it as `[[nodiscard]]` But that would defy the purpose? Repository: rCXX libc++ https://reviews.llvm.org/D45179 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r330746 - [clangd] Initialize candidate count in unit test
Author: d0k Date: Tue Apr 24 10:57:53 2018 New Revision: 330746 URL: http://llvm.org/viewvc/llvm-project?rev=330746&view=rev Log: [clangd] Initialize candidate count in unit test Found by msan. Modified: clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp Modified: clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp?rev=330746&r1=330745&r2=330746&view=diff == --- clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp Tue Apr 24 10:57:53 2018 @@ -53,7 +53,7 @@ protected: MockCompilationDatabase CDB; IgnoreDiagnostics DiagConsumer; ClangdServer Server; - int Limit; + int Limit = 0; std::vector getSymbols(StringRef Query) { EXPECT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for preamble"; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46024: [clang-format] Add SpaceBeforeCpp11BracedList option.
rkirsling created this revision. rkirsling added reviewers: djasper, klimek. Herald added a subscriber: cfe-commits. WebKit C++ style for object initialization is as follows: Foo foo { bar }; Yet using `clang-format -style=webkit` changes this to: Foo foo{ bar }; As there is no existing combination of rules that will ensure a space before a braced list in this fashion, this patch adds a new SpaceBeforeCpp11BracedList rule. Repository: rC Clang https://reviews.llvm.org/D46024 Files: docs/ClangFormatStyleOptions.rst include/clang/Format/Format.h lib/Format/Format.cpp lib/Format/TokenAnnotator.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -6864,6 +6864,67 @@ verifyFormat("vector foo = { ::SomeGlobalFunction() };", ExtraSpaces); verifyFormat("const struct A a = { .a = 1, .b = 2 };", ExtraSpaces); verifyFormat("const struct A a = { [0] = 1, [1] = 2 };", ExtraSpaces); + + FormatStyle SpaceBeforeBrace = getLLVMStyle(); + SpaceBeforeBrace.SpaceBeforeCpp11BracedList = true; + verifyFormat("vector x {1, 2, 3, 4};", SpaceBeforeBrace); + verifyFormat("vector x {\n" + "1,\n" + "2,\n" + "3,\n" + "4,\n" + "};", + SpaceBeforeBrace); + verifyFormat("vector x {{}, {}, {}, {}};", SpaceBeforeBrace); + verifyFormat("f({1, 2});", SpaceBeforeBrace); + verifyFormat("auto v = Foo {-1};", SpaceBeforeBrace); + verifyFormat("f({1, 2}, {{2, 3}, {4, 5}}, c, {d});", SpaceBeforeBrace); + verifyFormat("Class::Class : member {1, 2, 3} {}", SpaceBeforeBrace); + verifyFormat("new vector {1, 2, 3};", SpaceBeforeBrace); + verifyFormat("new int[3] {1, 2, 3};", SpaceBeforeBrace); + verifyFormat("new int {1};", SpaceBeforeBrace); + verifyFormat("return {arg1, arg2};", SpaceBeforeBrace); + verifyFormat("return {arg1, SomeType {parameter}};", SpaceBeforeBrace); + verifyFormat("int count = set {f(), g(), h()}.size();", + SpaceBeforeBrace); + verifyFormat("new T {arg1, arg2};", SpaceBeforeBrace); + verifyFormat("f(MyMap[{composite, key}]);", SpaceBeforeBrace); + verifyFormat("class Class {\n" + " T member = {arg1, arg2};\n" + "};", + SpaceBeforeBrace); + verifyFormat("vector foo = {::SomeGlobalFunction()};", + SpaceBeforeBrace); + verifyFormat("const struct A a = {.a = 1, .b = 2};", SpaceBeforeBrace); + verifyFormat("const struct A a = {[0] = 1, [1] = 2};", SpaceBeforeBrace); + verifyFormat("static_assert(std::is_integral {} + 0, \"\");", + SpaceBeforeBrace); + verifyFormat("int a = std::is_integral {} + 0;", SpaceBeforeBrace); + verifyFormat("int foo(int i) { return fo1 {}(i); }", SpaceBeforeBrace); + verifyFormat("int foo(int i) { return fo1 {}(i); }", SpaceBeforeBrace); + verifyFormat("auto i = decltype(x) {};", SpaceBeforeBrace); + verifyFormat("std::vector v = {1, 0 /* comment */};", + SpaceBeforeBrace); + verifyFormat("Node n {1, Node {1000}, //\n" + "2};", + SpaceBeforeBrace); + verifyFormat("Aaaa aaa {\n" + "{\n" + ",\n" + "},\n" + "};", + SpaceBeforeBrace); + verifyFormat("class C : public D {\n" + " SomeClass SC {2};\n" + "};", + SpaceBeforeBrace); + verifyFormat("class C : public A {\n" + " class D : public B {\n" + "void f() { int i {2}; }\n" + " };\n" + "};", + SpaceBeforeBrace); + verifyFormat("#define A {a, a},", SpaceBeforeBrace); } TEST_F(FormatTest, FormatsBracedListsInColumnLayout) { @@ -10446,6 +10507,7 @@ CHECK_PARSE_BOOL(SpaceAfterCStyleCast); CHECK_PARSE_BOOL(SpaceAfterTemplateKeyword); CHECK_PARSE_BOOL(SpaceBeforeAssignmentOperators); + CHECK_PARSE_BOOL(SpaceBeforeCpp11BracedList); CHECK_PARSE_BOOL(SpaceBeforeCtorInitializerColon); CHECK_PARSE_BOOL(SpaceBeforeInheritanceColon); CHECK_PARSE_BOOL(SpaceBeforeRangeBasedForLoopColon); Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -2522,6 +2522,9 @@ if (Style.isCpp()) { if (Left.is(tok::kw_operator)) return Right.is(tok::coloncolon); +if (Right.is(tok::l_brace) && Right.BlockKind == BK_BracedInit && +!Left.opensScope() && Style.SpaceBeforeCpp11BracedList) + return true; } else if (Style.Language == FormatStyle::LK_Proto || Style.Language == FormatStyle::LK_TextProto) { if (Right.is(tok::period) && Index: lib/Format/Format.cpp === --- lib/For
[PATCH] D45179: [libc++] Add _LIBCPP_FORCE_NODISCARD define to force-enable nodiscard in pre-C++17
mclow.lists added a comment. In https://reviews.llvm.org/D45179#1077055, @thakis wrote: > So you're happy with this opt-in version? I'm happy with an opt-in mechanism, yes. This one is not quite right yet. BTW, I expect a //large// set of calls in the standard library to get marked as `[[nodiscard]]` in Rapperswil. Comment at: include/__config:1016 +// because GCC does not silence them via (void) cast. +#if __has_cpp_attribute(nodiscard) && _LIBCPP_STD_VER > 17 +# define _LIBCPP_NODISCARD [[nodiscard]] `[[nodiscard]]` is a C++17 feature. This test should be `>=`, not `>`. Comment at: include/__config:1026 +(_LIBCPP_STD_VER > 17 || defined(_LIBCPP_FORCE_NODISCARD)) +# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD #else I wouldn't change this; just leave it as `[[nodiscard]]` Repository: rCXX libc++ https://reviews.llvm.org/D45179 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45964: [Driver] Fix implicit config files from prefixed symlinks
sepavloff accepted this revision. sepavloff added a comment. This revision is now accepted and ready to land. Thank you for fixing this issue! LGTM Comment at: lib/Driver/Driver.cpp:132 ArrayRef Args) { - ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName); + if (ClangNameParts.TargetPrefix.empty() && ClangNameParts.DriverMode == nullptr) +ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName); Maybe this check could be made a method of `ParsedClangName`, something like `isEmpty`? Repository: rC Clang https://reviews.llvm.org/D45964 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45179: [libc++] Add _LIBCPP_FORCE_NODISCARD define to force-enable nodiscard in pre-C++17
rjmccall added a comment. In https://reviews.llvm.org/D45179#1077048, @mclow.lists wrote: > In https://reviews.llvm.org/D45179#1056183, @rjmccall wrote: > > > Is Marshall arguing that the standard doesn't allow compilers to warn about > > failing to use these function results prior to C++17? Because I don't > > think that's true; warnings are thoroughly non-normative. > > > I have proposed to add different forms of "nodiscard" warnings to libc++ in > the past, and received **strong** pushback from people who: > > - Compile with -Werror > - Don't want to change their code. > > I'm not willing to have that argument again. Alright, well, I won't push you on it. Repository: rCXX libc++ https://reviews.llvm.org/D45179 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44984: [HIP] Add hip input kind and codegen for kernel launching
tra added inline comments. Comment at: lib/CodeGen/CGCUDANV.cpp:51-52 llvm::Constant *getLaunchFn() const; + std::string addPrefixToName(CodeGenModule &CGM, StringRef FuncName) const; + std::string addUnderscoredPrefixToName(CodeGenModule &CGM, + StringRef FuncName) const; rjmccall wrote: > tra wrote: > > `const CodeGenModule &CGM` > Why doesn't the CGNVCUDARuntime just hold on to a reference to the CGM? > That's what we do with all the other separated singletons (like the > CGCXXABI), and it would let you avoid some of the redundant fields like > Context and TheModule. Actually, CGCUDARuntime already has CGM field, so the CGM argument can be just dropped. https://reviews.llvm.org/D44984 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45996: [HWASan] Update HWASan assembly snippet in the docs
This revision was automatically updated to reflect the committed changes. Closed by commit rC330745: [HWASan] Update HWASan assembly snippet in the docs (authored by alekseyshl, committed by ). Changed prior to commit: https://reviews.llvm.org/D45996?vs=143671&id=143782#toc Repository: rL LLVM https://reviews.llvm.org/D45996 Files: docs/HardwareAssistedAddressSanitizerDesign.rst Index: docs/HardwareAssistedAddressSanitizerDesign.rst === --- docs/HardwareAssistedAddressSanitizerDesign.rst +++ docs/HardwareAssistedAddressSanitizerDesign.rst @@ -52,15 +52,16 @@ // int foo(int *a) { return *a; } // clang -O2 --target=aarch64-linux -fsanitize=hwaddress -c load.c foo: - 0: 08 dc 44 d3 ubfxx8, x0, #4, #52 // shadow address - 4: 08 01 40 39 ldrbw8, [x8] // load shadow - 8: 09 fc 78 d3 lsr x9, x0, #56 // address tag - c: 3f 01 08 6b cmp w9, w8 // compare tags - 10: 61 00 00 54 b.ne#12 // jump on mismatch - 14: 00 00 40 b9 ldr w0, [x0] // original load - 18: c0 03 5f d6 ret - 1c: 40 20 21 d4 brk #0x902 // trap - + 0: 08 00 00 90 adrpx8, 0 <__hwasan_shadow> + 4: 08 01 40 f9 ldr x8, [x8] // shadow base (to be resolved by the loader) + 8: 09 dc 44 d3 ubfxx9, x0, #4, #52 // shadow offset + c: 28 69 68 38 ldrbw8, [x9, x8] // load shadow tag + 10: 09 fc 78 d3 lsr x9, x0, #56 // extract address tag + 14: 3f 01 08 6b cmp w9, w8 // compare tags + 18: 61 00 00 54 b.ne24 // jump on mismatch + 1c: 00 00 40 b9 ldr w0, [x0] // original load + 20: c0 03 5f d6 ret + 24: 40 20 21 d4 brk #0x902 // trap Alternatively, memory accesses are prefixed with a function call. Index: docs/HardwareAssistedAddressSanitizerDesign.rst === --- docs/HardwareAssistedAddressSanitizerDesign.rst +++ docs/HardwareAssistedAddressSanitizerDesign.rst @@ -52,15 +52,16 @@ // int foo(int *a) { return *a; } // clang -O2 --target=aarch64-linux -fsanitize=hwaddress -c load.c foo: - 0: 08 dc 44 d3 ubfx x8, x0, #4, #52 // shadow address - 4: 08 01 40 39 ldrb w8, [x8] // load shadow - 8: 09 fc 78 d3 lsr x9, x0, #56 // address tag - c: 3f 01 08 6b cmp w9, w8 // compare tags - 10: 61 00 00 54 b.ne #12 // jump on mismatch - 14: 00 00 40 b9 ldr w0, [x0] // original load - 18: c0 03 5f d6 ret - 1c: 40 20 21 d4 brk #0x902 // trap - + 0: 08 00 00 90 adrp x8, 0 <__hwasan_shadow> + 4: 08 01 40 f9 ldr x8, [x8] // shadow base (to be resolved by the loader) + 8: 09 dc 44 d3 ubfx x9, x0, #4, #52 // shadow offset + c: 28 69 68 38 ldrb w8, [x9, x8] // load shadow tag + 10: 09 fc 78 d3 lsr x9, x0, #56 // extract address tag + 14: 3f 01 08 6b cmp w9, w8 // compare tags + 18: 61 00 00 54 b.ne 24 // jump on mismatch + 1c: 00 00 40 b9 ldr w0, [x0] // original load + 20: c0 03 5f d6 ret + 24: 40 20 21 d4 brk #0x902 // trap Alternatively, memory accesses are prefixed with a function call. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45891: [clang-tidy] Improve bugprone-unused-return-value check
khuttun added a comment. Could someone help getting this merged? I don't have commit access to the repo. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45891 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45996: [HWASan] Update HWASan assembly snippet in the docs
This revision was automatically updated to reflect the committed changes. Closed by commit rL330745: [HWASan] Update HWASan assembly snippet in the docs (authored by alekseyshl, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D45996 Files: cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst Index: cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst === --- cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst +++ cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst @@ -52,15 +52,16 @@ // int foo(int *a) { return *a; } // clang -O2 --target=aarch64-linux -fsanitize=hwaddress -c load.c foo: - 0: 08 dc 44 d3 ubfxx8, x0, #4, #52 // shadow address - 4: 08 01 40 39 ldrbw8, [x8] // load shadow - 8: 09 fc 78 d3 lsr x9, x0, #56 // address tag - c: 3f 01 08 6b cmp w9, w8 // compare tags - 10: 61 00 00 54 b.ne#12 // jump on mismatch - 14: 00 00 40 b9 ldr w0, [x0] // original load - 18: c0 03 5f d6 ret - 1c: 40 20 21 d4 brk #0x902 // trap - + 0: 08 00 00 90 adrpx8, 0 <__hwasan_shadow> + 4: 08 01 40 f9 ldr x8, [x8] // shadow base (to be resolved by the loader) + 8: 09 dc 44 d3 ubfxx9, x0, #4, #52 // shadow offset + c: 28 69 68 38 ldrbw8, [x9, x8] // load shadow tag + 10: 09 fc 78 d3 lsr x9, x0, #56 // extract address tag + 14: 3f 01 08 6b cmp w9, w8 // compare tags + 18: 61 00 00 54 b.ne24 // jump on mismatch + 1c: 00 00 40 b9 ldr w0, [x0] // original load + 20: c0 03 5f d6 ret + 24: 40 20 21 d4 brk #0x902 // trap Alternatively, memory accesses are prefixed with a function call. Index: cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst === --- cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst +++ cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst @@ -52,15 +52,16 @@ // int foo(int *a) { return *a; } // clang -O2 --target=aarch64-linux -fsanitize=hwaddress -c load.c foo: - 0: 08 dc 44 d3 ubfx x8, x0, #4, #52 // shadow address - 4: 08 01 40 39 ldrb w8, [x8] // load shadow - 8: 09 fc 78 d3 lsr x9, x0, #56 // address tag - c: 3f 01 08 6b cmp w9, w8 // compare tags - 10: 61 00 00 54 b.ne #12 // jump on mismatch - 14: 00 00 40 b9 ldr w0, [x0] // original load - 18: c0 03 5f d6 ret - 1c: 40 20 21 d4 brk #0x902 // trap - + 0: 08 00 00 90 adrp x8, 0 <__hwasan_shadow> + 4: 08 01 40 f9 ldr x8, [x8] // shadow base (to be resolved by the loader) + 8: 09 dc 44 d3 ubfx x9, x0, #4, #52 // shadow offset + c: 28 69 68 38 ldrb w8, [x9, x8] // load shadow tag + 10: 09 fc 78 d3 lsr x9, x0, #56 // extract address tag + 14: 3f 01 08 6b cmp w9, w8 // compare tags + 18: 61 00 00 54 b.ne 24 // jump on mismatch + 1c: 00 00 40 b9 ldr w0, [x0] // original load + 20: c0 03 5f d6 ret + 24: 40 20 21 d4 brk #0x902 // trap Alternatively, memory accesses are prefixed with a function call. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330745 - [HWASan] Update HWASan assembly snippet in the docs
Author: alekseyshl Date: Tue Apr 24 10:41:48 2018 New Revision: 330745 URL: http://llvm.org/viewvc/llvm-project?rev=330745&view=rev Log: [HWASan] Update HWASan assembly snippet in the docs Summary: To complement https://reviews.llvm.org/D45840 Reviewers: eugenis Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D45996 Modified: cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst Modified: cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst?rev=330745&r1=330744&r2=330745&view=diff == --- cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst (original) +++ cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst Tue Apr 24 10:41:48 2018 @@ -52,15 +52,16 @@ verifies the tags. Currently, the follow // int foo(int *a) { return *a; } // clang -O2 --target=aarch64-linux -fsanitize=hwaddress -c load.c foo: - 0: 08 dc 44 d3 ubfxx8, x0, #4, #52 // shadow address - 4: 08 01 40 39 ldrbw8, [x8] // load shadow - 8: 09 fc 78 d3 lsr x9, x0, #56 // address tag - c: 3f 01 08 6b cmp w9, w8 // compare tags - 10: 61 00 00 54 b.ne#12 // jump on mismatch - 14: 00 00 40 b9 ldr w0, [x0] // original load - 18: c0 03 5f d6 ret - 1c: 40 20 21 d4 brk #0x902 // trap - + 0: 08 00 00 90 adrpx8, 0 <__hwasan_shadow> + 4: 08 01 40 f9 ldr x8, [x8] // shadow base (to be resolved by the loader) + 8: 09 dc 44 d3 ubfxx9, x0, #4, #52 // shadow offset + c: 28 69 68 38 ldrbw8, [x9, x8] // load shadow tag + 10: 09 fc 78 d3 lsr x9, x0, #56 // extract address tag + 14: 3f 01 08 6b cmp w9, w8 // compare tags + 18: 61 00 00 54 b.ne24 // jump on mismatch + 1c: 00 00 40 b9 ldr w0, [x0] // original load + 20: c0 03 5f d6 ret + 24: 40 20 21 d4 brk #0x902 // trap Alternatively, memory accesses are prefixed with a function call. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330744 - [X86] Add recently added intrinsic headers to the module map.
Author: ctopper Date: Tue Apr 24 10:40:49 2018 New Revision: 330744 URL: http://llvm.org/viewvc/llvm-project?rev=330744&view=rev Log: [X86] Add recently added intrinsic headers to the module map. Modified: cfe/trunk/lib/Headers/module.modulemap Modified: cfe/trunk/lib/Headers/module.modulemap URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/module.modulemap?rev=330744&r1=330743&r2=330744&view=diff == --- cfe/trunk/lib/Headers/module.modulemap (original) +++ cfe/trunk/lib/Headers/module.modulemap Tue Apr 24 10:40:49 2018 @@ -63,6 +63,9 @@ module _Builtin_intrinsics [system] [ext textual header "fma4intrin.h" textual header "mwaitxintrin.h" textual header "clzerointrin.h" +textual header "wbnoinvdintrin.h" +textual header "cldemoteintrin.h" +textual header "waitpkgintrin.h" explicit module mm_malloc { requires !freestanding ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330743 - [X86] Consistently use double underscore at the beginning of the include guards in our intrinsic headers.
Author: ctopper Date: Tue Apr 24 10:40:47 2018 New Revision: 330743 URL: http://llvm.org/viewvc/llvm-project?rev=330743&view=rev Log: [X86] Consistently use double underscore at the beginning of the include guards in our intrinsic headers. Most files used double underscore, but a few used single. This converges them all to double. Modified: cfe/trunk/lib/Headers/__wmmintrin_aes.h cfe/trunk/lib/Headers/__wmmintrin_pclmul.h cfe/trunk/lib/Headers/clzerointrin.h cfe/trunk/lib/Headers/mwaitxintrin.h cfe/trunk/lib/Headers/nmmintrin.h cfe/trunk/lib/Headers/popcntintrin.h cfe/trunk/lib/Headers/smmintrin.h cfe/trunk/lib/Headers/waitpkgintrin.h cfe/trunk/lib/Headers/wmmintrin.h Modified: cfe/trunk/lib/Headers/__wmmintrin_aes.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__wmmintrin_aes.h?rev=330743&r1=330742&r2=330743&view=diff == --- cfe/trunk/lib/Headers/__wmmintrin_aes.h (original) +++ cfe/trunk/lib/Headers/__wmmintrin_aes.h Tue Apr 24 10:40:47 2018 @@ -20,8 +20,8 @@ * *===---=== */ -#ifndef _WMMINTRIN_AES_H -#define _WMMINTRIN_AES_H +#ifndef __WMMINTRIN_AES_H +#define __WMMINTRIN_AES_H #include @@ -148,4 +148,4 @@ _mm_aesimc_si128(__m128i __V) #undef __DEFAULT_FN_ATTRS -#endif /* _WMMINTRIN_AES_H */ +#endif /* __WMMINTRIN_AES_H */ Modified: cfe/trunk/lib/Headers/__wmmintrin_pclmul.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__wmmintrin_pclmul.h?rev=330743&r1=330742&r2=330743&view=diff == --- cfe/trunk/lib/Headers/__wmmintrin_pclmul.h (original) +++ cfe/trunk/lib/Headers/__wmmintrin_pclmul.h Tue Apr 24 10:40:47 2018 @@ -20,8 +20,8 @@ * *===---=== */ -#ifndef _WMMINTRIN_PCLMUL_H -#define _WMMINTRIN_PCLMUL_H +#ifndef __WMMINTRIN_PCLMUL_H +#define __WMMINTRIN_PCLMUL_H /// \brief Multiplies two 64-bit integer values, which are selected from source ///operands using the immediate-value operand. The multiplication is a @@ -54,4 +54,4 @@ ((__m128i)__builtin_ia32_pclmulqdq128((__v2di)(__m128i)(__X), \ (__v2di)(__m128i)(__Y), (char)(__I))) -#endif /* _WMMINTRIN_PCLMUL_H */ +#endif /* __WMMINTRIN_PCLMUL_H */ Modified: cfe/trunk/lib/Headers/clzerointrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/clzerointrin.h?rev=330743&r1=330742&r2=330743&view=diff == --- cfe/trunk/lib/Headers/clzerointrin.h (original) +++ cfe/trunk/lib/Headers/clzerointrin.h Tue Apr 24 10:40:47 2018 @@ -24,8 +24,8 @@ #error "Never use directly; include instead." #endif -#ifndef _CLZEROINTRIN_H -#define _CLZEROINTRIN_H +#ifndef __CLZEROINTRIN_H +#define __CLZEROINTRIN_H /* Define the default attributes for the functions in this file. */ #define __DEFAULT_FN_ATTRS \ @@ -47,4 +47,4 @@ _mm_clzero (void * __line) #undef __DEFAULT_FN_ATTRS -#endif /* _CLZEROINTRIN_H */ +#endif /* __CLZEROINTRIN_H */ Modified: cfe/trunk/lib/Headers/mwaitxintrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/mwaitxintrin.h?rev=330743&r1=330742&r2=330743&view=diff == --- cfe/trunk/lib/Headers/mwaitxintrin.h (original) +++ cfe/trunk/lib/Headers/mwaitxintrin.h Tue Apr 24 10:40:47 2018 @@ -25,8 +25,8 @@ #error "Never use directly; include instead." #endif -#ifndef _MWAITXINTRIN_H -#define _MWAITXINTRIN_H +#ifndef __MWAITXINTRIN_H +#define __MWAITXINTRIN_H /* Define the default attributes for the functions in this file. */ #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("mwaitx"))) @@ -44,4 +44,4 @@ _mm_mwaitx(unsigned __extensions, unsign #undef __DEFAULT_FN_ATTRS -#endif /* _MWAITXINTRIN_H */ +#endif /* __MWAITXINTRIN_H */ Modified: cfe/trunk/lib/Headers/nmmintrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/nmmintrin.h?rev=330743&r1=330742&r2=330743&view=diff == --- cfe/trunk/lib/Headers/nmmintrin.h (original) +++ cfe/trunk/lib/Headers/nmmintrin.h Tue Apr 24 10:40:47 2018 @@ -21,10 +21,10 @@ *===---=== */ -#ifndef _NMMINTRIN_H -#define _NMMINTRIN_H +#ifndef __NMMINTRIN_H +#define __NMMINTRIN_H /* To match expectations of gcc we put the sse4.2 definitions into smmintrin.h, just include it now then. */ #include -#endif /* _NMMINTRIN_H */ +#endif /* __NMMINTRIN_H */ Modified: cfe/trunk/lib/Headers/popcntintrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/popcntintrin.h?rev=330743
[PATCH] D44435: CUDA ctor/dtor Module-Unique Symbol Name
tra added inline comments. Comment at: lib/CodeGen/CGCUDANV.cpp:287 +CtorSuffix.append("_"); +CtorSuffix.append(ModuleName); + } SimeonEhrig wrote: > tra wrote: > > There is a general problem with this approach. File name can contain the > > characters that PTX does not allow. > > We currently only deal with '.' and '@', but that's not enough here. > > You may want to either mangle the name somehow to avoid/convert illegal > > characters or use some other way to provide unique suffix. Hex-encoded hash > > of the file name would avoid this problem, for example. > > > > > > > Maybe I'm wrong but I think, that should be no problem, because the > generating of a cuda ctor/dtor have nothing to do with the PTX generation. > > The function 'makeModuleCtorFunction' should just generate llvm ir code for > the host (e.g. x86_64). > > If I'm wrong, could you tell me please, where in the source code the > 'makeModuleCtorFunction' affect the PTX generation. You are correct that PTX is irrelevant here. I've completely missed that this will be generated for the host, which is more forgiving. That said, I'm still not completely sure whether we're guaranteed that using arbitrary characters in a symbol name is OK on x86 and, potentially, other host platforms. As an experiment, try using a module which has a space in its name. https://reviews.llvm.org/D44435 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D45179: [libc++] Add _LIBCPP_FORCE_NODISCARD define to force-enable nodiscard in pre-C++17
So you're happy with this opt-in version? On Tue, Apr 24, 2018 at 1:29 PM, Marshall Clow via Phabricator via cfe-commits wrote: > mclow.lists added a comment. > > In https://reviews.llvm.org/D45179#1056183, @rjmccall wrote: > > > Is Marshall arguing that the standard doesn't allow compilers to warn > about failing to use these function results prior to C++17? Because I > don't think that's true; warnings are thoroughly non-normative. > > > I have proposed to add different forms of "nodiscard" warnings to libc++ > in the past, and received **strong** pushback from people who: > > - Compile with -Werror > - Don't want to change their code. > > I'm not willing to have that argument again. > > > Repository: > rCXX libc++ > > https://reviews.llvm.org/D45179 > > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45179: [libc++] Add _LIBCPP_FORCE_NODISCARD define to force-enable nodiscard in pre-C++17
mclow.lists added a comment. In https://reviews.llvm.org/D45179#1056183, @rjmccall wrote: > Is Marshall arguing that the standard doesn't allow compilers to warn about > failing to use these function results prior to C++17? Because I don't think > that's true; warnings are thoroughly non-normative. I have proposed to add different forms of "nodiscard" warnings to libc++ in the past, and received **strong** pushback from people who: - Compile with -Werror - Don't want to change their code. I'm not willing to have that argument again. Repository: rCXX libc++ https://reviews.llvm.org/D45179 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45921: Add getDeserializationListener to ASTReader
rsmith accepted this revision. rsmith added a comment. This revision is now accepted and ready to land. This seems fine, but I wonder if we should expose a mechanism that will create a multiplex listener automatically as needed? https://reviews.llvm.org/D45921 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46022: [OpenCL] Restrict various keywords in OpenCL C++ mode
rjmccall added a comment. I'm not sure that doing this in the lexer is appropriate; you should just diagnose the unsupported feature in Sema, or at best the parser. Repository: rC Clang https://reviews.llvm.org/D46022 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46007: [analyzer] Add `TaintBugVisitor` to the ArrayBoundV2, DivideZero and VLASize.
a.sidorin added a comment. Mostly LG. Comment at: lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp:75 auto report = llvm::make_unique(*BT, os.str(), N); + report->addVisitor(std::move(Visitor)); report->addRange(SizeE->getSourceRange()); In this patch, sometimes we check the visitor to be non-null, sometimes not. As I can see, `BugReport::addVisitor()` works well with `nullptr` arguments (it checks arguments) so I think we can omit the checks. Repository: rC Clang https://reviews.llvm.org/D46007 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44387: [x86] Introduce the pconfig/encl[u|s|v] intrinsics
craig.topper added a comment. I see that gcc implements all of this with wrappers around inline assembly. Any reason we couldn't just do that? Comment at: lib/Headers/pconfigintrin.h:31 + +#define MKTME_KEY_PROGRAM 0x0001 + This doesn't match the name used by gcc. It also needs to start with underscores since all names without underscores belong to user code. Comment at: lib/Headers/sgxintrin.h:52 +} + +#endif You need to undef __DEFAULT_FN_ATTRS https://reviews.llvm.org/D44387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45532: [StaticAnalyzer] Checker to find uninitialized fields after a constructor call
Szelethus added a comment. I'd also like to point out that as I mentioned before, the checker's name itself is misleading (it is a leftover from an earlier implementation of this checker). Here are just some ideas I came up with: - UninitializedObjectChecker - UninitializedFieldsChecker - UninitializedFieldsAfterConstructionChecker - UninitializedMembersChecker - UninitializedMembersAfterConstructionChecker Of these I like the first the most, but I'm open for anything, if you have an idea for it. In https://reviews.llvm.org/D45532#1075789, @NoQ wrote: > Guys, what do you think about a checker that warns on uninitialized fields > only when at least one field is initialized? I'd be much more confident about > turning such check on by default. We can still keep a `pedantic` version. Sounds good! I just finished implementing it along with a few minor (like some TODOs and fixes according to inline comments) and not-so-minor (like ignoring fields from system headers) changes. I'll update the diff and post results on it once I finish checking the LLVM/Clang project. I feel very confident about the upcoming version. https://reviews.llvm.org/D45532 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46019: [ASTImporter] Fix isa cast assert
a.sidorin accepted this revision. a.sidorin added a comment. This revision is now accepted and ready to land. This LGTM, but could you please add a test? Repository: rC Clang https://reviews.llvm.org/D46019 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45722: [X86] Lowering SAD (sum of absolute differences) intrinsics to native IR (clang side)
craig.topper added inline comments. Comment at: clang/lib/CodeGen/CGBuiltin.cpp:8425 + llvm::Type *VTy = llvm::VectorType::get(QTy, N); + llvm::Type *BTy = llvm::VectorType::get(CGF.Builder.getInt8Ty(), N * 8); + SmallVector ShuffleMask; Is this not a dead variable now? Comment at: clang/lib/CodeGen/CGBuiltin.cpp:8426 + llvm::Type *BTy = llvm::VectorType::get(CGF.Builder.getInt8Ty(), N * 8); + SmallVector ShuffleMask; + ShuffleMask.resize(N); SmallVector ShuffleMask(N); Then you don't need the resize call. https://reviews.llvm.org/D45722 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45984: [X86] directstore and movdir64b intrinsics
craig.topper accepted this revision. craig.topper added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D45984 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46022: [OpenCL] Restrict various keywords in OpenCL C++ mode
svenvh created this revision. svenvh added reviewers: yaxunl, bader. Herald added subscribers: cfe-commits, Anastasia. Restrict the following keywords in the OpenCL C++ language mode, according to Section 2.9 of the OpenCL C++ 1.0 Specification. - dynamic_cast - typeid - goto - register (already restricted in OpenCL C, update the diagnostic) - thread_local - asm - exceptions (try/catch/throw) Support the __global, __local, __constant, __private, and __generic keywords in OpenCL C++. OpenCL C++ does not provide the unprefixed address space qualifiers such as global. Instead, libclcxx provides explicit address space pointer classes such as global_ptr and global that are implemented using the __-prefixed qualifiers. This patch is only a first stab at implementing the restrictions of OpenCL C++ and is by no means complete. It primarily covers restrictions that are easily caught before Sema. Repository: rC Clang https://reviews.llvm.org/D46022 Files: include/clang/Basic/DiagnosticSemaKinds.td include/clang/Basic/TokenKinds.def include/clang/Sema/DeclSpec.h lib/Basic/IdentifierTable.cpp lib/Frontend/CompilerInvocation.cpp lib/Parse/ParseDecl.cpp lib/Sema/DeclSpec.cpp test/Parser/opencl-cl20.cl test/Parser/opencl-cxx-keywords.cl test/Parser/opencl-storage-class.cl test/SemaOpenCL/storageclass.cl test/SemaOpenCLCXX/restricted.cl Index: test/SemaOpenCLCXX/restricted.cl === --- /dev/null +++ test/SemaOpenCLCXX/restricted.cl @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic -verify -fsyntax-only + +// This test checks that various C/C++/OpenCL C constructs are not available in +// OpenCL C++, according to OpenCL C++ 1.0 Specification Section 2.9. + +// Test storage class qualifiers. +kernel void test_storage_classes() { + register int x; + // expected-error@-1 {{OpenCL C++ version 1.0 does not support the 'register' storage class specifier}} + thread_local int y; + // expected-error@-1 {{OpenCL C++ version 1.0 does not support the 'thread_local' storage class specifier}} +} Index: test/SemaOpenCL/storageclass.cl === --- test/SemaOpenCL/storageclass.cl +++ test/SemaOpenCL/storageclass.cl @@ -10,14 +10,14 @@ static global float g_global_static_var = 0; // expected-error {{program scope variable must reside in constant address space}} static local float g_local_static_var = 0; // expected-error {{program scope variable must reside in constant address space}} static private float g_private_static_var = 0; // expected-error {{program scope variable must reside in constant address space}} -static generic float g_generic_static_var = 0; // expected-error{{OpenCL version 1.2 does not support the 'generic' type qualifier}} // expected-error {{program scope variable must reside in constant address space}} +static generic float g_generic_static_var = 0; // expected-error{{OpenCL C version 1.2 does not support the 'generic' type qualifier}} // expected-error {{program scope variable must reside in constant address space}} extern float g_implicit_extern_var; // expected-error {{extern variable must reside in constant address space}} extern constant float g_constant_extern_var; extern global float g_global_extern_var; // expected-error {{extern variable must reside in constant address space}} extern local float g_local_extern_var; // expected-error {{extern variable must reside in constant address space}} extern private float g_private_extern_var; // expected-error {{extern variable must reside in constant address space}} -extern generic float g_generic_extern_var; // expected-error{{OpenCL version 1.2 does not support the 'generic' type qualifier}} // expected-error {{extern variable must reside in constant address space}} +extern generic float g_generic_extern_var; // expected-error{{OpenCL C version 1.2 does not support the 'generic' type qualifier}} // expected-error {{extern variable must reside in constant address space}} void kernel foo(int x) { // static is not allowed at local scope before CL2.0 @@ -32,7 +32,7 @@ constant int L1 = 42; // expected-error {{variables in the constant address space can only be declared in the outermost scope of a kernel function}} } - auto int L3 = 7;// expected-error{{OpenCL version 1.2 does not support the 'auto' storage class specifier}} + auto int L3 = 7;// expected-error{{OpenCL C version 1.2 does not support the 'auto' storage class specifier}} global int L4; // expected-error{{function scope variable cannot be declared in global address space}} __attribute__((address_space(100))) int L5; // expected-error{{automatic variable qualified with an invalid address space}} @@ -64,12 +64,12 @@ static global float l_global_static_var = 0; // expected-
[PATCH] D45985: [test] Add a testcase for MinGW sysroot detections from SVN r330244. NFC.
rnk accepted this revision. rnk added a comment. This revision is now accepted and ready to land. lgtm Comment at: test/Driver/mingw-sysroot.cpp:1-2 +// REQUIRES: shell +// UNSUPPORTED: system-windows + Hah. :) Repository: rC Clang https://reviews.llvm.org/D45985 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44882: [clangd] Implementation of workspace/symbol request
malaperle added a comment. In https://reviews.llvm.org/D44882#1076864, @sammccall wrote: > So this fails if there's no standard library available without flags, which > is the case in google's test environment to ensure hermeticity :-( > > In the short-term, we've disabled the test internally - did it trigger any > buildbot failures? > In the medium term we should probably find a better way to test this :( No buildbot failures yet. But I suggest we just remove the test and add it back when we collect more symbols, i.e. in main files. WDYT? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D44882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34331: func.wrap.func.con: Unset function before destroying anything
mclow.lists accepted this revision. mclow.lists added a comment. Please move the tests into test/std and commit. https://reviews.llvm.org/D34331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46019: [ASTImporter] Fix isa cast assert
martong created this revision. martong added reviewers: a.sidorin, xazax.hun, szepet. Herald added subscribers: cfe-commits, dkrupp, rnkovacs. Do early return if we can't import the found decl for a member expr. This follows the pre-existing scheme, e.g with E->getMemberDecl(). Repository: rC Clang https://reviews.llvm.org/D46019 Files: lib/AST/ASTImporter.cpp Index: lib/AST/ASTImporter.cpp === --- lib/AST/ASTImporter.cpp +++ lib/AST/ASTImporter.cpp @@ -6085,9 +6085,13 @@ if (!ToMember && E->getMemberDecl()) return nullptr; - DeclAccessPair ToFoundDecl = DeclAccessPair::make( -dyn_cast(Importer.Import(E->getFoundDecl().getDecl())), -E->getFoundDecl().getAccess()); + auto *ToDecl = + dyn_cast_or_null(Importer.Import(E->getFoundDecl().getDecl())); + if (!ToDecl && E->getFoundDecl().getDecl()) +return nullptr; + + DeclAccessPair ToFoundDecl = + DeclAccessPair::make(ToDecl, E->getFoundDecl().getAccess()); DeclarationNameInfo ToMemberNameInfo( Importer.Import(E->getMemberNameInfo().getName()), Index: lib/AST/ASTImporter.cpp === --- lib/AST/ASTImporter.cpp +++ lib/AST/ASTImporter.cpp @@ -6085,9 +6085,13 @@ if (!ToMember && E->getMemberDecl()) return nullptr; - DeclAccessPair ToFoundDecl = DeclAccessPair::make( -dyn_cast(Importer.Import(E->getFoundDecl().getDecl())), -E->getFoundDecl().getAccess()); + auto *ToDecl = + dyn_cast_or_null(Importer.Import(E->getFoundDecl().getDecl())); + if (!ToDecl && E->getFoundDecl().getDecl()) +return nullptr; + + DeclAccessPair ToFoundDecl = + DeclAccessPair::make(ToDecl, E->getFoundDecl().getAccess()); DeclarationNameInfo ToMemberNameInfo( Importer.Import(E->getMemberNameInfo().getName()), ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45470: Emit an error when mixing and
mclow.lists added inline comments. Comment at: clang/test/Headers/stdatomic.cpp:4 + +#include + Is there a reason we want to test this twice - once in clang and once in libc++? We can use `expected-error` in libc++ tests to check the error. https://reviews.llvm.org/D45470 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44882: [clangd] Implementation of workspace/symbol request
sammccall added a comment. In https://reviews.llvm.org/D44882#1066743, @malaperle wrote: > In https://reviews.llvm.org/D44882#1065632, @sammccall wrote: > > > In https://reviews.llvm.org/D44882#1065631, @malaperle wrote: > > > > > In https://reviews.llvm.org/D44882#1065622, @sammccall wrote: > > > > > > > Still LG, thanks! > > > > I'll look into the testing issue. > > > > > > > > > I thought about it after... I think it was because I was trying to test > > > with std::unordered_map (to prevent multiple results) which needs > > > std=c++11, I'll try with something else. > > > > > > Worth a shot, but don't count on it - for c++ clang switched to using > > std=c++11 by default a while ago. > > > I just tried "std::basic_ostringstream" and that works. Seems safer. So this fails if there's no standard library available without flags, which is the case in google's test environment to ensure hermeticity :-( In the short-term, we've disabled the test internally - did it trigger any buildbot failures? In the medium term we should probably find a better way to test this :( Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D44882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D42966: Fix USR generation in the presence of #line directives or linemarkes
ilya-biryukov added a comment. Sorry for the delay. In https://reviews.llvm.org/D42966#1069674, @mikhail.ramalho wrote: > Sure. Basically, the previous code would not generate the USR for the > function's parameters. > The issue was that SM.getFileEntryForID would return NULL because there is > no actual file Why wasn't there a file for function parameter? Function parameters *are* declared in some file, or am I missing something? More general question is: how do we want USRs for function parameters to work, specifically should USR of the same param of different declarations be the same or different? Repository: rC Clang https://reviews.llvm.org/D42966 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D42966: Fix USR generation in the presence of #line directives or linemarkes
ilya-biryukov added a comment. In https://reviews.llvm.org/D42966#1069674, @mikhail.ramalho wrote: > Sure. Basically, the previous code would not generate the USR for the > function's parameters. > > The issue was that SM.getFileEntryForID would return NULL because there is no > actual file, that's why I changed to get the presumedLoc and build the name > using the column/line. > > I know that using column/line not the preferable method to generate USR but I > couldn't find a way to generate the offset of a presumed location. Repository: rC Clang https://reviews.llvm.org/D42966 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44984: [HIP] Add hip input kind and codegen for kernel launching
rjmccall added a comment. Otherwise LGTM. Comment at: lib/CodeGen/CGCUDANV.cpp:51-52 llvm::Constant *getLaunchFn() const; + std::string addPrefixToName(CodeGenModule &CGM, StringRef FuncName) const; + std::string addUnderscoredPrefixToName(CodeGenModule &CGM, + StringRef FuncName) const; tra wrote: > `const CodeGenModule &CGM` Why doesn't the CGNVCUDARuntime just hold on to a reference to the CGM? That's what we do with all the other separated singletons (like the CGCXXABI), and it would let you avoid some of the redundant fields like Context and TheModule. https://reviews.llvm.org/D44984 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46015: [OpenCL] Add separate read_only and write_only pipe IR types
stuart created this revision. stuart added reviewers: Anastasia, yaxunl. Herald added a subscriber: cfe-commits. SPIR-V encodes the read_only and write_only access qualifiers of pipes, so separate LLVM IR types are required to target SPIR-V. Other backends may also find this useful. These new types are opencl.pipe_ro_t and opencl.pipe_wo_t, which replace opencl.pipe_t. This replaces __get_pipe_num_packets(...) and __get_pipe_max_packets(...) which took a read_only pipe with separate versions for read_only and write_only pipes, namely: - __get_pipe_num_packets_ro(...) - __get_pipe_num_packets_wo(...) - __get_pipe_max_packets_ro(...) - __get_pipe_max_packets_wo(...) Repository: rC Clang https://reviews.llvm.org/D46015 Files: lib/CodeGen/CGBuiltin.cpp lib/CodeGen/CGOpenCLRuntime.cpp lib/CodeGen/CGOpenCLRuntime.h test/CodeGenOpenCL/opencl_types.cl test/CodeGenOpenCL/pipe_builtin.cl test/CodeGenOpenCL/pipe_types.cl test/Index/pipe-size.cl Index: test/Index/pipe-size.cl === --- test/Index/pipe-size.cl +++ test/Index/pipe-size.cl @@ -5,12 +5,12 @@ __kernel void testPipe( pipe int test ) { int s = sizeof(test); -// X86: store %opencl.pipe_t* %test, %opencl.pipe_t** %test.addr, align 8 +// X86: store %opencl.pipe_ro_t* %test, %opencl.pipe_ro_t** %test.addr, align 8 // X86: store i32 8, i32* %s, align 4 -// SPIR: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)** %test.addr, align 4 +// SPIR: store %opencl.pipe_ro_t addrspace(1)* %test, %opencl.pipe_ro_t addrspace(1)** %test.addr, align 4 // SPIR: store i32 4, i32* %s, align 4 -// SPIR64: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)** %test.addr, align 8 +// SPIR64: store %opencl.pipe_ro_t addrspace(1)* %test, %opencl.pipe_ro_t addrspace(1)** %test.addr, align 8 // SPIR64: store i32 8, i32* %s, align 4 -// AMDGCN: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)* addrspace(5)* %test.addr, align 8 +// AMDGCN: store %opencl.pipe_ro_t addrspace(1)* %test, %opencl.pipe_ro_t addrspace(1)* addrspace(5)* %test.addr, align 8 // AMDGCN: store i32 8, i32 addrspace(5)* %s, align 4 } Index: test/CodeGenOpenCL/pipe_types.cl === --- test/CodeGenOpenCL/pipe_types.cl +++ test/CodeGenOpenCL/pipe_types.cl @@ -1,34 +1,35 @@ // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s -// CHECK: %opencl.pipe_t = type opaque +// CHECK: %opencl.pipe_ro_t = type opaque +// CHECK: %opencl.pipe_wo_t = type opaque typedef unsigned char __attribute__((ext_vector_type(3))) uchar3; typedef int __attribute__((ext_vector_type(4))) int4; void test1(read_only pipe int p) { -// CHECK: define void @test1(%opencl.pipe_t* %p) +// CHECK: define void @test1(%opencl.pipe_ro_t* %p) reserve_id_t rid; // CHECK: %rid = alloca %opencl.reserve_id_t } void test2(write_only pipe float p) { -// CHECK: define void @test2(%opencl.pipe_t* %p) +// CHECK: define void @test2(%opencl.pipe_wo_t* %p) } void test3(read_only pipe const int p) { -// CHECK: define void @test3(%opencl.pipe_t* %p) +// CHECK: define void @test3(%opencl.pipe_ro_t* %p) } void test4(read_only pipe uchar3 p) { -// CHECK: define void @test4(%opencl.pipe_t* %p) +// CHECK: define void @test4(%opencl.pipe_ro_t* %p) } void test5(read_only pipe int4 p) { -// CHECK: define void @test5(%opencl.pipe_t* %p) +// CHECK: define void @test5(%opencl.pipe_ro_t* %p) } typedef read_only pipe int MyPipe; kernel void test6(MyPipe p) { -// CHECK: define spir_kernel void @test6(%opencl.pipe_t* %p) +// CHECK: define spir_kernel void @test6(%opencl.pipe_ro_t* %p) } struct Person { @@ -41,7 +42,7 @@ read_only pipe struct Person SPipe) { // CHECK: define void @test_reserved_read_pipe read_pipe (SPipe, SDst); - // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 16, i32 8) + // CHECK: call i32 @__read_pipe_2(%opencl.pipe_ro_t* %{{.*}}, i8* %{{.*}}, i32 16, i32 8) read_pipe (SPipe, SDst); - // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 16, i32 8) + // CHECK: call i32 @__read_pipe_2(%opencl.pipe_ro_t* %{{.*}}, i8* %{{.*}}, i32 16, i32 8) } Index: test/CodeGenOpenCL/pipe_builtin.cl === --- test/CodeGenOpenCL/pipe_builtin.cl +++ test/CodeGenOpenCL/pipe_builtin.cl @@ -1,79 +1,93 @@ // RUN: %clang_cc1 -emit-llvm -cl-ext=+cl_khr_subgroups -O0 -cl-std=CL2.0 -o - %s | FileCheck %s -// CHECK: %opencl.pipe_t = type opaque -// CHECK: %opencl.reserve_id_t = type opaque +// CHECK-DAG: %opencl.pipe_ro_t = type opaque +// CHECK-DAG: %opencl.pipe_wo_t = type opaque +// CHECK-DAG: %opencl.reserve_id_t = type opaque #pragma OPENCL EXTENSION cl_khr_subgroups : enable void test