diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -3273,13 +3273,13 @@ if (Style.InsertBraces) { Passes.emplace_back([&](const Environment &Env) { - return BracesInserter(Env, Expanded).process(); + return BracesInserter(Env, Expanded).process(/*SkipAnnotation=*/true); }); } if (Style.RemoveBracesLLVM) { Passes.emplace_back([&](const Environment &Env) { - return BracesRemover(Env, Expanded).process(); + return BracesRemover(Env, Expanded).process(/*SkipAnnotation=*/true); }); } @@ -3305,7 +3305,7 @@ if (Style.isJavaScript() && Style.JavaScriptQuotes != FormatStyle::JSQS_Leave) { Passes.emplace_back([&](const Environment &Env) { - return JavaScriptRequoter(Env, Expanded).process(); + return JavaScriptRequoter(Env, Expanded).process(/*SkipAnnotation=*/true); }); } diff --git a/clang/lib/Format/TokenAnalyzer.h b/clang/lib/Format/TokenAnalyzer.h --- a/clang/lib/Format/TokenAnalyzer.h +++ b/clang/lib/Format/TokenAnalyzer.h @@ -89,7 +89,8 @@ public: TokenAnalyzer(const Environment &Env, const FormatStyle &Style); - std::pair process(); + std::pair + process(bool SkipAnnotation = false); protected: virtual std::pair diff --git a/clang/lib/Format/TokenAnalyzer.cpp b/clang/lib/Format/TokenAnalyzer.cpp --- a/clang/lib/Format/TokenAnalyzer.cpp +++ b/clang/lib/Format/TokenAnalyzer.cpp @@ -97,7 +97,8 @@ << "\n"); } -std::pair TokenAnalyzer::process() { +std::pair +TokenAnalyzer::process(bool SkipAnnotation) { tooling::Replacements Result; llvm::SpecificBumpPtrAllocator Allocator; IdentifierTable IdentTable(getFormattingLangOpts(Style)); @@ -121,7 +122,8 @@ TokenAnnotator Annotator(Style, Lex.getKeywords()); for (const UnwrappedLine &Line : Lines) { AnnotatedLines.push_back(new AnnotatedLine(Line)); - Annotator.annotate(*AnnotatedLines.back()); + if (!SkipAnnotation) + Annotator.annotate(*AnnotatedLines.back()); } std::pair RunResult =