r311621 - Fix ClangFormatFuzzer.
George Karpenkov via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 23 17:30:28 PDT 2017
Author: george.karpenkov
Date: Wed Aug 23 17:30:28 2017
New Revision: 311621
URL: http://llvm.org/viewvc/llvm-project?rev=311621&view=rev
Log:
Fix ClangFormatFuzzer.
Modified:
cfe/trunk/tools/clang-format/fuzzer/ClangFormatFuzzer.cpp
Modified: cfe/trunk/tools/clang-format/fuzzer/ClangFormatFuzzer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/fuzzer/ClangFormatFuzzer.cpp?rev=311621&r1=311620&r2=311621&view=diff
==============================================================================
--- cfe/trunk/tools/clang-format/fuzzer/ClangFormatFuzzer.cpp (original)
+++ cfe/trunk/tools/clang-format/fuzzer/ClangFormatFuzzer.cpp Wed Aug 23 17:30:28 2017
@@ -20,7 +20,10 @@ extern "C" int LLVMFuzzerTestOneInput(ui
std::string s((const char *)data, size);
auto Style = getGoogleStyle(clang::format::FormatStyle::LK_Cpp);
Style.ColumnLimit = 60;
- applyAllReplacements(s, clang::format::reformat(
- Style, s, {clang::tooling::Range(0, s.size())}));
+ auto Replaces = reformat(Style, s, clang::tooling::Range(0, s.size()));
+ auto Result = applyAllReplacements(s, Replaces);
+
+ // Output must be checked, as otherwise we crash.
+ if (!Result) {}
return 0;
}
More information about the cfe-commits
mailing list