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.
This commit is contained in:
Alexander Kornienko
2026-03-16 20:16:28 +01:00
committed by GitHub
parent c9d321b3d1
commit 7e51783b0b
3 changed files with 5 additions and 24 deletions

View File

@@ -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;

View File

@@ -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);

View File

@@ -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)