[clang] [Format] Configure ASSIGN_OR_RETURN macros for Google style (PR #169037)

via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 14 22:51:29 PST 2026


================
@@ -961,14 +968,21 @@ TEST(ConfigParseTest, ParsesConfiguration) {
               StatementAttributeLikeMacros,
               std::vector<std::string>({"emit", "Q_EMIT"}));
 
+  Style.Macros.clear();
+  CHECK_PARSE("{ BasedOnStyle: LLVM, Macros: [foo]}", Macros,
+              std::vector<std::string>({"foo"}));
+  CHECK_PARSE_THAT(
+      "BasedOnStyle: Google", Macros,
+      testing::ElementsAre(testing::StartsWith("ASSIGN_OR_RETURN(a, b)="),
+                           testing::StartsWith("ASSIGN_OR_RETURN(a, b, c)=")));
----------------
owenca wrote:

```suggestion
  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);
```

https://github.com/llvm/llvm-project/pull/169037


More information about the cfe-commits mailing list