Author: Alexander Kornienko Date: 2026-03-16T20:16:28+01:00 New Revision: 7e51783b0bda05ec6155a4a943aa19145f0ff75d
URL: https://github.com/llvm/llvm-project/commit/7e51783b0bda05ec6155a4a943aa19145f0ff75d DIFF: https://github.com/llvm/llvm-project/commit/7e51783b0bda05ec6155a4a943aa19145f0ff75d.diff LOG: Revert "[Format] Configure ASSIGN_OR_RETURN macros for Google style" (#186445) Reverts llvm/llvm-project#169037 The change breaks formatting of real code containing ASSIGN_OR_RETURN macros nested into lambdas. See https://github.com/llvm/llvm-project/pull/169037#issuecomment-4056423543 for the test case. Added: Modified: clang/lib/Format/Format.cpp clang/unittests/Format/ConfigParseTest.cpp clang/unittests/Format/FormatTestMacroExpansion.cpp Removed: ################################################################################ diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 5c5a2ff2f5049..148124b190f4a 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -2011,11 +2011,6 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) { GoogleStyle.IncludeStyle.IncludeIsMainRegex = "([-_](test|unittest))?$"; GoogleStyle.IndentCaseLabels = true; GoogleStyle.KeepEmptyLines.AtStartOfBlock = false; - - GoogleStyle.Macros.push_back("ASSIGN_OR_RETURN(a, b)=a = (b)"); - GoogleStyle.Macros.push_back( - "ASSIGN_OR_RETURN(a, b, c)=a = (b); if (x) return c"); - GoogleStyle.ObjCBinPackProtocolList = FormatStyle::BPS_Never; GoogleStyle.ObjCSpaceAfterProperty = false; GoogleStyle.ObjCSpaceBeforeProtocolList = true; diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp index 8ae06bf339404..f13c68c3002e2 100644 --- a/clang/unittests/Format/ConfigParseTest.cpp +++ b/clang/unittests/Format/ConfigParseTest.cpp @@ -1043,13 +1043,6 @@ TEST(ConfigParseTest, ParsesConfiguration) { StatementAttributeLikeMacros, std::vector<std::string>({"emit", "Q_EMIT"})); - Style.Macros.clear(); - CHECK_PARSE("{Macros: [foo]}", Macros, std::vector<std::string>({"foo"})); - std::vector<std::string> GoogleMacros; - GoogleMacros.push_back("ASSIGN_OR_RETURN(a, b)=a = (b)"); - GoogleMacros.push_back("ASSIGN_OR_RETURN(a, b, c)=a = (b); if (x) return c"); - CHECK_PARSE("BasedOnStyle: Google", Macros, GoogleMacros); - Style.StatementMacros.clear(); CHECK_PARSE("StatementMacros: [QUNUSED]", StatementMacros, std::vector<std::string>{"QUNUSED"}); @@ -1057,6 +1050,7 @@ TEST(ConfigParseTest, ParsesConfiguration) { std::vector<std::string>({"QUNUSED", "QT_REQUIRE_VERSION"})); CHECK_PARSE_LIST(JavaImportGroups); + CHECK_PARSE_LIST(Macros); CHECK_PARSE_LIST(MacrosSkippedByRemoveParentheses); CHECK_PARSE_LIST(NamespaceMacros); CHECK_PARSE_LIST(ObjCPropertyAttributeOrder); diff --git a/clang/unittests/Format/FormatTestMacroExpansion.cpp b/clang/unittests/Format/FormatTestMacroExpansion.cpp index c00607f0b7115..d391fe3d715c3 100644 --- a/clang/unittests/Format/FormatTestMacroExpansion.cpp +++ b/clang/unittests/Format/FormatTestMacroExpansion.cpp @@ -58,18 +58,10 @@ TEST_F(FormatTestMacroExpansion, UnexpandConfiguredMacros) { verifyFormat("ASSIGN_OR_RETURN(MySomewhatLongType *variable,\n" " MySomewhatLongFunction(SomethingElse()));", Style); - verifyFormat( - "ASSIGN_OR_RETURN(MySomewhatLongType *variable,\n" - " MySomewhatLongFunction(SomethingElse()), RetMe());", - Style); - - verifyFormat( - "void f() {\n" - " ASSIGN_OR_RETURN(MySomewhatLongType* variable,\n" - " MySomewhatLongFunction(SomethingElse()));\n" - " ASSIGN_OR_RETURN(MySomewhatLongType* variable,\n" - " MySomewhatLongFunction(SomethingElse()), RetMe());", - getGoogleStyle()); + verifyFormat("ASSIGN_OR_RETURN(MySomewhatLongType *variable,\n" + " MySomewhatLongFunction(SomethingElse()), " + "ReturnMe());", + Style); verifyFormat(R"( #define MACRO(a, b) ID(a + b) _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
