Re: [llvm-branch-commits] [clang] c3a21e5 - [ASTMatchers] Ensure that we can match inside lambdas
This patch causes practically infinite traversal times on code that contains deeply nested lambdas. Please fix or revert the commit. There's a very simple test case (add more nesting, if it's still fast ;): void f() { [] { [] { [] { [] { [] { [] { [] { [] { [] { [] { [] { [] { [] { [] { [] { [] { [] { [] { [] { [] { [] { [] { [] { [] { [] { [] { [] { [] { [] { }(); }(); }(); }(); }(); }(); }(); }(); }(); }(); }(); }(); }(); }(); }(); }(); }(); }(); }(); }(); }(); }(); }(); }(); }(); }(); }(); }(); }(); } Three nested lambdas are enough to demonstrate the issue by looking at the AST dump. The body of the innermost lambda (0x45593fda99a0) is printed 8 times, and it will be traversed 8 times as well by AST matchers: `-FunctionDecl 0x45593fda9198 line:1:6 f 'void ()' `-CompoundStmt 0x45593fdce970 `-ExprWithCleanups 0x45593fdce958 'void':'void' `-CXXOperatorCallExpr 0x45593fdce928 'void':'void' '()' |-ImplicitCastExpr 0x45593fdce8b0 'auto (*)() const -> void' | `-DeclRefExpr 0x45593fdce890 'auto () const -> void' lvalue CXXMethod 0x45593fda9490 'operator()' 'auto () const -> void' `-ImplicitCastExpr 0x45593fdce910 'const (lambda at /tmp/nested-lambdas.cc:2:3)' lvalue `-MaterializeTemporaryExpr 0x45593fdce8f8 '(lambda at /tmp/nested-lambdas.cc:2:3)' lvalue `-LambdaExpr 0x45593fdce788 '(lambda at /tmp/nested-lambdas.cc:2:3)' |-CXXRecordDecl 0x45593fda9350 col:3 implicit class definition | |-DefinitionData lambda pass_in_registers empty standard_layout trivially_copyable literal can_const_default_init | | |-DefaultConstructor defaulted_is_constexpr | | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param | | |-MoveConstructor exists simple trivial needs_implicit | | |-CopyAssignment trivial has_const_param needs_implicit implicit_has_const_param | | |-MoveAssignment | | `-Destructor simple irrelevant trivial | |-CXXMethodDecl 0x45593fda9490 line:2:3 used constexpr operator() 'auto () const -> void' inline | | `-CompoundStmt 0x45593fdce4e0 | | `-ExprWithCleanups 0x45593fdce4c8 'void':'void' | | `-CXXOperatorCallExpr 0x45593fdce498 'void':'void' '()' | | |-ImplicitCastExpr 0x45593fdce420 'auto (*)() const -> void' | | | `-DeclRefExpr 0x45593fdce400 'auto () const -> void' lvalue CXXMethod 0x45593fda96c0 'operator()' 'auto () const -> void' | | `-ImplicitCastExpr 0x45593fdce480 'const (lambda at /tmp/nested-lambdas.cc:3:3)' lvalue | | `-MaterializeTemporaryExpr 0x45593fdce468 '(lambda at /tmp/nested-lambdas.cc:3:3)' lvalue | | `-LambdaExpr 0x45593fdce2f0 '(lambda at /tmp/nested-lambdas.cc:3:3)' | | |-CXXRecordDecl 0x45593fda9588 col:3 implicit class definition | | | |-DefinitionData lambda pass_in_registers empty standard_layout trivially_copyable literal can_const_default_init | | | | |-DefaultConstructor defaulted_is_constexpr | | | | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param | | | | |-MoveConstructor exists simple trivial needs_implicit | | | | |-CopyAssignment trivial has_const_param needs_implicit implicit_has_const_param | | | | |-MoveAssignment | | | | `-Destructor simple irrelevant trivial | | | |-CXXMethodDecl 0x45593fda96c0 line:3:3 used constexpr operator() 'auto () const -> void' inline | | | | `-CompoundStmt 0x45593fdce048 | | | | `-ExprWithCleanups 0x45593fdce030 'void':'void' | | | | `-CXXOperatorCallExpr 0x45593fdce000 'void':'void' '()' | | | | |-ImplicitCastExpr 0x45593fda9f88 'auto (*)() const -> void' | | | | | `-DeclRefExpr 0x45593fda9f08 'auto () const -> void' lvalue CXXMethod 0x45593fda98f0 'operator()' 'auto () const -> void' | | | | `-ImplicitCastExpr 0x45593fda9fe0 'const (lambda at /tmp/nested-lambdas.cc:4:3)' lvalue | | | | `-MaterializeTemporaryExpr 0x45593fda9fc8 '(lambda at /tmp/nested-lambdas.cc:4:3)' lvalue | | | | `-LambdaExpr 0x45593fda9dd0 '(lambda at /tmp/nested-lambdas.cc:4:3)' | | | | |-CXXRecordDecl 0x45593fda97b8 col:3 implicit class definition | | | | | |-Defin
[llvm-branch-commits] [libcxx] 7051e79 - Drop the 'git' suffix from various version variables
Author: Tom Stellard Date: 2021-01-27T15:21:24-08:00 New Revision: 7051e794ceb6399429ab1b961a13e6876ea93943 URL: https://github.com/llvm/llvm-project/commit/7051e794ceb6399429ab1b961a13e6876ea93943 DIFF: https://github.com/llvm/llvm-project/commit/7051e794ceb6399429ab1b961a13e6876ea93943.diff LOG: Drop the 'git' suffix from various version variables Added: Modified: libcxx/CMakeLists.txt libcxxabi/CMakeLists.txt libunwind/CMakeLists.txt llvm/CMakeLists.txt Removed: diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index 4e7e8f978546..9bf1a02f0908 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -29,7 +29,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXX_STANDALONE_BUIL project(libcxx CXX C) set(PACKAGE_NAME libcxx) - set(PACKAGE_VERSION 12.0.0git) + set(PACKAGE_VERSION 12.0.0) set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org") diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt index b803347c2a8e..426c855288fc 100644 --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -28,7 +28,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXXABI_STANDALONE_B project(libcxxabi CXX C) set(PACKAGE_NAME libcxxabi) - set(PACKAGE_VERSION 11.0.0git) + set(PACKAGE_VERSION 11.0.0) set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org") diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index 8ae32fbccf4e..48cb8e004e08 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -24,7 +24,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBUNWIND_STANDALONE_B project(libunwind LANGUAGES C CXX ASM) set(PACKAGE_NAME libunwind) - set(PACKAGE_VERSION 12.0.0git) + set(PACKAGE_VERSION 12.0.0) set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org") diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 454ec561af9a..277d0fe54d7b 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -14,7 +14,7 @@ if(NOT DEFINED LLVM_VERSION_PATCH) set(LLVM_VERSION_PATCH 0) endif() if(NOT DEFINED LLVM_VERSION_SUFFIX) - set(LLVM_VERSION_SUFFIX git) + set(LLVM_VERSION_SUFFIX "") endif() if (NOT PACKAGE_VERSION) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] d64226e - [clangd] Work around GCC bug 66735
Author: Sam McCall Date: 2021-01-27T15:23:35-08:00 New Revision: d64226e8fab8fc7b4d947223c61036a60eb6a871 URL: https://github.com/llvm/llvm-project/commit/d64226e8fab8fc7b4d947223c61036a60eb6a871 DIFF: https://github.com/llvm/llvm-project/commit/d64226e8fab8fc7b4d947223c61036a60eb6a871.diff LOG: [clangd] Work around GCC bug 66735 (cherry picked from commit 12de8e1399fecf691639ba430b3824acb1311e70) Added: Modified: clang-tools-extra/clangd/ParsedAST.cpp Removed: diff --git a/clang-tools-extra/clangd/ParsedAST.cpp b/clang-tools-extra/clangd/ParsedAST.cpp index 403d3fe3e64f..1020282f5ee8 100644 --- a/clang-tools-extra/clangd/ParsedAST.cpp +++ b/clang-tools-extra/clangd/ParsedAST.cpp @@ -316,8 +316,8 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs, Check->registerMatchers(&CTFinder); } -ASTDiags.setLevelAdjuster([&, &Cfg(Config::current())]( - DiagnosticsEngine::Level DiagLevel, +const Config& Cfg = Config::current(); +ASTDiags.setLevelAdjuster([&](DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &Info) { if (Cfg.Diagnostics.SuppressAll || isBuiltinDiagnosticSuppressed(Info.getID(), Cfg.Diagnostics.Suppress)) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] ea99c88 - Permit __VA_OPT__ in all language modes and allow it to be detected with #ifdef.
Author: Richard Smith Date: 2021-01-27T15:52:31-08:00 New Revision: ea99c885a63de9af673a5e5cd51f44fb70c83c1b URL: https://github.com/llvm/llvm-project/commit/ea99c885a63de9af673a5e5cd51f44fb70c83c1b DIFF: https://github.com/llvm/llvm-project/commit/ea99c885a63de9af673a5e5cd51f44fb70c83c1b.diff LOG: Permit __VA_OPT__ in all language modes and allow it to be detected with #ifdef. These changes are intended to give code a path to move away from the GNU ,##__VA_ARGS__ extension, which is non-conforming in some situations and which we'd like to disable in our conforming mode in those cases. (cherry picked from commit 0436ec2128c9775ba13b0308937238fc79673fdd) Added: Modified: clang/include/clang/Lex/Preprocessor.h clang/include/clang/Lex/VariadicMacroSupport.h clang/lib/Lex/PPDirectives.cpp clang/lib/Lex/PPExpressions.cpp clang/lib/Lex/PPMacroExpansion.cpp clang/lib/Lex/Preprocessor.cpp clang/test/Preprocessor/macro_vaopt_check.cpp clang/test/Preprocessor/macro_vaopt_expand.cpp Removed: diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h index 68139cb24b31..ba8bdaa23c4c 100644 --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -447,6 +447,25 @@ class Preprocessor { ElseLoc(ElseLoc) {} }; + class IfdefMacroNameScopeRAII { +Preprocessor &PP; +bool VAOPTWasPoisoned; + + public: +IfdefMacroNameScopeRAII(Preprocessor &PP) +: PP(PP), VAOPTWasPoisoned(PP.Ident__VA_OPT__->isPoisoned()) { + PP.Ident__VA_OPT__->setIsPoisoned(false); +} +IfdefMacroNameScopeRAII(const IfdefMacroNameScopeRAII&) = delete; +IfdefMacroNameScopeRAII &operator=(const IfdefMacroNameScopeRAII&) = delete; +~IfdefMacroNameScopeRAII() { Exit(); } + +void Exit() { + if (VAOPTWasPoisoned) +PP.Ident__VA_OPT__->setIsPoisoned(true); +} + }; + private: friend class ASTReader; friend class MacroArgs; diff --git a/clang/include/clang/Lex/VariadicMacroSupport.h b/clang/include/clang/Lex/VariadicMacroSupport.h index 989e0ac703c9..119f02201fc6 100644 --- a/clang/include/clang/Lex/VariadicMacroSupport.h +++ b/clang/include/clang/Lex/VariadicMacroSupport.h @@ -39,17 +39,14 @@ namespace clang { assert(Ident__VA_ARGS__->isPoisoned() && "__VA_ARGS__ should be poisoned " "outside an ISO C/C++ variadic " "macro definition!"); - assert( - !Ident__VA_OPT__ || - (Ident__VA_OPT__->isPoisoned() && "__VA_OPT__ should be poisoned!")); + assert(Ident__VA_OPT__->isPoisoned() && "__VA_OPT__ should be poisoned!"); } /// Client code should call this function just before the Preprocessor is /// about to Lex tokens from the definition of a variadic (ISO C/C++) macro. void enterScope() { Ident__VA_ARGS__->setIsPoisoned(false); - if (Ident__VA_OPT__) -Ident__VA_OPT__->setIsPoisoned(false); + Ident__VA_OPT__->setIsPoisoned(false); } /// Client code should call this function as soon as the Preprocessor has @@ -58,8 +55,7 @@ namespace clang { /// (might be explicitly called, and then reinvoked via the destructor). void exitScope() { Ident__VA_ARGS__->setIsPoisoned(true); - if (Ident__VA_OPT__) -Ident__VA_OPT__->setIsPoisoned(true); + Ident__VA_OPT__->setIsPoisoned(true); } ~VariadicMacroScopeGuard() { exitScope(); } diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index d6b03d85913d..e2aa93455ea5 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -2928,9 +2928,14 @@ void Preprocessor::HandleIfdefDirective(Token &Result, ++NumIf; Token DirectiveTok = Result; + // __VA_OPT__ is allowed as the operand of #if[n]def. + IfdefMacroNameScopeRAII IfdefMacroNameScope(*this); + Token MacroNameTok; ReadMacroName(MacroNameTok); + IfdefMacroNameScope.Exit(); + // Error reading macro name? If so, diagnostic already issued. if (MacroNameTok.is(tok::eod)) { // Skip code until we get to #endif. This helps with recovery by not diff --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp index 8c120c13d7d2..952fb8f121dc 100644 --- a/clang/lib/Lex/PPExpressions.cpp +++ b/clang/lib/Lex/PPExpressions.cpp @@ -104,6 +104,9 @@ static bool EvaluateDefined(PPValue &Result, Token &PeekTok, DefinedTracker &DT, SourceLocation beginLoc(PeekTok.getLocation()); Result.setBegin(beginLoc); + // __VA_OPT__ is allowed as the operand of 'defined'. + Preprocessor::IfdefMacroNameScopeRAII IfdefMacroNameScope(PP); + // Get the next token, don't expand it. PP.LexUnexpandedNonComment(PeekTok); @@ -122,6 +125,8 @@ static bool EvaluateDefined(PPValue &Result
[llvm-branch-commits] [clang] 9ea2a10 - Don't allow __VA_OPT__ to be detected by #ifdef.
Author: Richard Smith Date: 2021-01-27T15:52:31-08:00 New Revision: 9ea2a107ca4055a3a4960cb6dffb84b7f43bd8ea URL: https://github.com/llvm/llvm-project/commit/9ea2a107ca4055a3a4960cb6dffb84b7f43bd8ea DIFF: https://github.com/llvm/llvm-project/commit/9ea2a107ca4055a3a4960cb6dffb84b7f43bd8ea.diff LOG: Don't allow __VA_OPT__ to be detected by #ifdef. More study has discovered this to not actually be useful: because current C++20 implementations reject `#ifdef __VA_OPT__`, this can't really be used as a feature-test mechanism. And it's not too hard to detect __VA_OPT__ without this, for example: #define THIRD_ARG(a, b, c, ...) c #define HAS_VA_OPT(...) THIRD_ARG(__VA_OPT__(,), 1, 0, ) #if HAS_VA_OPT(?) Partially reverts 0436ec2128c9775ba13b0308937238fc79673fdd. (cherry picked from commit 5dfa37a76153f2a18ac7fe30721cc1332b672ea2) Added: Modified: clang/include/clang/Lex/Preprocessor.h clang/lib/Lex/PPDirectives.cpp clang/lib/Lex/PPExpressions.cpp clang/lib/Lex/PPMacroExpansion.cpp clang/lib/Lex/Preprocessor.cpp clang/test/Preprocessor/macro_vaopt_check.cpp Removed: diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h index ba8bdaa23c4c..68139cb24b31 100644 --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -447,25 +447,6 @@ class Preprocessor { ElseLoc(ElseLoc) {} }; - class IfdefMacroNameScopeRAII { -Preprocessor &PP; -bool VAOPTWasPoisoned; - - public: -IfdefMacroNameScopeRAII(Preprocessor &PP) -: PP(PP), VAOPTWasPoisoned(PP.Ident__VA_OPT__->isPoisoned()) { - PP.Ident__VA_OPT__->setIsPoisoned(false); -} -IfdefMacroNameScopeRAII(const IfdefMacroNameScopeRAII&) = delete; -IfdefMacroNameScopeRAII &operator=(const IfdefMacroNameScopeRAII&) = delete; -~IfdefMacroNameScopeRAII() { Exit(); } - -void Exit() { - if (VAOPTWasPoisoned) -PP.Ident__VA_OPT__->setIsPoisoned(true); -} - }; - private: friend class ASTReader; friend class MacroArgs; diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index e2aa93455ea5..d6b03d85913d 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -2928,14 +2928,9 @@ void Preprocessor::HandleIfdefDirective(Token &Result, ++NumIf; Token DirectiveTok = Result; - // __VA_OPT__ is allowed as the operand of #if[n]def. - IfdefMacroNameScopeRAII IfdefMacroNameScope(*this); - Token MacroNameTok; ReadMacroName(MacroNameTok); - IfdefMacroNameScope.Exit(); - // Error reading macro name? If so, diagnostic already issued. if (MacroNameTok.is(tok::eod)) { // Skip code until we get to #endif. This helps with recovery by not diff --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp index 952fb8f121dc..8c120c13d7d2 100644 --- a/clang/lib/Lex/PPExpressions.cpp +++ b/clang/lib/Lex/PPExpressions.cpp @@ -104,9 +104,6 @@ static bool EvaluateDefined(PPValue &Result, Token &PeekTok, DefinedTracker &DT, SourceLocation beginLoc(PeekTok.getLocation()); Result.setBegin(beginLoc); - // __VA_OPT__ is allowed as the operand of 'defined'. - Preprocessor::IfdefMacroNameScopeRAII IfdefMacroNameScope(PP); - // Get the next token, don't expand it. PP.LexUnexpandedNonComment(PeekTok); @@ -125,8 +122,6 @@ static bool EvaluateDefined(PPValue &Result, Token &PeekTok, DefinedTracker &DT, PP.LexUnexpandedNonComment(PeekTok); } - IfdefMacroNameScope.Exit(); - // If we don't have a pp-identifier now, this is an error. if (PP.CheckMacroName(PeekTok, MU_Other)) return true; diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp index f6ca04defeb9..43d31d6c5732 100644 --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -323,16 +323,13 @@ void Preprocessor::dumpMacroInfo(const IdentifierInfo *II) { /// RegisterBuiltinMacro - Register the specified identifier in the identifier /// table and mark it as a builtin macro to be expanded. -static IdentifierInfo *RegisterBuiltinMacro(Preprocessor &PP, const char *Name, -bool Disabled = false) { +static IdentifierInfo *RegisterBuiltinMacro(Preprocessor &PP, const char *Name){ // Get the identifier. IdentifierInfo *Id = PP.getIdentifierInfo(Name); // Mark it as being a macro that is builtin. MacroInfo *MI = PP.AllocateMacroInfo(SourceLocation()); MI->setIsBuiltinMacro(); - if (Disabled) -MI->DisableMacro(); PP.appendDefMacroDirective(Id, MI); return Id; } @@ -346,7 +343,6 @@ void Preprocessor::RegisterBuiltinMacros() { Ident__TIME__ = RegisterBuiltinMacro(*this, "__TIME__"); Ident__COUNTER__ = RegisterBuiltinMacro(*this, "__COUNTER__"); Ident_Pragma = RegisterBuiltinMacro(*this, "_Pragma"
[llvm-branch-commits] [clang] 9df2b64 - [cxx_status] Mark P0732R2 as only 'partial', not 'Clang 12', as some of
Author: Richard Smith Date: 2021-01-27T16:09:10-08:00 New Revision: 9df2b64fc5fa911ca59b3f646806ca3fd6787c2d URL: https://github.com/llvm/llvm-project/commit/9df2b64fc5fa911ca59b3f646806ca3fd6787c2d DIFF: https://github.com/llvm/llvm-project/commit/9df2b64fc5fa911ca59b3f646806ca3fd6787c2d.diff LOG: [cxx_status] Mark P0732R2 as only 'partial', not 'Clang 12', as some of the changes were reverted. (cherry picked from commit 727fc31a9898dfb89610ca1bc05ff86204a77177) Added: Modified: clang/www/cxx_status.html Removed: diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html index 685f32dbe0d3..fc3340ec9d96 100755 --- a/clang/www/cxx_status.html +++ b/clang/www/cxx_status.html @@ -1005,7 +1005,7 @@ C++20 implementation status Class types as non-type template parameters https://wg21.link/p0732r2";>P0732R2 - Clang 12 + Partial https://wg21.link/p1907r1";>P1907R1 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 8d22f25 - [llvm-c] Move LLVMX86_AMXTypeKind & LLVMPoisonValueValueKind to the bottom to avoid value changes compared with LLVM<=11
Author: Fangrui Song Date: 2021-01-27T16:30:34-08:00 New Revision: 8d22f25d155113f9cfdf3952dc49088c820f2a77 URL: https://github.com/llvm/llvm-project/commit/8d22f25d155113f9cfdf3952dc49088c820f2a77 DIFF: https://github.com/llvm/llvm-project/commit/8d22f25d155113f9cfdf3952dc49088c820f2a77.diff LOG: [llvm-c] Move LLVMX86_AMXTypeKind & LLVMPoisonValueValueKind to the bottom to avoid value changes compared with LLVM<=11 Fixes PR48905 (cherry picked from commit 6612c2bb68becda5504099b48082c844503c6d4c) Added: Modified: llvm/include/llvm-c/Core.h Removed: diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h index 8274213aa839..a78df16ca404 100644 --- a/llvm/include/llvm-c/Core.h +++ b/llvm/include/llvm-c/Core.h @@ -160,10 +160,10 @@ typedef enum { LLVMVectorTypeKind,/**< Fixed width SIMD vector type */ LLVMMetadataTypeKind, /**< Metadata */ LLVMX86_MMXTypeKind, /**< X86 MMX */ - LLVMX86_AMXTypeKind, /**< X86 AMX */ LLVMTokenTypeKind, /**< Tokens */ LLVMScalableVectorTypeKind, /**< Scalable SIMD vector type */ - LLVMBFloatTypeKind /**< 16 bit brain floating point type */ + LLVMBFloatTypeKind,/**< 16 bit brain floating point type */ + LLVMX86_AMXTypeKind/**< X86 AMX */ } LLVMTypeKind; typedef enum { @@ -270,7 +270,6 @@ typedef enum { LLVMConstantVectorValueKind, LLVMUndefValueValueKind, - LLVMPoisonValueValueKind, LLVMConstantAggregateZeroValueKind, LLVMConstantDataArrayValueKind, LLVMConstantDataVectorValueKind, @@ -283,6 +282,7 @@ typedef enum { LLVMInlineAsmValueKind, LLVMInstructionValueKind, + LLVMPoisonValueValueKind } LLVMValueKind; typedef enum { ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] 8364f53 - Revert "Suppress non-conforming GNU paste extension in all standard-conforming modes"
Author: Reid Kleckner Date: 2021-01-27T16:34:01-08:00 New Revision: 8364f5369eeeb2da8db2bae7716c549930d8df93 URL: https://github.com/llvm/llvm-project/commit/8364f5369eeeb2da8db2bae7716c549930d8df93 DIFF: https://github.com/llvm/llvm-project/commit/8364f5369eeeb2da8db2bae7716c549930d8df93.diff LOG: Revert "Suppress non-conforming GNU paste extension in all standard-conforming modes" This reverts commit f4537935dcdbf390c863591cf556e76c3abab9c1. This reverts commit b43c26d036dcbf7a6881f39e4434cf059364022a. This GNU and MSVC extension turns out to be very popular. Most projects are not using C++20, so cannot use the new __VA_OPT__ feature to be standards conformant. The other workaround, using -std=gnu*, enables too many language extensions and isn't viable. Until there is a way for users to get the behavior provided by the `, ## __VA_ARGS__` extension in the -std=c++17 and earlier language modes, we need to revert this. (cherry picked from commit 61a66e4b5ec18e9e73c2f6334f6b7f7dd4bca77e) Added: Modified: clang/lib/Lex/TokenLexer.cpp clang/test/Preprocessor/macro_fn_comma_swallow2.c Removed: diff --git a/clang/lib/Lex/TokenLexer.cpp b/clang/lib/Lex/TokenLexer.cpp index 97cb2cf0bb8c..da5681aaf478 100644 --- a/clang/lib/Lex/TokenLexer.cpp +++ b/clang/lib/Lex/TokenLexer.cpp @@ -148,12 +148,12 @@ bool TokenLexer::MaybeRemoveCommaBeforeVaArgs( return false; // GCC removes the comma in the expansion of " ... , ## __VA_ARGS__ " if - // __VA_ARGS__ is empty, but not in strict mode where there are no - // named arguments, where it remains. With GNU extensions, it is removed - // regardless of named arguments. + // __VA_ARGS__ is empty, but not in strict C99 mode where there are no + // named arguments, where it remains. In all other modes, including C99 + // with GNU extensions, it is removed regardless of named arguments. // Microsoft also appears to support this extension, unofficially. - if (!PP.getLangOpts().GNUMode && !PP.getLangOpts().MSVCCompat && - Macro->getNumParams() < 2) + if (PP.getLangOpts().C99 && !PP.getLangOpts().GNUMode +&& Macro->getNumParams() < 2) return false; // Is a comma available to be removed? diff --git a/clang/test/Preprocessor/macro_fn_comma_swallow2.c b/clang/test/Preprocessor/macro_fn_comma_swallow2.c index 4e4960ca7f18..93ab2b83664a 100644 --- a/clang/test/Preprocessor/macro_fn_comma_swallow2.c +++ b/clang/test/Preprocessor/macro_fn_comma_swallow2.c @@ -1,16 +1,11 @@ // Test the __VA_ARGS__ comma swallowing extensions of various compiler dialects. // RUN: %clang_cc1 -E %s | FileCheck -check-prefix=GCC -strict-whitespace %s -// RUN: %clang_cc1 -E -std=c90 %s | FileCheck -check-prefix=C99 -strict-whitespace %s // RUN: %clang_cc1 -E -std=c99 %s | FileCheck -check-prefix=C99 -strict-whitespace %s // RUN: %clang_cc1 -E -std=c11 %s | FileCheck -check-prefix=C99 -strict-whitespace %s // RUN: %clang_cc1 -E -x c++ %s | FileCheck -check-prefix=GCC -strict-whitespace %s -// RUN: %clang_cc1 -E -x c++ -std=c++03 %s | FileCheck -check-prefix=C99 -strict-whitespace %s -// RUN: %clang_cc1 -E -x c++ -std=c++11 %s | FileCheck -check-prefix=C99 -strict-whitespace %s // RUN: %clang_cc1 -E -std=gnu99 %s | FileCheck -check-prefix=GCC -strict-whitespace %s // RUN: %clang_cc1 -E -fms-compatibility %s | FileCheck -check-prefix=MS -strict-whitespace %s -// RUN: %clang_cc1 -E -x c++ -fms-compatibility %s | FileCheck -check-prefix=MS -strict-whitespace %s -// RUN: %clang_cc1 -E -x c++ -std=c++11 -fms-compatibility %s | FileCheck -check-prefix=MS -strict-whitespace %s // RUN: %clang_cc1 -E -DNAMED %s | FileCheck -check-prefix=GCC -strict-whitespace %s // RUN: %clang_cc1 -E -std=c99 -DNAMED %s | FileCheck -check-prefix=C99 -strict-whitespace %s ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxxabi] b0085d2 - Itanium Mangling: Mangle `__alignof__` differently than `alignof`.
Author: James Y Knight Date: 2021-01-27T20:02:29-05:00 New Revision: b0085d205b3063c332a080599830ef0500cb6924 URL: https://github.com/llvm/llvm-project/commit/b0085d205b3063c332a080599830ef0500cb6924 DIFF: https://github.com/llvm/llvm-project/commit/b0085d205b3063c332a080599830ef0500cb6924.diff LOG: Itanium Mangling: Mangle `__alignof__` differently than `alignof`. The two operations have acted differently since Clang 8, but were unfortunately mangled the same. The new mangling uses new "vendor extended expression" syntax proposed in https://github.com/itanium-cxx-abi/cxx-abi/issues/112 GCC had the same mangling problem, https://gcc.gnu.org/PR88115, and will hopefully be switching to the same mangling as implemented here. Additionally, fix the mangling of `__uuidof` to use the new extension syntax, instead of its previous nonstandard special-case. Adjusts the demangler accordingly. Differential Revision: https://reviews.llvm.org/D93922 (cherry picked from commit 9c7aeaebb3ac1b94200b59b111742cb6b8f090c2) Added: clang/test/CodeGenCXX/mangle-alignof.cpp Modified: clang/lib/AST/ItaniumMangle.cpp clang/test/CodeGenCXX/microsoft-uuidof-mangling.cpp libcxxabi/src/demangle/ItaniumDemangle.h libcxxabi/test/test_demangle.pass.cpp llvm/include/llvm/Demangle/ItaniumDemangle.h Removed: diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp index 6c8d5687c64a..668733a4be34 100644 --- a/clang/lib/AST/ItaniumMangle.cpp +++ b/clang/lib/AST/ItaniumMangle.cpp @@ -558,6 +558,7 @@ class CXXNameMangler { unsigned NumTemplateArgs); void mangleTemplateArgs(TemplateName TN, const TemplateArgumentList &AL); void mangleTemplateArg(TemplateArgument A, bool NeedExactType); + void mangleTemplateArgExpr(const Expr *E); void mangleValueInTemplateArg(QualType T, const APValue &V, bool TopLevel, bool NeedExactType = false); @@ -3528,8 +3529,8 @@ void CXXNameMangler::mangleType(const DependentSizedMatrixType *T) { Out << "u" << VendorQualifier.size() << VendorQualifier; Out << "I"; - mangleTemplateArg(T->getRowExpr(), false); - mangleTemplateArg(T->getColumnExpr(), false); + mangleTemplateArgExpr(T->getRowExpr()); + mangleTemplateArgExpr(T->getColumnExpr()); mangleType(T->getElementType()); Out << "E"; } @@ -3916,6 +3917,7 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity) { // ::= ds # expr.*expr // ::= sZ # size of a parameter pack // ::= sZ # size of a function parameter pack + // ::= u * E # vendor extended expression // ::= // ::= L E# integer literal //::= L E # floating literal @@ -4007,14 +4009,26 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity) { case Expr::CXXUuidofExprClass: { const CXXUuidofExpr *UE = cast(E); -if (UE->isTypeOperand()) { - QualType UuidT = UE->getTypeOperand(Context.getASTContext()); - Out << "u8__uuidoft"; - mangleType(UuidT); +// As of clang 12, uuidof uses the vendor extended expression +// mangling. Previously, it used a special-cased nonstandard extension. +if (Context.getASTContext().getLangOpts().getClangABICompat() > +LangOptions::ClangABI::Ver11) { + Out << "u8__uuidof"; + if (UE->isTypeOperand()) +mangleType(UE->getTypeOperand(Context.getASTContext())); + else +mangleTemplateArgExpr(UE->getExprOperand()); + Out << 'E'; } else { - Expr *UuidExp = UE->getExprOperand(); - Out << "u8__uuidofz"; - mangleExpression(UuidExp, Arity); + if (UE->isTypeOperand()) { +QualType UuidT = UE->getTypeOperand(Context.getASTContext()); +Out << "u8__uuidoft"; +mangleType(UuidT); + } else { +Expr *UuidExp = UE->getExprOperand(); +Out << "u8__uuidofz"; +mangleExpression(UuidExp, Arity); + } } break; } @@ -4312,13 +4326,39 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity) { break; } +auto MangleAlignofSizeofArg = [&] { + if (SAE->isArgumentType()) { +Out << 't'; +mangleType(SAE->getArgumentType()); + } else { +Out << 'z'; +mangleExpression(SAE->getArgumentExpr()); + } +}; + switch(SAE->getKind()) { case UETT_SizeOf: Out << 's'; + MangleAlignofSizeofArg(); break; case UETT_PreferredAlignOf: + // As of clang 12, we mangle __alignof__ diff erently than alignof. (They + // have acted diff erently since Clang 8, but were previously mangled the + // same.) + if (Context.getASTContext().getLangOpts().getClangABICompat() > + LangOptions::ClangABI::
[llvm-branch-commits] [clang] 7da92af - Itanium Mangling: Fix handling of in .
Author: James Y Knight Date: 2021-01-27T20:02:30-05:00 New Revision: 7da92afbf08e90960f7e5dee00bbf6ef8f323a5c URL: https://github.com/llvm/llvm-project/commit/7da92afbf08e90960f7e5dee00bbf6ef8f323a5c DIFF: https://github.com/llvm/llvm-project/commit/7da92afbf08e90960f7e5dee00bbf6ef8f323a5c.diff LOG: Itanium Mangling: Fix handling of in . Previously, we were emitting an extraneous X .. E in around an if the template argument was constructed from an expression (rather than an already-evaluated literal value). In such a case, we would then e.g. emit 'XLi0EE' instead of 'Li0E'. We had one special-case for DeclRefExpr expressions, in particular, to omit them the mangled-name without the surrounding X/E. However, unfortunately, that special case also triggered for ParmVarDecl (a subtype of VarDecl), and _incorrectly_ emitted 'L_Z .. E' instead of the proper 'Xfp_E'. This change causes mangleExpression itself to be responsible for emitting X/E around non-primary expressions, which removes the special-case, and corrects both these problems. Differential Revision: https://reviews.llvm.org/D95487 (cherry picked from commit 8ca33605ff0cfc536f5c6710fb5f6378bf11959a) Added: Modified: clang/lib/AST/ItaniumMangle.cpp clang/test/CodeGenCXX/clang-abi-compat.cpp clang/test/CodeGenCXX/mangle-abi-tag.cpp clang/test/CodeGenCXX/mangle-concept.cpp clang/test/CodeGenCXX/mangle-template.cpp clang/test/CodeGenCXX/mangle.cpp clang/test/CodeGenCXX/matrix-type.cpp clang/test/CodeGenCXX/microsoft-uuidof-mangling.cpp Removed: diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp index 668733a4be34..54e2f361a9f1 100644 --- a/clang/lib/AST/ItaniumMangle.cpp +++ b/clang/lib/AST/ItaniumMangle.cpp @@ -546,8 +546,8 @@ class CXXNameMangler { unsigned knownArity); void mangleCastExpression(const Expr *E, StringRef CastEncoding); void mangleInitListElements(const InitListExpr *InitList); - void mangleDeclRefExpr(const NamedDecl *D); - void mangleExpression(const Expr *E, unsigned Arity = UnknownArity); + void mangleExpression(const Expr *E, unsigned Arity = UnknownArity, +bool AsTemplateArg = false); void mangleCXXCtorType(CXXCtorType T, const CXXRecordDecl *InheritedFrom); void mangleCXXDtorType(CXXDtorType T); @@ -3872,33 +3872,8 @@ void CXXNameMangler::mangleInitListElements(const InitListExpr *InitList) { mangleExpression(InitList->getInit(i)); } -void CXXNameMangler::mangleDeclRefExpr(const NamedDecl *D) { - switch (D->getKind()) { - default: -// ::= L E # external name -Out << 'L'; -mangle(D); -Out << 'E'; -break; - - case Decl::ParmVar: -mangleFunctionParam(cast(D)); -break; - - case Decl::EnumConstant: { -const EnumConstantDecl *ED = cast(D); -mangleIntegerLiteral(ED->getType(), ED->getInitVal()); -break; - } - - case Decl::NonTypeTemplateParm: -const NonTypeTemplateParmDecl *PD = cast(D); -mangleTemplateParameter(PD->getDepth(), PD->getIndex()); -break; - } -} - -void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity) { +void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity, + bool AsTemplateArg) { // ::= // ::= // ::= @@ -3912,6 +3887,7 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity) { // ::= at # alignof (a type) // ::= // ::= + // ::= fpT# 'this' expression (part of ) // ::= sr # dependent name // ::= sr # dependent template-id // ::= ds # expr.*expr @@ -3920,11 +3896,55 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity) { // ::= u * E # vendor extended expression // ::= // ::= L E# integer literal - //::= L E # floating literal + //::= L E # floating literal + //::= L E # string literal + //::= L E # nullptr literal "LDnE" + //::= L 0 E # null pointer template argument + //::= L _ E# complex floating point literal (C99); not used by clang //::= L E # external name - //::= fpT # 'this' expression QualType ImplicitlyConvertedToType; + // A top-level expression that's not needs to be wrapped in + // X...E in a template arg. + bool IsPrimaryExpr = true; + auto NotPrimaryExpr = [&] { +if (AsTemplateArg && IsPrimaryExpr) + Out << 'X'; +IsPrimaryExpr = false; + }; + + auto MangleDeclRefExpr
[llvm-branch-commits] [clang] 0b7b698 - Itanium Mangling: In 'enable_if', omit X/E around .
Author: James Y Knight Date: 2021-01-27T20:02:30-05:00 New Revision: 0b7b698fecd37415a635a586e5ca159ab0b8872f URL: https://github.com/llvm/llvm-project/commit/0b7b698fecd37415a635a586e5ca159ab0b8872f DIFF: https://github.com/llvm/llvm-project/commit/0b7b698fecd37415a635a586e5ca159ab0b8872f.diff LOG: Itanium Mangling: In 'enable_if', omit X/E around . The Clang enable_if extension is mangled as an , which is supposed to contain . However, we were unconditionally emitting X/E around its arguments, neglecting the fact that should be emitted directly without the surrounding X/E. Differential Revision: https://reviews.llvm.org/D95488 (cherry picked from commit a7246ba02a8923f316419a62d836dbe1c0b437bd) Added: Modified: clang/lib/AST/ItaniumMangle.cpp clang/test/CodeGen/enable_if.c clang/test/CodeGenCXX/clang-abi-compat.cpp clang/test/CodeGenCXX/enable_if.cpp Removed: diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp index 54e2f361a9f1..4420f6a2c1c3 100644 --- a/clang/lib/AST/ItaniumMangle.cpp +++ b/clang/lib/AST/ItaniumMangle.cpp @@ -727,9 +727,17 @@ void CXXNameMangler::mangleFunctionEncodingBareType(const FunctionDecl *FD) { EnableIfAttr *EIA = dyn_cast(*I); if (!EIA) continue; - Out << 'X'; - mangleExpression(EIA->getCond()); - Out << 'E'; + if (Context.getASTContext().getLangOpts().getClangABICompat() > + LangOptions::ClangABI::Ver11) { +mangleTemplateArgExpr(EIA->getCond()); + } else { +// Prior to Clang 12, we hardcoded the X/E around enable-if's argument, +// even though should not include an X/E around +// . +Out << 'X'; +mangleExpression(EIA->getCond()); +Out << 'E'; + } } Out << 'E'; FunctionTypeDepth.pop(Saved); diff --git a/clang/test/CodeGen/enable_if.c b/clang/test/CodeGen/enable_if.c index 14550b9e2db9..327a201cdeba 100644 --- a/clang/test/CodeGen/enable_if.c +++ b/clang/test/CodeGen/enable_if.c @@ -31,22 +31,22 @@ void bar(int m) __attribute__((overloadable, enable_if(m > 0, ""))); void bar(int m) __attribute__((overloadable, enable_if(1, ""))); // CHECK-LABEL: define{{.*}} void @test2 void test2() { - // CHECK: store void (i32)* @_Z3barUa9enable_ifIXLi1EEEi + // CHECK: store void (i32)* @_Z3barUa9enable_ifILi1EEi void (*p)(int) = bar; - // CHECK: store void (i32)* @_Z3barUa9enable_ifIXLi1EEEi + // CHECK: store void (i32)* @_Z3barUa9enable_ifILi1EEi void (*p2)(int) = &bar; - // CHECK: store void (i32)* @_Z3barUa9enable_ifIXLi1EEEi + // CHECK: store void (i32)* @_Z3barUa9enable_ifILi1EEi p = bar; - // CHECK: store void (i32)* @_Z3barUa9enable_ifIXLi1EEEi + // CHECK: store void (i32)* @_Z3barUa9enable_ifILi1EEi p = &bar; - // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifIXLi1EEEi to i8*) + // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifILi1EEi to i8*) void *vp1 = (void*)&bar; - // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifIXLi1EEEi to i8*) + // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifILi1EEi to i8*) void *vp2 = (void*)bar; - // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifIXLi1EEEi to i8*) + // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifILi1EEi to i8*) vp1 = (void*)&bar; - // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifIXLi1EEEi to i8*) + // CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifILi1EEi to i8*) vp1 = (void*)bar; } @@ -54,13 +54,13 @@ void baz(int m) __attribute__((overloadable, enable_if(1, ""))); void baz(int m) __attribute__((overloadable)); // CHECK-LABEL: define{{.*}} void @test3 void test3() { - // CHECK: store void (i32)* @_Z3bazUa9enable_ifIXLi1EEEi + // CHECK: store void (i32)* @_Z3bazUa9enable_ifILi1EEi void (*p)(int) = baz; - // CHECK: store void (i32)* @_Z3bazUa9enable_ifIXLi1EEEi + // CHECK: store void (i32)* @_Z3bazUa9enable_ifILi1EEi void (*p2)(int) = &baz; - // CHECK: store void (i32)* @_Z3bazUa9enable_ifIXLi1EEEi + // CHECK: store void (i32)* @_Z3bazUa9enable_ifILi1EEi p = baz; - // CHECK: store void (i32)* @_Z3bazUa9enable_ifIXLi1EEEi + // CHECK: store void (i32)* @_Z3bazUa9enable_ifILi1EEi p = &baz; } @@ -71,13 +71,13 @@ void qux(int m) __attribute__((overloadable, enable_if(1, ""), void qux(int m) __attribute__((overloadable, enable_if(1, ""))); // CHECK-LABEL: define{{.*}} void @test4 void test4() { - // CHECK: store void (i32)* @_Z3quxUa9enable_ifIXLi1EEXLi1EEEi + // CHECK: store void (i32)* @_Z3quxUa9enable_ifILi1ELi1EEi void (*p)(int) = qux; - // CHECK: store void (i32)* @_Z3quxUa9enable_ifIXLi1EEXLi1EEEi + // CHECK: store void (i32)* @_Z3quxUa9enable_ifILi1ELi1EEi void (*p2)(int) = &qux; - // CHECK: store void (i32)* @_Z3quxUa9enable_ifIXLi1EEXLi1EEEi + // CHECK: store void (i32)* @_Z3q