From af5b021504d0578ec76e59fcf0d5b44b1b7f592d Mon Sep 17 00:00:00 2001 From: George Karpenkov Date: Thu, 24 Aug 2017 00:30:28 +0000 Subject: [PATCH] Fix ClangFormatFuzzer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@311621 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/clang-format/fuzzer/ClangFormatFuzzer.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/clang-format/fuzzer/ClangFormatFuzzer.cpp b/tools/clang-format/fuzzer/ClangFormatFuzzer.cpp index 5334ce873e..d440a6124b 100644 --- a/tools/clang-format/fuzzer/ClangFormatFuzzer.cpp +++ b/tools/clang-format/fuzzer/ClangFormatFuzzer.cpp @@ -20,7 +20,10 @@ 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; - 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; } -- 2.40.0