From e9fbba867ceefa7b8ed70d74f1c6850491948318 Mon Sep 17 00:00:00 2001 From: Andi-Bogdan Postelnicu Date: Tue, 17 Nov 2020 15:04:14 +0000 Subject: [PATCH] Bug 1666550 - Update `clang-tools` to `clang-11`. r=dmajor Differential Revision: https://phabricator.services.mozilla.com/D97137 --- build/build-clang/clang-format-11.patch | 154 +++++++++++++++++ build/build-clang/clang-tidy-ci.patch | 20 +-- build/build-clang/clang-tidy-linux64.json | 2 +- build/build-clang/clang-tidy-macosx64.json | 3 +- build/build-clang/clang-tidy-win64.json | 2 +- build/build-clang/clang_format_10.patch | 187 --------------------- taskcluster/ci/toolchain/clang-tidy.yml | 8 +- tools/clang-tidy/config.yaml | 2 +- 8 files changed, 173 insertions(+), 205 deletions(-) create mode 100644 build/build-clang/clang-format-11.patch delete mode 100644 build/build-clang/clang_format_10.patch diff --git a/build/build-clang/clang-format-11.patch b/build/build-clang/clang-format-11.patch new file mode 100644 index 000000000000..8c8fba5659da --- /dev/null +++ b/build/build-clang/clang-format-11.patch @@ -0,0 +1,154 @@ +From b9e789447f14c0330edd22c82746af29e7c3b259 Mon Sep 17 00:00:00 2001 +From: Sylvestre Ledru +Date: Sat, 17 Oct 2020 19:51:05 +0200 +Subject: [PATCH] Revert "[clang-format] Fix AlignConsecutive on PP blocks" + +This reverts commit b2eb439317576ce718193763c12bff9fccdfc166. + +Caused the regression: +https://bugs.llvm.org/show_bug.cgi?id=47589 + +Reviewed By: MyDeveloperDay + +Differential Revision: https://reviews.llvm.org/D89464 +--- + clang/lib/Format/FormatToken.h | 6 ----- + clang/lib/Format/UnwrappedLineParser.cpp | 2 -- + clang/lib/Format/WhitespaceManager.cpp | 10 +++----- + clang/unittests/Format/FormatTest.cpp | 23 ------------------- + clang/unittests/Format/FormatTestComments.cpp | 21 ----------------- + 5 files changed, 3 insertions(+), 59 deletions(-) + +diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h +index d4287f53fde..b132a3e84da 100644 +--- a/clang/lib/Format/FormatToken.h ++++ b/clang/lib/Format/FormatToken.h +@@ -183,12 +183,6 @@ struct FormatToken { + /// before the token. + bool MustBreakBefore = false; + +- /// Whether to not align across this token +- /// +- /// This happens for example when a preprocessor directive ended directly +- /// before the token, but very rarely otherwise. +- bool MustBreakAlignBefore = false; +- + /// The raw text of the token. + /// + /// Contains the raw token text without leading whitespace and without leading +diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp +index a37386425aa..ea8a41cfba8 100644 +--- a/clang/lib/Format/UnwrappedLineParser.cpp ++++ b/clang/lib/Format/UnwrappedLineParser.cpp +@@ -3037,7 +3037,6 @@ void UnwrappedLineParser::readToken(int LevelDifference) { + } + FormatTok = Tokens->getNextToken(); + FormatTok->MustBreakBefore = true; +- FormatTok->MustBreakAlignBefore = true; + } + + if (!PPStack.empty() && (PPStack.back().Kind == PP_Unreachable) && +@@ -3062,7 +3061,6 @@ void UnwrappedLineParser::pushToken(FormatToken *Tok) { + Line->Tokens.push_back(UnwrappedLineNode(Tok)); + if (MustBreakBeforeNextToken) { + Line->Tokens.back().Tok->MustBreakBefore = true; +- Line->Tokens.back().Tok->MustBreakAlignBefore = true; + MustBreakBeforeNextToken = false; + } + } +diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp +index 32e0b685ea0..3a265bd0916 100644 +--- a/clang/lib/Format/WhitespaceManager.cpp ++++ b/clang/lib/Format/WhitespaceManager.cpp +@@ -411,11 +411,9 @@ static unsigned AlignTokens(const FormatStyle &Style, F &&Matches, + if (Changes[i].NewlinesBefore != 0) { + CommasBeforeMatch = 0; + EndOfSequence = i; +- // If there is a blank line, there is a forced-align-break (eg, +- // preprocessor), or if the last line didn't contain any matching token, +- // the sequence ends here. +- if (Changes[i].NewlinesBefore > 1 || +- Changes[i].Tok->MustBreakAlignBefore || !FoundMatchOnLine) ++ // If there is a blank line, or if the last line didn't contain any ++ // matching token, the sequence ends here. ++ if (Changes[i].NewlinesBefore > 1 || !FoundMatchOnLine) + AlignCurrentSequence(); + + FoundMatchOnLine = false; +@@ -726,8 +724,6 @@ void WhitespaceManager::alignTrailingComments() { + if (Changes[i].StartOfBlockComment) + continue; + Newlines += Changes[i].NewlinesBefore; +- if (Changes[i].Tok->MustBreakAlignBefore) +- BreakBeforeNext = true; + if (!Changes[i].IsTrailingComment) + continue; + +diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp +index 17d302f0b65..7e4d1fca509 100644 +--- a/clang/unittests/Format/FormatTest.cpp ++++ b/clang/unittests/Format/FormatTest.cpp +@@ -11968,29 +11968,6 @@ TEST_F(FormatTest, AlignConsecutiveAssignments) { + verifyFormat("int oneTwoThree = 123; // comment\n" + "int oneTwo = 12; // comment", + Alignment); +- +- // Bug 25167 +- verifyFormat("#if A\n" +- "#else\n" +- "int aaaaaaaa = 12;\n" +- "#endif\n" +- "#if B\n" +- "#else\n" +- "int a = 12;\n" +- "#endif\n", +- Alignment); +- verifyFormat("enum foo {\n" +- "#if A\n" +- "#else\n" +- " aaaaaaaa = 12;\n" +- "#endif\n" +- "#if B\n" +- "#else\n" +- " a = 12;\n" +- "#endif\n" +- "};\n", +- Alignment); +- + EXPECT_EQ("int a = 5;\n" + "\n" + "int oneTwoThree = 123;", +diff --git a/clang/unittests/Format/FormatTestComments.cpp b/clang/unittests/Format/FormatTestComments.cpp +index 47509f29744..d5b9f8e0885 100644 +--- a/clang/unittests/Format/FormatTestComments.cpp ++++ b/clang/unittests/Format/FormatTestComments.cpp +@@ -2780,27 +2780,6 @@ TEST_F(FormatTestComments, AlignTrailingComments) { + " // line 2 about b\n" + " long b;", + getLLVMStyleWithColumns(80))); +- +- // Checks an edge case in preprocessor handling. +- // These comments should *not* be aligned +- EXPECT_EQ( +- "#if FOO\n" +- "#else\n" +- "long a; // Line about a\n" +- "#endif\n" +- "#if BAR\n" +- "#else\n" +- "long b_long_name; // Line about b\n" +- "#endif\n", +- format("#if FOO\n" +- "#else\n" +- "long a; // Line about a\n" // Previous (bad) behavior +- "#endif\n" +- "#if BAR\n" +- "#else\n" +- "long b_long_name; // Line about b\n" +- "#endif\n", +- getLLVMStyleWithColumns(80))); + } + + TEST_F(FormatTestComments, AlignsBlockCommentDecorations) { +-- +2.28.0 diff --git a/build/build-clang/clang-tidy-ci.patch b/build/build-clang/clang-tidy-ci.patch index e3f5f527532c..8d5d807ddf6b 100644 --- a/build/build-clang/clang-tidy-ci.patch +++ b/build/build-clang/clang-tidy-ci.patch @@ -1,23 +1,23 @@ diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp -index 40aaf402ec0..2184d51c643 100644 +index d6913dfd3c07..d031a163fdd7 100644 --- a/clang-tools-extra/clang-tidy/ClangTidy.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp -@@ -410,6 +410,7 @@ ClangTidyASTConsumerFactory::CreateASTConsumer( - - for (auto &Check : Checks) { +@@ -418,6 +418,7 @@ ClangTidyASTConsumerFactory::CreateASTConsumer( + if (!Check->isLanguageVersionSupported(Context.getLangOpts())) + continue; Check->registerMatchers(&*Finder); + Check->registerPPCallbacks(Compiler); Check->registerPPCallbacks(*SM, PP, ModuleExpanderPP); } - + diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.h b/clang-tools-extra/clang-tidy/ClangTidyCheck.h -index 1ad881f673a..59982bd377e 100644 +index 54b725126752..200780e86804 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyCheck.h +++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.h -@@ -53,6 +53,9 @@ public: - /// constructor using the Options.get() methods below. - ClangTidyCheck(StringRef CheckName, ClangTidyContext *Context); - +@@ -130,6 +130,9 @@ public: + return true; + } + + /// This has been deprecated in clang 9 - needed by mozilla-must-override + virtual void registerPPCallbacks(CompilerInstance &Compiler) {} + diff --git a/build/build-clang/clang-tidy-linux64.json b/build/build-clang/clang-tidy-linux64.json index 5528067f5c1c..d9eda595cb4d 100644 --- a/build/build-clang/clang-tidy-linux64.json +++ b/build/build-clang/clang-tidy-linux64.json @@ -12,6 +12,6 @@ "patches": [ "clang-tidy-ci.patch", "clang-tidy-no-errors.patch", - "clang_format_10.patch" + "clang-format-11.patch" ] } diff --git a/build/build-clang/clang-tidy-macosx64.json b/build/build-clang/clang-tidy-macosx64.json index e7f12af4bf8f..b496bbda6124 100644 --- a/build/build-clang/clang-tidy-macosx64.json +++ b/build/build-clang/clang-tidy-macosx64.json @@ -17,7 +17,8 @@ "patches": [ "clang-tidy-ci.patch", "clang-tidy-no-errors.patch", + "compiler-rt-cross-compile.patch", "compiler-rt-no-codesign.patch", - "clang_format_10.patch" + "clang-format-11.patch" ] } diff --git a/build/build-clang/clang-tidy-win64.json b/build/build-clang/clang-tidy-win64.json index a0b1e6ccbc96..2d0c180ebcc9 100644 --- a/build/build-clang/clang-tidy-win64.json +++ b/build/build-clang/clang-tidy-win64.json @@ -11,6 +11,6 @@ "patches": [ "clang-tidy-ci.patch", "clang-tidy-no-errors.patch", - "clang_format_10.patch" + "clang-format-11.patch" ] } diff --git a/build/build-clang/clang_format_10.patch b/build/build-clang/clang_format_10.patch deleted file mode 100644 index 5cd9d31598f1..000000000000 --- a/build/build-clang/clang_format_10.patch +++ /dev/null @@ -1,187 +0,0 @@ -diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp -index 70bcd7048c5..8cb786a4d34 100644 ---- a/clang/lib/Format/TokenAnnotator.cpp -+++ b/clang/lib/Format/TokenAnnotator.cpp -@@ -2176,6 +2176,10 @@ static bool isFunctionDeclarationName(const FormatToken &Current, - Next = Next->Next; - continue; - } -+ if (Next->is(TT_TemplateOpener) && Next->MatchingParen) { -+ Next = Next->MatchingParen; -+ continue; -+ } - - break; - } -@@ -2705,20 +2709,40 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, - tok::l_square)); - if (Right.is(tok::star) && Left.is(tok::l_paren)) - return false; -- if (Right.isOneOf(tok::star, tok::amp, tok::ampamp) && -- (Left.is(tok::identifier) || Left.isSimpleTypeSpecifier()) && -- // Space between the type and the * in: -- // operator void*() -- // operator char*() -- // operator /*comment*/ const char*() -- // operator volatile /*comment*/ char*() -- // operator Foo*() -- // dependent on PointerAlignment style. -- Left.Previous && -- (Left.Previous->endsSequence(tok::kw_operator) || -- Left.Previous->endsSequence(tok::kw_const, tok::kw_operator) || -- Left.Previous->endsSequence(tok::kw_volatile, tok::kw_operator))) -- return (Style.PointerAlignment != FormatStyle::PAS_Left); -+ if (Right.is(tok::star) && Left.is(tok::star)) -+ return false; -+ if (Right.isOneOf(tok::star, tok::amp, tok::ampamp)) { -+ const FormatToken *Previous = &Left; -+ while (Previous && !Previous->is(tok::kw_operator)) { -+ if (Previous->is(tok::identifier) || Previous->isSimpleTypeSpecifier()) { -+ Previous = Previous->getPreviousNonComment(); -+ continue; -+ } -+ if (Previous->is(TT_TemplateCloser) && Previous->MatchingParen) { -+ Previous = Previous->MatchingParen->getPreviousNonComment(); -+ continue; -+ } -+ if (Previous->is(tok::coloncolon)) { -+ Previous = Previous->getPreviousNonComment(); -+ continue; -+ } -+ break; -+ } -+ // Space between the type and the * in: -+ // operator void*() -+ // operator char*() -+ // operator /*comment*/ const char*() -+ // operator volatile /*comment*/ char*() -+ // operator Foo*() -+ // operator C*() -+ // operator std::Foo*() -+ // operator C::D*() -+ // dependent on PointerAlignment style. -+ if (Previous && (Previous->endsSequence(tok::kw_operator) || -+ Previous->endsSequence(tok::kw_const, tok::kw_operator) || -+ Previous->endsSequence(tok::kw_volatile, tok::kw_operator))) -+ return (Style.PointerAlignment != FormatStyle::PAS_Left); -+ } - const auto SpaceRequiredForArrayInitializerLSquare = - [](const FormatToken &LSquareTok, const FormatStyle &Style) { - return Style.SpacesInContainerLiterals || -diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp -index a5a26b5c1e8..7f8a3795e6e 100644 ---- a/clang/unittests/Format/FormatTest.cpp -+++ b/clang/unittests/Format/FormatTest.cpp -@@ -6185,7 +6185,17 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) { - "void\n" - "A::operator[]() {}\n" - "void\n" -- "A::operator!() {}\n", -+ "A::operator!() {}\n" -+ "void\n" -+ "A::operator**() {}\n" -+ "void\n" -+ "A::operator *() {}\n" -+ "void\n" -+ "A::operator **() {}\n" -+ "void\n" -+ "A::operator &() {}\n" -+ "void\n" -+ "A::operator void **() {}\n", - Style); - verifyFormat("constexpr auto\n" - "operator()() const -> reference {}\n" -@@ -6202,6 +6212,10 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) { - "constexpr auto\n" - "operator void *() const -> reference {}\n" - "constexpr auto\n" -+ "operator void **() const -> reference {}\n" -+ "constexpr auto\n" -+ "operator void *() const -> reference {}\n" -+ "constexpr auto\n" - "operator void &() const -> reference {}\n" - "constexpr auto\n" - "operator void &&() const -> reference {}\n" -@@ -14986,9 +15000,20 @@ TEST_F(FormatTest, OperatorSpacing) { - Style.PointerAlignment = FormatStyle::PAS_Right; - verifyFormat("Foo::operator*();", Style); - verifyFormat("Foo::operator void *();", Style); -+ verifyFormat("Foo::operator void **();", Style); - verifyFormat("Foo::operator()(void *);", Style); - verifyFormat("Foo::operator*(void *);", Style); - verifyFormat("Foo::operator*();", Style); -+ verifyFormat("Foo::operator**();", Style); -+ verifyFormat("Foo::operator&();", Style); -+ verifyFormat("Foo::operator *();", Style); -+ verifyFormat("Foo::operator *();", Style); -+ verifyFormat("Foo::operator **();", Style); -+ verifyFormat("Foo::operator **();", Style); -+ verifyFormat("Foo::operator &();", Style); -+ verifyFormat("Foo::operator &();", Style); -+ verifyFormat("Foo::operator &&();", Style); -+ verifyFormat("Foo::operator &&();", Style); - verifyFormat("operator*(int (*)(), class Foo);", Style); - - verifyFormat("Foo::operator&();", Style); -@@ -14999,21 +15024,39 @@ TEST_F(FormatTest, OperatorSpacing) { - verifyFormat("operator&(int (&)(), class Foo);", Style); - - verifyFormat("Foo::operator&&();", Style); -+ verifyFormat("Foo::operator**();", Style); - verifyFormat("Foo::operator void &&();", Style); - verifyFormat("Foo::operator()(void &&);", Style); - verifyFormat("Foo::operator&&(void &&);", Style); - verifyFormat("Foo::operator&&();", Style); - verifyFormat("operator&&(int(&&)(), class Foo);", Style); -+ verifyFormat("operator const nsTArrayRight &()", Style); -+ verifyFormat("[[nodiscard]] operator const nsTArrayRight &()", -+ Style); -+ verifyFormat("operator void **()", Style); -+ verifyFormat("operator const FooRight &()", Style); -+ verifyFormat("operator const FooRight *()", Style); -+ verifyFormat("operator const FooRight **()", Style); - - Style.PointerAlignment = FormatStyle::PAS_Left; - verifyFormat("Foo::operator*();", Style); -+ verifyFormat("Foo::operator**();", Style); - verifyFormat("Foo::operator void*();", Style); -+ verifyFormat("Foo::operator void**();", Style); - verifyFormat("Foo::operator/*comment*/ void*();", Style); - verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style); - verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style); - verifyFormat("Foo::operator()(void*);", Style); - verifyFormat("Foo::operator*(void*);", Style); - verifyFormat("Foo::operator*();", Style); -+ verifyFormat("Foo::operator*();", Style); -+ verifyFormat("Foo::operator*();", Style); -+ verifyFormat("Foo::operator**();", Style); -+ verifyFormat("Foo::operator**();", Style); -+ verifyFormat("Foo::operator&();", Style); -+ verifyFormat("Foo::operator&();", Style); -+ verifyFormat("Foo::operator&&();", Style); -+ verifyFormat("Foo::operator&&();", Style); - verifyFormat("operator*(int (*)(), class Foo);", Style); - - verifyFormat("Foo::operator&();", Style); -@@ -15035,6 +15078,21 @@ TEST_F(FormatTest, OperatorSpacing) { - verifyFormat("Foo::operator&&(void&&);", Style); - verifyFormat("Foo::operator&&();", Style); - verifyFormat("operator&&(int(&&)(), class Foo);", Style); -+ verifyFormat("operator const nsTArrayLeft&()", Style); -+ verifyFormat("[[nodiscard]] operator const nsTArrayLeft&()", -+ Style); -+ verifyFormat("operator void**()", Style); -+ verifyFormat("operator const FooLeft&()", Style); -+ verifyFormat("operator const FooLeft*()", Style); -+ verifyFormat("operator const FooLeft**()", Style); -+ -+ // PR45107 -+ verifyFormat("operator Vector&();", Style); -+ verifyFormat("operator const Vector&();", Style); -+ verifyFormat("operator foo::Bar*();", Style); -+ verifyFormat("operator const Foo::Bar*();", Style); -+ verifyFormat("operator/*a*/ const /*b*/ Foo /*c*/ /*d*/ ::Bar*();", -+ Style); - - Style.PointerAlignment = FormatStyle::PAS_Middle; - verifyFormat("Foo::operator*();", Style); diff --git a/taskcluster/ci/toolchain/clang-tidy.yml b/taskcluster/ci/toolchain/clang-tidy.yml index 9fbc26b34da7..77dc2d28bf63 100644 --- a/taskcluster/ci/toolchain/clang-tidy.yml +++ b/taskcluster/ci/toolchain/clang-tidy.yml @@ -23,7 +23,7 @@ job-defaults: - 'build/build-clang/build-clang.py' fetches: fetch: - - clang-10 + - clang-11 linux64-clang-tidy: index: @@ -51,7 +51,7 @@ macosx64-clang-tidy: worker-type: b-linux-large worker: env: - TOOLTOOL_MANIFEST: "browser/config/tooltool-manifests/macosx64/cross-releng.manifest" + TOOLTOOL_MANIFEST: "browser/config/tooltool-manifests/macosx64/cross-releng-12.manifest" run: using: toolchain-script script: build-clang.sh @@ -66,8 +66,8 @@ macosx64-clang-tidy: fetches: toolchain: - linux64-binutils - - linux64-cctools-port-clang-10 - - linux64-clang-10 + - linux64-cctools-port-clang-11 + - linux64-clang-11-macosx-cross - linux64-gcc-7 - linux64-node diff --git a/tools/clang-tidy/config.yaml b/tools/clang-tidy/config.yaml index 719f7c0b585e..1549595b29f3 100644 --- a/tools/clang-tidy/config.yaml +++ b/tools/clang-tidy/config.yaml @@ -19,7 +19,7 @@ platforms: # Minimum clang-tidy version that is required for all the following checkers # to work properly. # This is also used by 'mach clang-format' -package_version: "10.0" +package_version: "11.0" clang_checkers: - name: -* publish: !!bool no