diff options
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r-- | clang/lib/Format/Format.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 8f119d3b650..bd9f3233237 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -1648,6 +1648,8 @@ private: SmallVector<FormatToken *, 16> Tokens; SmallVector<IdentifierInfo *, 8> ForEachMacros; + bool FormattingDisabled = false; + void readRawToken(FormatToken &Tok) { Lex.LexFromRawLexer(Tok.Tok); Tok.TokenText = StringRef(SourceMgr.getCharacterData(Tok.Tok.getLocation()), @@ -1663,6 +1665,11 @@ private: Tok.Tok.setKind(tok::char_constant); } } + if (Tok.is(tok::comment) && Tok.TokenText == "// clang-format on") + FormattingDisabled = false; + Tok.Finalized = FormattingDisabled; + if (Tok.is(tok::comment) && Tok.TokenText == "// clang-format off") + FormattingDisabled = true; } }; |