[clang-format] Add macro replacement to fuzzing.
authorManuel Klimek <klimek@google.com>
Mon, 27 Feb 2023 09:39:40 +0000 (09:39 +0000)
committerManuel Klimek <klimek@google.com>
Mon, 27 Feb 2023 10:40:22 +0000 (10:40 +0000)
clang/tools/clang-format/fuzzer/ClangFormatFuzzer.cpp

index f90cdf5ab60dbfd6e88e3793ddde1ff8766d6d26..a8a783ba1a53e549d904b2887250a5ed10295e59 100644 (file)
@@ -19,6 +19,9 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
   std::string s((const char *)data, size);
   auto Style = getGoogleStyle(clang::format::FormatStyle::LK_Cpp);
   Style.ColumnLimit = 60;
+  Style.Macros.push_back("ASSIGN_OR_RETURN(a, b)=a = (b)");
+  Style.Macros.push_back("ASSIGN_OR_RETURN(a, b, c)=a = (b); if (x) return c");
+  Style.Macros.push_back("MOCK_METHOD(r, n, a, s)=r n a s");
   auto Replaces = reformat(Style, s, clang::tooling::Range(0, s.size()));
   auto Result = applyAllReplacements(s, Replaces);