[clang] d4ff961 - Add missing #include for ObjCMethodDecl.
Author: Jorge Gorbe Moya Date: 2024-05-30T15:42:57-07:00 New Revision: d4ff9615a1531f4a466b7d1fb0f175e3ae489289 URL: https://github.com/llvm/llvm-project/commit/d4ff9615a1531f4a466b7d1fb0f175e3ae489289 DIFF: https://github.com/llvm/llvm-project/commit/d4ff9615a1531f4a466b7d1fb0f175e3ae489289.diff LOG: Add missing #include for ObjCMethodDecl. DeclBase.h only contains a forward declaration of ObjCMethodDecl, and when building clang/Sema/Attr.h with header modules this causes a build failure because `llvm::isa` requires the full type. Added: Modified: clang/include/clang/Sema/Attr.h Removed: diff --git a/clang/include/clang/Sema/Attr.h b/clang/include/clang/Sema/Attr.h index 781170feb34ed..1133862568a6c 100644 --- a/clang/include/clang/Sema/Attr.h +++ b/clang/include/clang/Sema/Attr.h @@ -14,7 +14,7 @@ #define LLVM_CLANG_SEMA_ATTR_H #include "clang/AST/Decl.h" -#include "clang/AST/DeclBase.h" +#include "clang/AST/DeclObjC.h" #include "llvm/Support/Casting.h" namespace clang { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] placement new initializes typedef array with correct size (PR #83124)
slackito wrote: The following program fails to build after this change: ``` #include #include template struct X { void f() { values_.reset(new int64_t[123][65]); } std::unique_ptr values_; }; int main() { X x; x.f(); } ``` you get similar errors with both libstdc++: ``` jgorbe@gorbe:~/llvm-build/bin$ ./clang++ -o /dev/null ~/repro.cc /usr/local/google/home/jgorbe/repro.cc:7:13: error: no matching member function for call to 'reset' 7 | values_.reset(new int64_t[123][65]); | ^ /usr/local/google/home/jgorbe/repro.cc:15:5: note: in instantiation of member function 'X::f' requested here 15 | x.f(); | ^ /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/unique_ptr.h:779:7: note: candidate template ignored: requirement '__and_, std::__and_, std::is_pointer, std::is_convertible>>>::value' was not satisfied [with _Up = int64_t *] 779 | reset(_Up __p) noexcept | ^ 1 error generated. ``` and libc++ ``` jgorbe@gorbe:~/llvm-build/bin$ ./clang++ -o /dev/null ~/repro.cc -stdlib=libc++ /usr/local/google/home/jgorbe/repro.cc:7:13: error: no matching member function for call to 'reset' 7 | values_.reset(new int64_t[123][65]); | ^ /usr/local/google/home/jgorbe/repro.cc:15:5: note: in instantiation of member function 'X::f' requested here 15 | x.f(); | ^ /usr/local/google/home/jgorbe/llvm-build/bin/../include/c++/v1/__memory/unique_ptr.h:457:60: note: candidate template ignored: requirement '_CheckArrayPointerConversion::value' was not satisfied [with _Pp = int64_t *] 457 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(_Pp __p) _NOEXCEPT { |^ 1 error generated. ``` https://github.com/llvm/llvm-project/pull/83124 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 2b2881b - Add namespace qualifier for llvm::StringRef
Author: Jorge Gorbe Moya Date: 2024-02-21T14:16:27-08:00 New Revision: 2b2881b0ae94e56aa019b519419d122bb7b81462 URL: https://github.com/llvm/llvm-project/commit/2b2881b0ae94e56aa019b519419d122bb7b81462 DIFF: https://github.com/llvm/llvm-project/commit/2b2881b0ae94e56aa019b519419d122bb7b81462.diff LOG: Add namespace qualifier for llvm::StringRef Added: Modified: clang/include/clang/InstallAPI/Context.h Removed: diff --git a/clang/include/clang/InstallAPI/Context.h b/clang/include/clang/InstallAPI/Context.h index b06168918a6138..7d105920734fde 100644 --- a/clang/include/clang/InstallAPI/Context.h +++ b/clang/include/clang/InstallAPI/Context.h @@ -28,7 +28,7 @@ struct InstallAPIContext { llvm::Triple TargetTriple{}; /// File Path of output location. - StringRef OutputLoc{}; + llvm::StringRef OutputLoc{}; /// What encoding to write output as. llvm::MachO::FileType FT = llvm::MachO::FileType::TBD_V5; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] fcbb4e1 - [NFCI] Fix unused variable warning with asserts off in clang/lib/Sema/TypeLocBuilder.cpp
Author: Jorge Gorbe Moya Date: 2022-07-12T17:40:41-07:00 New Revision: fcbb4e1fa42793edc9531d59d047e6bd0909d3d3 URL: https://github.com/llvm/llvm-project/commit/fcbb4e1fa42793edc9531d59d047e6bd0909d3d3 DIFF: https://github.com/llvm/llvm-project/commit/fcbb4e1fa42793edc9531d59d047e6bd0909d3d3.diff LOG: [NFCI] Fix unused variable warning with asserts off in clang/lib/Sema/TypeLocBuilder.cpp Added: Modified: clang/lib/Sema/TypeLocBuilder.cpp Removed: diff --git a/clang/lib/Sema/TypeLocBuilder.cpp b/clang/lib/Sema/TypeLocBuilder.cpp index d2360224ac60..3699b5dffe8a 100644 --- a/clang/lib/Sema/TypeLocBuilder.cpp +++ b/clang/lib/Sema/TypeLocBuilder.cpp @@ -156,8 +156,7 @@ TypeLoc TypeLocBuilder::pushImpl(QualType T, size_t LocalSize, unsigned LocalAli Index -= LocalSize; - unsigned FDSz = TypeLoc::getFullDataSizeForType(T); - assert(Capacity - Index == FDSz && + assert(Capacity - Index == TypeLoc::getFullDataSizeForType(T) && "incorrect data size provided to CreateTypeSourceInfo!"); return getTemporaryTypeLoc(T); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ee88c0c - [NFCI] Fix unused variable/function warnings in MacroCallReconstructorTest.cpp when asserts are disabled.
Author: Jorge Gorbe Moya Date: 2022-07-12T16:46:58-07:00 New Revision: ee88c0cf09969ba44307068797e12533b94768a6 URL: https://github.com/llvm/llvm-project/commit/ee88c0cf09969ba44307068797e12533b94768a6 DIFF: https://github.com/llvm/llvm-project/commit/ee88c0cf09969ba44307068797e12533b94768a6.diff LOG: [NFCI] Fix unused variable/function warnings in MacroCallReconstructorTest.cpp when asserts are disabled. Added: Modified: clang/unittests/Format/MacroCallReconstructorTest.cpp Removed: diff --git a/clang/unittests/Format/MacroCallReconstructorTest.cpp b/clang/unittests/Format/MacroCallReconstructorTest.cpp index 2bda62aa42be..3abe0383aeae 100644 --- a/clang/unittests/Format/MacroCallReconstructorTest.cpp +++ b/clang/unittests/Format/MacroCallReconstructorTest.cpp @@ -91,14 +91,6 @@ struct Chunk { llvm::SmallVector Children; }; -bool tokenMatches(const FormatToken *Left, const FormatToken *Right) { - if (Left->getType() == Right->getType() && - Left->TokenText == Right->TokenText) -return true; - llvm::dbgs() << Left->TokenText << " != " << Right->TokenText << "\n"; - return false; -} - // Allows to produce chunks of a token list by typing the code of equal tokens. // // Created from a list of tokens, users call "consume" to get the next chunk @@ -110,7 +102,9 @@ struct Matcher { Chunk consume(StringRef Tokens) { TokenList Result; for (const FormatToken *Token : uneof(Lex.lex(Tokens))) { - assert(tokenMatches(*It, Token)); + (void)Token; // Fix unused variable warning when asserts are disabled. + assert((*It)->getType() == Token->getType() && + (*It)->TokenText == Token->TokenText); Result.push_back(*It); ++It; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 7dcd698 - Use writable temporary file for test compiler output instead of hardcoded name. NFCI.
Author: Jorge Gorbe Moya Date: 2022-04-08T10:57:27-07:00 New Revision: 7dcd698875cc6c73a9b10acad1b55aeb08bc9fca URL: https://github.com/llvm/llvm-project/commit/7dcd698875cc6c73a9b10acad1b55aeb08bc9fca DIFF: https://github.com/llvm/llvm-project/commit/7dcd698875cc6c73a9b10acad1b55aeb08bc9fca.diff LOG: Use writable temporary file for test compiler output instead of hardcoded name. NFCI. Added: Modified: clang/test/Modules/cxx20-10-2-ex3.cpp clang/test/Modules/cxx20-10-2-ex4.cpp clang/test/Modules/cxx20-10-2-ex6.cpp clang/test/Modules/cxx20-10-2-ex7.cpp Removed: diff --git a/clang/test/Modules/cxx20-10-2-ex3.cpp b/clang/test/Modules/cxx20-10-2-ex3.cpp index b41269f06fb3c..f9b515e869bf5 100644 --- a/clang/test/Modules/cxx20-10-2-ex3.cpp +++ b/clang/test/Modules/cxx20-10-2-ex3.cpp @@ -1,6 +1,6 @@ // Based on C++20 10.2 example 3. -// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o M.pcm +// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o %t export module M; struct S; diff --git a/clang/test/Modules/cxx20-10-2-ex4.cpp b/clang/test/Modules/cxx20-10-2-ex4.cpp index 48d351f472307..793e9964aa9dc 100644 --- a/clang/test/Modules/cxx20-10-2-ex4.cpp +++ b/clang/test/Modules/cxx20-10-2-ex4.cpp @@ -1,6 +1,6 @@ // Based on C++20 10.2 example 4. -// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -verify -o M.pcm +// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -verify -o %t export module M; diff --git a/clang/test/Modules/cxx20-10-2-ex6.cpp b/clang/test/Modules/cxx20-10-2-ex6.cpp index 7f66e90b178ea..cb3bc88e7e728 100644 --- a/clang/test/Modules/cxx20-10-2-ex6.cpp +++ b/clang/test/Modules/cxx20-10-2-ex6.cpp @@ -1,6 +1,6 @@ // Based on C++20 10.2 example 6. -// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -verify -o M.pcm +// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -verify -o %t export module M; diff --git a/clang/test/Modules/cxx20-10-2-ex7.cpp b/clang/test/Modules/cxx20-10-2-ex7.cpp index 86d139ff5b556..07029df876d29 100644 --- a/clang/test/Modules/cxx20-10-2-ex7.cpp +++ b/clang/test/Modules/cxx20-10-2-ex7.cpp @@ -1,6 +1,6 @@ // Based on C++20 10.2 example 6. -// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -verify -o M.pcm +// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -verify -o %t export module M; export namespace N { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 5b81158 - Revert "[clang-format] Handle attributes before case label."
Author: Jorge Gorbe Moya Date: 2022-03-21T14:39:14-07:00 New Revision: 5b811586758808ce3335272d5b41852cf87666c7 URL: https://github.com/llvm/llvm-project/commit/5b811586758808ce3335272d5b41852cf87666c7 DIFF: https://github.com/llvm/llvm-project/commit/5b811586758808ce3335272d5b41852cf87666c7.diff LOG: Revert "[clang-format] Handle attributes before case label." This reverts commit 596fa2d90044841c33b9a0e6b17406c2a45077a2. Added: Modified: clang/lib/Format/UnwrappedLineParser.cpp clang/lib/Format/UnwrappedLineParser.h clang/unittests/Format/FormatTest.cpp Removed: diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index bef8ed54fab8a..36205b8ee18cd 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -480,10 +480,6 @@ bool UnwrappedLineParser::parseLevel(bool HasOpeningBrace, unsigned StatementCount = 0; bool SwitchLabelEncountered = false; do { -if (FormatTok->getType() == TT_AttributeMacro) { - nextToken(); - continue; -} tok::TokenKind kind = FormatTok->Tok.getKind(); if (FormatTok->getType() == TT_MacroBlockBegin) kind = tok::l_brace; @@ -573,8 +569,6 @@ bool UnwrappedLineParser::parseLevel(bool HasOpeningBrace, parseCSharpAttribute(); break; } - if (handleCppAttributes()) -break; LLVM_FALLTHROUGH; default: ParseDefault(); @@ -1403,11 +1397,9 @@ void UnwrappedLineParser::parseStructuralElement(IfStmtKind *IfKind, // e.g. "default void f() {}" in a Java interface. break; case tok::kw_case: -if (Style.isJavaScript() && Line->MustBeDeclaration) { +if (Style.isJavaScript() && Line->MustBeDeclaration) // 'case: string' field declaration. - nextToken(); break; -} parseCaseLabel(); return; case tok::kw_try: @@ -1828,12 +1820,6 @@ void UnwrappedLineParser::parseStructuralElement(IfStmtKind *IfKind, case tok::kw_new: parseNew(); break; -case tok::kw_case: - if (Style.isJavaScript() && Line->MustBeDeclaration) -// 'case: string' field declaration. -break; - parseCaseLabel(); - break; default: nextToken(); break; @@ -2402,24 +2388,17 @@ static void markOptionalBraces(FormatToken *LeftBrace) { RightBrace->Optional = true; } -void UnwrappedLineParser::handleAttributes() { - // Handle AttributeMacro, e.g. `if (x) UNLIKELY`. - if (FormatTok->is(TT_AttributeMacro)) -nextToken(); - handleCppAttributes(); -} - -bool UnwrappedLineParser::handleCppAttributes() { - // Handle [[likely]] / [[unlikely]] attributes. - if (FormatTok->is(tok::l_square) && tryToParseSimpleAttribute()) { -parseSquare(); -return true; - } - return false; -} - FormatToken *UnwrappedLineParser::parseIfThenElse(IfStmtKind *IfKind, bool KeepBraces) { + auto HandleAttributes = [this]() { +// Handle AttributeMacro, e.g. `if (x) UNLIKELY`. +if (FormatTok->is(TT_AttributeMacro)) + nextToken(); +// Handle [[likely]] / [[unlikely]] attributes. +if (FormatTok->is(tok::l_square) && tryToParseSimpleAttribute()) + parseSquare(); + }; + assert(FormatTok->is(tok::kw_if) && "'if' expected"); nextToken(); if (FormatTok->is(tok::exclaim)) @@ -2432,7 +2411,7 @@ FormatToken *UnwrappedLineParser::parseIfThenElse(IfStmtKind *IfKind, if (FormatTok->is(tok::l_paren)) parseParens(); } - handleAttributes(); + HandleAttributes(); bool NeedsUnwrappedLine = false; keepAncestorBraces(); @@ -2469,7 +2448,7 @@ FormatToken *UnwrappedLineParser::parseIfThenElse(IfStmtKind *IfKind, Kind = IfStmtKind::IfElse; } nextToken(); -handleAttributes(); +HandleAttributes(); if (FormatTok->is(tok::l_brace)) { ElseLeftBrace = FormatTok; CompoundStatementIndenter Indenter(this, Style, Line->Level); diff --git a/clang/lib/Format/UnwrappedLineParser.h b/clang/lib/Format/UnwrappedLineParser.h index 798bae24ad075..5cc01398a5457 100644 --- a/clang/lib/Format/UnwrappedLineParser.h +++ b/clang/lib/Format/UnwrappedLineParser.h @@ -121,8 +121,6 @@ class UnwrappedLineParser { void parseSquare(bool LambdaIntroducer = false); void keepAncestorBraces(); void parseUnbracedBody(bool CheckEOF = false); - void handleAttributes(); - bool handleCppAttributes(); FormatToken *parseIfThenElse(IfStmtKind *IfKind, bool KeepBraces = false); void parseTryCatch(); void parseForOrWhileLoop(); diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index e36a267c01f4b..539e9c22767ea 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -2609,52 +2609,6 @@ TEST_F(FormatTest, FormatsSwitchStatement) {
[clang-tools-extra] de9611b - [NFC] Don't pass temporary LangOptions to Lexer
Author: Jorge Gorbe Moya Date: 2022-02-28T12:53:59-08:00 New Revision: de9611befeebeb85324062cb1ae8978a82a09e26 URL: https://github.com/llvm/llvm-project/commit/de9611befeebeb85324062cb1ae8978a82a09e26 DIFF: https://github.com/llvm/llvm-project/commit/de9611befeebeb85324062cb1ae8978a82a09e26.diff LOG: [NFC] Don't pass temporary LangOptions to Lexer Since https://reviews.llvm.org/D120334, passing a temporary LangOptions object to Lexer results in stack-use-after-scope. Added: Modified: clang-tools-extra/clangd/Format.cpp Removed: diff --git a/clang-tools-extra/clangd/Format.cpp b/clang-tools-extra/clangd/Format.cpp index adf9cfd39cb68..bb492dbdbd3bd 100644 --- a/clang-tools-extra/clangd/Format.cpp +++ b/clang-tools-extra/clangd/Format.cpp @@ -25,8 +25,8 @@ void closeBrackets(std::string , const format::FormatStyle ) { SourceManagerForFile FileSM("mock_file.cpp", Code); auto = FileSM.get(); FileID FID = SM.getMainFileID(); - Lexer Lex(FID, SM.getBufferOrFake(FID), SM, -format::getFormattingLangOpts(Style)); + LangOptions LangOpts = format::getFormattingLangOpts(Style); + Lexer Lex(FID, SM.getBufferOrFake(FID), SM, LangOpts); Token Tok; std::vector Brackets; while (!Lex.LexFromRawLexer(Tok)) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 770ddf5 - Fix unused variable warning in release build
Author: Jorge Gorbe Moya Date: 2021-11-09T19:48:42-08:00 New Revision: 770ddf599d28e8b0aef38166bed899b0194f4d8b URL: https://github.com/llvm/llvm-project/commit/770ddf599d28e8b0aef38166bed899b0194f4d8b DIFF: https://github.com/llvm/llvm-project/commit/770ddf599d28e8b0aef38166bed899b0194f4d8b.diff LOG: Fix unused variable warning in release build Added: Modified: clang/lib/CodeGen/CodeGenFunction.h Removed: diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index e8207511813c..6d8d1f470f1d 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -397,8 +397,7 @@ class CodeGenFunction : public CodeGenTypeCache { if (!PostAllocaInsertPt) { assert(AllocaInsertPt && "Expected static alloca insertion point at function prologue"); - auto *EBB = AllocaInsertPt->getParent(); - assert(EBB->isEntryBlock() && + assert(AllocaInsertPt->getParent()->isEntryBlock() && "EBB should be entry block of the current code gen function"); PostAllocaInsertPt = AllocaInsertPt->clone(); PostAllocaInsertPt->setName("postallocapt"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 74add1b - Revert "[clang-tidy] Fix lint warning in ClangTidyDiagnosticConsumer.cpp (NFC)"
Author: Jorge Gorbe Moya Date: 2021-11-09T11:28:48-08:00 New Revision: 74add1b6d6d377ab2cdce26699cf798110817e42 URL: https://github.com/llvm/llvm-project/commit/74add1b6d6d377ab2cdce26699cf798110817e42 DIFF: https://github.com/llvm/llvm-project/commit/74add1b6d6d377ab2cdce26699cf798110817e42.diff LOG: Revert "[clang-tidy] Fix lint warning in ClangTidyDiagnosticConsumer.cpp (NFC)" The change causes multiple clang-tidy tests to fail under ASan. This reverts commit 00769572025f9b0d36dc832d3c1bc61500091ed5. Added: Modified: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp index 9771d90de63df..456de0e979dbd 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp @@ -374,11 +374,13 @@ static ClangTidyError createNolintError(const ClangTidyContext , bool IsNolintBegin) { ClangTidyError Error("clang-tidy-nolint", ClangTidyError::Error, Context.getCurrentBuildDirectory(), false); - auto Message = Twine("unmatched 'NOLINT") + - (IsNolintBegin ? "BEGIN" : "END") + "' comment without a " + - (IsNolintBegin ? "subsequent" : "previous") + " 'NOLINT" + - (IsNolintBegin ? "END" : "BEGIN") + "' comment"; - Error.Message = tooling::DiagnosticMessage(Message.str(), SM, Loc); + StringRef Message = + IsNolintBegin + ? "unmatched 'NOLINTBEGIN' comment without a subsequent 'NOLINTEND' " +"comment" + : "unmatched 'NOLINTEND' comment without a previous 'NOLINTBEGIN' " +"comment"; + Error.Message = tooling::DiagnosticMessage(Message, SM, Loc); return Error; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] 82576d6 - [libunwind] Fix UB in EHHeaderParser::findFDE
Author: Jorge Gorbe Moya Date: 2020-04-07T14:44:42-07:00 New Revision: 82576d6fecfec71725eb900111c000d772002449 URL: https://github.com/llvm/llvm-project/commit/82576d6fecfec71725eb900111c000d772002449 DIFF: https://github.com/llvm/llvm-project/commit/82576d6fecfec71725eb900111c000d772002449.diff LOG: [libunwind] Fix UB in EHHeaderParser::findFDE When the EHHeaderInfo object filled by decodeEHHdr has fde_count == 0, findFDE does the following: - sets low = 0 and len = hdrInfo.fde_count as a preparation to start a binary search - because len is 0, the binary search loop is skipped - the code still tries to find a table entry at hdrInfo.table + low * tableEntrySize, and decode it. This is wrong when fde_count is 0, and trying to decode a table entry that isn't there will lead to reading garbage offsets and can cause segfaults. Differential Revision: https://reviews.llvm.org/D77679 Added: Modified: libunwind/src/EHHeaderParser.hpp Removed: diff --git a/libunwind/src/EHHeaderParser.hpp b/libunwind/src/EHHeaderParser.hpp index 0101835b8e63..f97cca54825f 100644 --- a/libunwind/src/EHHeaderParser.hpp +++ b/libunwind/src/EHHeaderParser.hpp @@ -109,6 +109,8 @@ bool EHHeaderParser::findFDE(A , pint_t pc, pint_t ehHdrStart, hdrInfo)) return false; + if (hdrInfo.fde_count == 0) return false; + size_t tableEntrySize = getTableEntrySize(hdrInfo.table_enc); pint_t tableEntry; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] 1ae8d81 - [libunwind] Fix memory leak in handling of DW_CFA_remember_state and DW_CFA_restore_state
Author: Jorge Gorbe Moya Date: 2020-02-18T11:57:18-08:00 New Revision: 1ae8d81147a0724cc972054afbd72943032e4832 URL: https://github.com/llvm/llvm-project/commit/1ae8d81147a0724cc972054afbd72943032e4832 DIFF: https://github.com/llvm/llvm-project/commit/1ae8d81147a0724cc972054afbd72943032e4832.diff LOG: [libunwind] Fix memory leak in handling of DW_CFA_remember_state and DW_CFA_restore_state parseInstructions() doesn't always process the whole set of DWARF instructions for a frame. It will stop once the target PC is reached, or if malformed instructions are found. So, for example, if we have an instruction sequence like this: ``` ... DW_CFA_remember_state ... DW_CFA_advance_loc past the location we're unwinding at (pcoffset in parseInstructions() main loop) ... DW_CFA_restore_state ``` ... the saved state will never be freed, even though the DW_CFA_remember_state opcode has a matching DW_CFA_restore_state later in the sequence. This change adds code to free whatever is left on rememberStack after parsing the CIE and the FDE instructions. Differential Revision: https://reviews.llvm.org/D66904 Added: libunwind/test/remember_state_leak.pass.sh.s Modified: libunwind/src/DwarfParser.hpp Removed: diff --git a/libunwind/src/DwarfParser.hpp b/libunwind/src/DwarfParser.hpp index df69c2a4bd23..2994bd7bb41f 100644 --- a/libunwind/src/DwarfParser.hpp +++ b/libunwind/src/DwarfParser.hpp @@ -360,13 +360,25 @@ bool CFI_Parser::parseFDEInstructions(A , PrologInfoStackEntry *rememberStack = NULL; // parse CIE then FDE instructions - return parseInstructions(addressSpace, cieInfo.cieInstructions, - cieInfo.cieStart + cieInfo.cieLength, cieInfo, - (pint_t)(-1), rememberStack, arch, results) && - parseInstructions(addressSpace, fdeInfo.fdeInstructions, - fdeInfo.fdeStart + fdeInfo.fdeLength, cieInfo, - upToPC - fdeInfo.pcStart, rememberStack, arch, - results); + bool returnValue = + parseInstructions(addressSpace, cieInfo.cieInstructions, +cieInfo.cieStart + cieInfo.cieLength, cieInfo, +(pint_t)(-1), rememberStack, arch, results) && + parseInstructions(addressSpace, fdeInfo.fdeInstructions, +fdeInfo.fdeStart + fdeInfo.fdeLength, cieInfo, +upToPC - fdeInfo.pcStart, rememberStack, arch, results); + + // Clean up rememberStack. Even in the case where every DW_CFA_remember_state + // is paired with a DW_CFA_restore_state, parseInstructions can skip restore + // opcodes if it reaches the target PC and stops interpreting, so we have to + // make sure we don't leak memory. + while (rememberStack) { +PrologInfoStackEntry *next = rememberStack->next; +free(rememberStack); +rememberStack = next; + } + + return returnValue; } /// "run" the DWARF instructions diff --git a/libunwind/test/remember_state_leak.pass.sh.s b/libunwind/test/remember_state_leak.pass.sh.s new file mode 100644 index ..821ee926eec8 --- /dev/null +++ b/libunwind/test/remember_state_leak.pass.sh.s @@ -0,0 +1,56 @@ +# REQUIRES: x86, linux +# RUN: %build -target x86_64-unknown-linux-gnu +# RUN: %run + +# The following assembly is a translation of this code: +# +# _Unwind_Reason_Code callback(int, _Unwind_Action, long unsigned int, +#_Unwind_Exception*, _Unwind_Context*, void*) { +# return _Unwind_Reason_Code(0); +# } +# +# int main() { +# asm(".cfi_remember_state\n\t"); +# _Unwind_Exception exc; +# _Unwind_ForcedUnwind(, callback, 0); +# asm(".cfi_restore_state\n\t"); +# } +# +# When unwinding, the CFI parser will stop parsing opcodes after the current PC, +# so in this case the DW_CFA_restore_state opcode will never be processed and, +# if the library doesn't clean up properly, the store allocated by +# DW_CFA_remember_state will be leaked. +# +# This test will fail when linked with an asan-enabled libunwind if the +# remembered state is leaked. + +SIZEOF_UNWIND_EXCEPTION = 32 + +.text +callback: +xorl%eax, %eax +retq + +.globlmain# -- Begin function main +.p2align4, 0x90 +.typemain,@function +main: # @main +.cfi_startproc +subq$8, %rsp # Adjust stack alignment +subq$SIZEOF_UNWIND_EXCEPTION, %rsp +.cfi_def_cfa_offset 48 +.cfi_remember_state +movq%rsp, %rdi +movabsq $callback, %rsi +xorl%edx, %edx +callq_Unwind_ForcedUnwind +.cfi_restore_state +xorl%eax, %eax +addq$SIZEOF_UNWIND_EXCEPTION, %rsp +addq$8, %rsp # Undo stack alignment adjustment +.cfi_def_cfa_offset 8 +retq +.Lfunc_end1: +.sizemain,
r374844 - Revert "Dead Virtual Function Elimination"
Author: jgorbe Date: Mon Oct 14 16:25:25 2019 New Revision: 374844 URL: http://llvm.org/viewvc/llvm-project?rev=374844=rev Log: Revert "Dead Virtual Function Elimination" This reverts commit 9f6a873268e1ad9855873d9d8007086c0d01cf4f. Removed: cfe/trunk/test/CodeGenCXX/vcall-visibility-metadata.cpp cfe/trunk/test/CodeGenCXX/virtual-function-elimination.cpp cfe/trunk/test/Driver/virtual-function-elimination.cpp Modified: cfe/trunk/include/clang/Basic/CodeGenOptions.def cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/CodeGen/CGClass.cpp cfe/trunk/lib/CodeGen/CGVTables.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp Modified: cfe/trunk/include/clang/Basic/CodeGenOptions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CodeGenOptions.def?rev=374844=374843=374844=diff == --- cfe/trunk/include/clang/Basic/CodeGenOptions.def (original) +++ cfe/trunk/include/clang/Basic/CodeGenOptions.def Mon Oct 14 16:25:25 2019 @@ -278,10 +278,6 @@ CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< CODEGENOPT(WholeProgramVTables, 1, 0) ///< Whether to apply whole-program /// vtable optimization. -CODEGENOPT(VirtualFunctionElimination, 1, 0) ///< Whether to apply the dead - /// virtual function elimination - /// optimization. - /// Whether to use public LTO visibility for entities in std and stdext /// namespaces. This is enabled by clang-cl's /MT and /MTd flags. CODEGENOPT(LTOVisibilityPublicStd, 1, 0) Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=374844=374843=374844=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Mon Oct 14 16:25:25 2019 @@ -1863,13 +1863,6 @@ def fforce_emit_vtables : Flag<["-"], "f HelpText<"Emits more virtual tables to improve devirtualization">; def fno_force_emit_vtables : Flag<["-"], "fno-force-emit-vtables">, Group, Flags<[CoreOption]>; - -def fvirtual_function_elimination : Flag<["-"], "fvirtual-function-elimination">, Group, - Flags<[CoreOption, CC1Option]>, - HelpText<"Enables dead virtual function elimination optimization. Requires -flto=full">; -def fno_virtual_function_elimination : Flag<["-"], "fno-virtual-function_elimination">, Group, - Flags<[CoreOption]>; - def fwrapv : Flag<["-"], "fwrapv">, Group, Flags<[CC1Option]>, HelpText<"Treat signed integer overflow as two's complement">; def fwritable_strings : Flag<["-"], "fwritable-strings">, Group, Flags<[CC1Option]>, Modified: cfe/trunk/lib/CodeGen/CGClass.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=374844=374843=374844=diff == --- cfe/trunk/lib/CodeGen/CGClass.cpp (original) +++ cfe/trunk/lib/CodeGen/CGClass.cpp Mon Oct 14 16:25:25 2019 @@ -2784,16 +2784,11 @@ void CodeGenFunction::EmitVTablePtrCheck bool CodeGenFunction::ShouldEmitVTableTypeCheckedLoad(const CXXRecordDecl *RD) { if (!CGM.getCodeGenOpts().WholeProgramVTables || + !SanOpts.has(SanitizerKind::CFIVCall) || + !CGM.getCodeGenOpts().SanitizeTrap.has(SanitizerKind::CFIVCall) || !CGM.HasHiddenLTOVisibility(RD)) return false; - if (CGM.getCodeGenOpts().VirtualFunctionElimination) -return true; - - if (!SanOpts.has(SanitizerKind::CFIVCall) || - !CGM.getCodeGenOpts().SanitizeTrap.has(SanitizerKind::CFIVCall)) -return false; - std::string TypeName = RD->getQualifiedNameAsString(); return !getContext().getSanitizerBlacklist().isBlacklistedType( SanitizerKind::CFIVCall, TypeName); @@ -2816,13 +2811,8 @@ llvm::Value *CodeGenFunction::EmitVTable TypeId}); llvm::Value *CheckResult = Builder.CreateExtractValue(CheckedLoad, 1); - std::string TypeName = RD->getQualifiedNameAsString(); - if (SanOpts.has(SanitizerKind::CFIVCall) && - !getContext().getSanitizerBlacklist().isBlacklistedType( - SanitizerKind::CFIVCall, TypeName)) { -EmitCheck(std::make_pair(CheckResult, SanitizerKind::CFIVCall), - SanitizerHandler::CFICheckFail, {}, {}); - } + EmitCheck(std::make_pair(CheckResult, SanitizerKind::CFIVCall), +SanitizerHandler::CFICheckFail, nullptr, nullptr); return Builder.CreateBitCast( Builder.CreateExtractValue(CheckedLoad, 0), Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=374844=374843=374844=diff
r359361 - Revert Fix interactions between __builtin_constant_p and constexpr to match current trunk GCC.
Author: jgorbe Date: Fri Apr 26 17:32:04 2019 New Revision: 359361 URL: http://llvm.org/viewvc/llvm-project?rev=359361=rev Log: Revert Fix interactions between __builtin_constant_p and constexpr to match current trunk GCC. This reverts r359059 (git commit 0b098754b73f3b96d00ecb1c7605760b11c90298) Removed: cfe/trunk/test/SemaCXX/builtin-constant-p.cpp Modified: cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/SemaCXX/enable_if.cpp Modified: cfe/trunk/lib/AST/ExprConstant.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=359361=359360=359361=diff == --- cfe/trunk/lib/AST/ExprConstant.cpp (original) +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Apr 26 17:32:04 2019 @@ -7801,33 +7801,19 @@ EvaluateBuiltinClassifyType(const CallEx } /// EvaluateBuiltinConstantPForLValue - Determine the result of -/// __builtin_constant_p when applied to the given pointer. +/// __builtin_constant_p when applied to the given lvalue. /// -/// A pointer is only "constant" if it is null (or a pointer cast to integer) -/// or it points to the first character of a string literal. -static bool EvaluateBuiltinConstantPForLValue(const APValue ) { - APValue::LValueBase Base = LV.getLValueBase(); - if (Base.isNull()) { -// A null base is acceptable. -return true; - } else if (const Expr *E = Base.dyn_cast()) { -if (!isa(E)) - return false; -return LV.getLValueOffset().isZero(); - } else { -// Any other base is not constant enough for GCC. -return false; - } +/// An lvalue is only "constant" if it is a pointer or reference to the first +/// character of a string literal. +template +static bool EvaluateBuiltinConstantPForLValue(const LValue ) { + const Expr *E = LV.getLValueBase().template dyn_cast(); + return E && isa(E) && LV.getLValueOffset().isZero(); } /// EvaluateBuiltinConstantP - Evaluate __builtin_constant_p as similarly to /// GCC as we can manage. -static bool EvaluateBuiltinConstantP(EvalInfo , const Expr *Arg) { - // Constant-folding is always enabled for the operand of __builtin_constant_p - // (even when the enclosing evaluation context otherwise requires a strict - // language-specific constant expression). - FoldConstant Fold(Info, true); - +static bool EvaluateBuiltinConstantP(ASTContext , const Expr *Arg) { QualType ArgType = Arg->getType(); // __builtin_constant_p always has one operand. The rules which gcc follows @@ -7835,27 +7821,34 @@ static bool EvaluateBuiltinConstantP(Eva // // - If the operand is of integral, floating, complex or enumeration type, //and can be folded to a known value of that type, it returns 1. - // - If the operand can be folded to a pointer to the first character - //of a string literal (or such a pointer cast to an integral type) - //or to a null pointer or an integer cast to a pointer, it returns 1. + // - If the operand and can be folded to a pointer to the first character + //of a string literal (or such a pointer cast to an integral type), it + //returns 1. // // Otherwise, it returns 0. // // FIXME: GCC also intends to return 1 for literals of aggregate types, but // its support for this does not currently work. - if (ArgType->isIntegralOrEnumerationType() || ArgType->isFloatingType() || - ArgType->isAnyComplexType() || ArgType->isPointerType() || - ArgType->isNullPtrType()) { -APValue V; -if (!::EvaluateAsRValue(Info, Arg, V)) + if (ArgType->isIntegralOrEnumerationType()) { +Expr::EvalResult Result; +if (!Arg->EvaluateAsRValue(Result, Ctx) || Result.HasSideEffects) return false; -// For a pointer (possibly cast to integer), there are special rules. +APValue = Result.Val; +if (V.getKind() == APValue::Int) + return true; if (V.getKind() == APValue::LValue) return EvaluateBuiltinConstantPForLValue(V); - -// Otherwise, any constant value is good enough. -return V.getKind() != APValue::Uninitialized; + } else if (ArgType->isFloatingType() || ArgType->isAnyComplexType()) { +return Arg->isEvaluatable(Ctx); + } else if (ArgType->isPointerType() || Arg->isGLValue()) { +LValue LV; +Expr::EvalStatus Status; +EvalInfo Info(Ctx, Status, EvalInfo::EM_ConstantFold); +if ((Arg->isGLValue() ? EvaluateLValue(Arg, LV, Info) + : EvaluatePointer(Arg, LV, Info)) && +!Status.HasSideEffects) + return EvaluateBuiltinConstantPForLValue(LV); } // Anything else isn't considered to be sufficiently constant. @@ -8266,7 +8259,7 @@ bool IntExprEvaluator::VisitBuiltinCallE case Builtin::BI__builtin_constant_p: { auto Arg = E->getArg(0); -if (EvaluateBuiltinConstantP(Info, Arg)) +if (EvaluateBuiltinConstantP(Info.Ctx, Arg)) return Success(true, E); auto ArgTy =
[libunwind] r350787 - Revert "[Sparc] Add Sparc V8 support"
Author: jgorbe Date: Wed Jan 9 17:08:31 2019 New Revision: 350787 URL: http://llvm.org/viewvc/llvm-project?rev=350787=rev Log: Revert "[Sparc] Add Sparc V8 support" This reverts commit r350705. Modified: libunwind/trunk/include/__libunwind_config.h libunwind/trunk/include/libunwind.h libunwind/trunk/src/DwarfInstructions.hpp libunwind/trunk/src/DwarfParser.hpp libunwind/trunk/src/Registers.hpp libunwind/trunk/src/UnwindCursor.hpp libunwind/trunk/src/UnwindRegistersRestore.S libunwind/trunk/src/UnwindRegistersSave.S libunwind/trunk/src/assembly.h libunwind/trunk/src/libunwind.cpp Modified: libunwind/trunk/include/__libunwind_config.h URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/__libunwind_config.h?rev=350787=350786=350787=diff == --- libunwind/trunk/include/__libunwind_config.h (original) +++ libunwind/trunk/include/__libunwind_config.h Wed Jan 9 17:08:31 2019 @@ -23,7 +23,6 @@ #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_ARM 287 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_OR1K 32 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_MIPS 65 -#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC 31 #if defined(_LIBUNWIND_IS_NATIVE_ONLY) # if defined(__i386__) @@ -114,11 +113,6 @@ #error "Unsupported MIPS ABI and/or environment" # endif # define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_MIPS -# elif defined(__sparc__) - #define _LIBUNWIND_TARGET_SPARC 1 - #define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC - #define _LIBUNWIND_CONTEXT_SIZE 16 - #define _LIBUNWIND_CURSOR_SIZE 23 # else # error "Unsupported architecture." # endif @@ -132,7 +126,6 @@ # define _LIBUNWIND_TARGET_OR1K 1 # define _LIBUNWIND_TARGET_MIPS_O32 1 # define _LIBUNWIND_TARGET_MIPS_NEWABI 1 -# define _LIBUNWIND_TARGET_SPARC 1 # define _LIBUNWIND_CONTEXT_SIZE 167 # define _LIBUNWIND_CURSOR_SIZE 179 # define _LIBUNWIND_HIGHEST_DWARF_REGISTER 287 Modified: libunwind/trunk/include/libunwind.h URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/libunwind.h?rev=350787=350786=350787=diff == --- libunwind/trunk/include/libunwind.h (original) +++ libunwind/trunk/include/libunwind.h Wed Jan 9 17:08:31 2019 @@ -823,40 +823,4 @@ enum { UNW_MIPS_LO = 65, }; -// SPARC registers -enum { - UNW_SPARC_G0 = 0, - UNW_SPARC_G1 = 1, - UNW_SPARC_G2 = 2, - UNW_SPARC_G3 = 3, - UNW_SPARC_G4 = 4, - UNW_SPARC_G5 = 5, - UNW_SPARC_G6 = 6, - UNW_SPARC_G7 = 7, - UNW_SPARC_O0 = 8, - UNW_SPARC_O1 = 9, - UNW_SPARC_O2 = 10, - UNW_SPARC_O3 = 11, - UNW_SPARC_O4 = 12, - UNW_SPARC_O5 = 13, - UNW_SPARC_O6 = 14, - UNW_SPARC_O7 = 15, - UNW_SPARC_L0 = 16, - UNW_SPARC_L1 = 17, - UNW_SPARC_L2 = 18, - UNW_SPARC_L3 = 19, - UNW_SPARC_L4 = 20, - UNW_SPARC_L5 = 21, - UNW_SPARC_L6 = 22, - UNW_SPARC_L7 = 23, - UNW_SPARC_I0 = 24, - UNW_SPARC_I1 = 25, - UNW_SPARC_I2 = 26, - UNW_SPARC_I3 = 27, - UNW_SPARC_I4 = 28, - UNW_SPARC_I5 = 29, - UNW_SPARC_I6 = 30, - UNW_SPARC_I7 = 31, -}; - #endif Modified: libunwind/trunk/src/DwarfInstructions.hpp URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfInstructions.hpp?rev=350787=350786=350787=diff == --- libunwind/trunk/src/DwarfInstructions.hpp (original) +++ libunwind/trunk/src/DwarfInstructions.hpp Wed Jan 9 17:08:31 2019 @@ -223,14 +223,6 @@ int DwarfInstructions::stepWithDwa } #endif -#if defined(_LIBUNWIND_TARGET_SPARC) - // Skip call site instruction and delay slot - returnAddress += 8; - // Skip unimp instruction if function returns a struct - if ((addressSpace.get32(returnAddress) & 0xC1C0) == 0) -returnAddress += 4; -#endif - // Return address is address after call site instruction, so setting IP to // that does simualates a return. newRegisters.setIP(returnAddress); Modified: libunwind/trunk/src/DwarfParser.hpp URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfParser.hpp?rev=350787=350786=350787=diff == --- libunwind/trunk/src/DwarfParser.hpp (original) +++ libunwind/trunk/src/DwarfParser.hpp Wed Jan 9 17:08:31 2019 @@ -685,22 +685,6 @@ bool CFI_Parser::parseInstructions(A break; #endif -#if defined(_LIBUNWIND_TARGET_SPARC) -case DW_CFA_GNU_window_save: - _LIBUNWIND_TRACE_DWARF("DW_CFA_GNU_window_save()\n"); - for (reg = UNW_SPARC_O0; reg <= UNW_SPARC_O7; reg++) { -results->savedRegisters[reg].location = kRegisterInRegister; -results->savedRegisters[reg].value = -(reg - UNW_SPARC_O0) + UNW_SPARC_I0; - } - - for (reg = UNW_SPARC_L0; reg <= UNW_SPARC_I7; reg++) { -
r347402 - Mark lambda decl as invalid if a captured variable has an invalid type.
Author: jgorbe Date: Wed Nov 21 09:49:37 2018 New Revision: 347402 URL: http://llvm.org/viewvc/llvm-project?rev=347402=rev Log: Mark lambda decl as invalid if a captured variable has an invalid type. This causes the compiler to crash when trying to compute a layout for the lambda closure type (see included test). Added: cfe/trunk/test/SemaCXX/lambda-invalid-capture.cpp Modified: cfe/trunk/lib/Sema/SemaExpr.cpp Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=347402=347401=347402=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Nov 21 09:49:37 2018 @@ -14966,6 +14966,21 @@ static void addAsFieldToClosureType(Sema = FieldDecl::Create(S.Context, Lambda, Loc, Loc, nullptr, FieldType, S.Context.getTrivialTypeSourceInfo(FieldType, Loc), nullptr, false, ICIS_NoInit); + // If the variable being captured has an invalid type, mark the lambda class + // as invalid as well. + if (!FieldType->isDependentType()) { +if (S.RequireCompleteType(Loc, FieldType, diag::err_field_incomplete)) { + Lambda->setInvalidDecl(); + Field->setInvalidDecl(); +} else { + NamedDecl *Def; + FieldType->isIncompleteType(); + if (Def && Def->isInvalidDecl()) { +Lambda->setInvalidDecl(); +Field->setInvalidDecl(); + } +} + } Field->setImplicit(true); Field->setAccess(AS_private); Lambda->addDecl(Field); Added: cfe/trunk/test/SemaCXX/lambda-invalid-capture.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/lambda-invalid-capture.cpp?rev=347402=auto == --- cfe/trunk/test/SemaCXX/lambda-invalid-capture.cpp (added) +++ cfe/trunk/test/SemaCXX/lambda-invalid-capture.cpp Wed Nov 21 09:49:37 2018 @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// Don't crash. + +struct g { + j; // expected-error {{C++ requires a type specifier for all declarations}} +}; + +void captures_invalid_type() { + g child; + auto q = [child]{}; + const int n = sizeof(q); +} + +void captures_invalid_array_type() { + g child[100]; + auto q = [child]{}; + const int n = sizeof(q); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r342668 - Add testcases for r342667.
Filed https://bugs.llvm.org/show_bug.cgi?id=39029 for the incorrect behavior when including a path with a leading slash on Windows. On Thu, Sep 20, 2018 at 3:35 PM Eric Christopher wrote: > Thank you! > > On Thu, Sep 20, 2018, 3:34 PM Zachary Turner wrote: > >> Test removed in r342693. >> >> On Thu, Sep 20, 2018 at 3:30 PM Jorge Gorbe Moya >> wrote: >> >>> Zach and I were able to find the cause. >>> >>> Clang on Windows manages to find "file.h" when you #include "/file.h" >>> and that makes the expected diagnostic not appear. MSVC inteprets an >>> #include with a leading slash as an absolute path so I think we have >>> accidentally hit a different bug in Clang :) >>> >>> One option to fix the test would be replacing the slash with another >>> random non-alphanumeric character that can't be interpreted as a directory >>> separator, but at that point I think we can just delete the failing test >>> and rely on the existing include-likely-typo.c that tests with both leading >>> and trailing non-alphanumeric characters. >>> >>> The other test in r342668 works because it includes a file that doesn't >>> exist even if you interpret the path as relative so it should be OK to keep >>> while the bug is found. >>> >>> I'll go find a bug about the behavior on windows. Thanks! >>> >>> Jorge >>> >>> On Thu, Sep 20, 2018 at 2:51 PM Eric Christopher >>> wrote: >>> FWIW we're trying to reproduce here real fast and then will revert or fix real fast. Thanks! -eric On Thu, Sep 20, 2018 at 2:46 PM Eric Christopher wrote: > Adding Jorge... > > On Thu, Sep 20, 2018 at 2:36 PM wrote: > >> Hi Eric, >> >> The test that you added in this commit is failing on the PS4 Windows >> bot. Can you please take a look? >> >> >> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/20052 >> >> FAIL: Clang :: Preprocessor/include-leading-nonalpha-suggest.c (10765 >> of 43992) >> TEST 'Clang :: >> Preprocessor/include-leading-nonalpha-suggest.c' FAILED >> >> Script: >> -- >> : 'RUN: at line 1'; >> >> c:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\bin\clang.EXE >> -cc1 -internal-isystem >> c:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\lib\clang\8.0.0\include >> -nostdsysteminc >> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\Preprocessor\include-leading-nonalpha-suggest.c >> -verify >> -- >> Exit Code: 1 >> >> Command Output (stdout): >> -- >> $ ":" "RUN: at line 1" >> $ >> "c:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\bin\clang.EXE" >> "-cc1" "-internal-isystem" >> "c:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\lib\clang\8.0.0\include" >> "-nostdsysteminc" >> "C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\Preprocessor\include-leading-nonalpha-suggest.c" >> "-verify" >> # command stderr: >> error: 'error' diagnostics expected but not seen: >> >> File >> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\Preprocessor\include-leading-nonalpha-suggest.c >> Line 3: '/empty_file_to_include.h' file not found, did you mean >> 'empty_file_to_include.h'? >> >> 1 error generated. >> >> >> error: command failed with exit status: 1 >> >> > Oof. Thanks. If I don't have something in 10 minutes I'll just revert. > > Thanks! > > -eric > > > >> Douglas Yung >> >> > -Original Message- >> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On >> Behalf >> > Of Eric Christopher via cfe-commits >> > Sent: Thursday, September 20, 2018 10:23 >> > To: cfe-commits@lists.llvm.org >> > Subject: r342668 - Add testcases for r342667. >> > >> > Author: echristo >> > Date: Thu Sep 20 10:22:43 2018 >> > New Revision: 342668 >> > >> > URL: http://llvm.org/viewvc/llvm-project?rev=342668=rev >> > Log: >> > Add testcases for r342667. >> > >> > Added: >> > >> cfe/trunk/test/Preprocessor/include-leading-nonalpha-no-suggest.c >> > cfe/trunk/test/Preprocessor/include-leading-nonalpha-suggest.c >> > >> > Added: cfe/trunk/test/Preprocessor/include-leading-nonalpha-no- >> > suggest.c >> > URL: http://llvm.org/viewvc/llvm- >> > project/cfe/trunk/test/Preprocessor/include-leading-nonalpha-no- >> > suggest.c?rev=342668=auto >> > >> === >> > === >> > --- >> cfe/trunk/test/Preprocessor/include-leading-nonalpha-no-suggest.c >>
Re: r342668 - Add testcases for r342667.
Zach and I were able to find the cause. Clang on Windows manages to find "file.h" when you #include "/file.h" and that makes the expected diagnostic not appear. MSVC inteprets an #include with a leading slash as an absolute path so I think we have accidentally hit a different bug in Clang :) One option to fix the test would be replacing the slash with another random non-alphanumeric character that can't be interpreted as a directory separator, but at that point I think we can just delete the failing test and rely on the existing include-likely-typo.c that tests with both leading and trailing non-alphanumeric characters. The other test in r342668 works because it includes a file that doesn't exist even if you interpret the path as relative so it should be OK to keep while the bug is found. I'll go find a bug about the behavior on windows. Thanks! Jorge On Thu, Sep 20, 2018 at 2:51 PM Eric Christopher wrote: > FWIW we're trying to reproduce here real fast and then will revert or fix > real fast. > > Thanks! > > -eric > > On Thu, Sep 20, 2018 at 2:46 PM Eric Christopher > wrote: > >> Adding Jorge... >> >> On Thu, Sep 20, 2018 at 2:36 PM wrote: >> >>> Hi Eric, >>> >>> The test that you added in this commit is failing on the PS4 Windows >>> bot. Can you please take a look? >>> >>> >>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/20052 >>> >>> FAIL: Clang :: Preprocessor/include-leading-nonalpha-suggest.c (10765 of >>> 43992) >>> TEST 'Clang :: >>> Preprocessor/include-leading-nonalpha-suggest.c' FAILED >>> Script: >>> -- >>> : 'RUN: at line 1'; >>> >>> c:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\bin\clang.EXE >>> -cc1 -internal-isystem >>> c:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\lib\clang\8.0.0\include >>> -nostdsysteminc >>> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\Preprocessor\include-leading-nonalpha-suggest.c >>> -verify >>> -- >>> Exit Code: 1 >>> >>> Command Output (stdout): >>> -- >>> $ ":" "RUN: at line 1" >>> $ >>> "c:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\bin\clang.EXE" >>> "-cc1" "-internal-isystem" >>> "c:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\lib\clang\8.0.0\include" >>> "-nostdsysteminc" >>> "C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\Preprocessor\include-leading-nonalpha-suggest.c" >>> "-verify" >>> # command stderr: >>> error: 'error' diagnostics expected but not seen: >>> >>> File >>> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\Preprocessor\include-leading-nonalpha-suggest.c >>> Line 3: '/empty_file_to_include.h' file not found, did you mean >>> 'empty_file_to_include.h'? >>> >>> 1 error generated. >>> >>> >>> error: command failed with exit status: 1 >>> >>> >> Oof. Thanks. If I don't have something in 10 minutes I'll just revert. >> >> Thanks! >> >> -eric >> >> >> >>> Douglas Yung >>> >>> > -Original Message- >>> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On >>> Behalf >>> > Of Eric Christopher via cfe-commits >>> > Sent: Thursday, September 20, 2018 10:23 >>> > To: cfe-commits@lists.llvm.org >>> > Subject: r342668 - Add testcases for r342667. >>> > >>> > Author: echristo >>> > Date: Thu Sep 20 10:22:43 2018 >>> > New Revision: 342668 >>> > >>> > URL: http://llvm.org/viewvc/llvm-project?rev=342668=rev >>> > Log: >>> > Add testcases for r342667. >>> > >>> > Added: >>> > cfe/trunk/test/Preprocessor/include-leading-nonalpha-no-suggest.c >>> > cfe/trunk/test/Preprocessor/include-leading-nonalpha-suggest.c >>> > >>> > Added: cfe/trunk/test/Preprocessor/include-leading-nonalpha-no- >>> > suggest.c >>> > URL: http://llvm.org/viewvc/llvm- >>> > project/cfe/trunk/test/Preprocessor/include-leading-nonalpha-no- >>> > suggest.c?rev=342668=auto >>> > === >>> > === >>> > --- cfe/trunk/test/Preprocessor/include-leading-nonalpha-no-suggest.c >>> > (added) >>> > +++ cfe/trunk/test/Preprocessor/include-leading-nonalpha-no-suggest.c >>> > Thu Sep 20 10:22:43 2018 >>> > @@ -0,0 +1,3 @@ >>> > +// RUN: %clang_cc1 %s -verify >>> > + >>> > +#include "/non_existing_file_to_include.h" // expected-error >>> > {{'/non_existing_file_to_include.h' file not found}} >>> > >>> > Added: cfe/trunk/test/Preprocessor/include-leading-nonalpha-suggest.c >>> > URL: http://llvm.org/viewvc/llvm- >>> > project/cfe/trunk/test/Preprocessor/include-leading-nonalpha- >>> > suggest.c?rev=342668=auto >>> > === >>> > === >>> > --- cfe/trunk/test/Preprocessor/include-leading-nonalpha-suggest.c >>> > (added) >>> > +++