summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-08-06 13:40:26 +0000
committerDaniel Jasper <djasper@google.com>2014-08-06 13:40:26 +0000
commit47189443997ca5549b8ec1cfd5377f30bf1c69a6 (patch)
treef188433f522bd1732af840ca28d8e8904606e856 /clang/lib
parent99917946da2c41dfe60790cf51d03e7f80beed8c (diff)
downloadbcm5719-llvm-47189443997ca5549b8ec1cfd5377f30bf1c69a6.tar.gz
bcm5719-llvm-47189443997ca5549b8ec1cfd5377f30bf1c69a6.zip
clang-format: Add special comments to disable formatting.
With this patch: int ThisWillBeFormatted; // clang-format off int ThisWontBeFormatted; // clang-format on int Formatted; This is for regions where a significantly nicer code layout can be found knowing the content of the code. This fixes llvm.org/PR20463. llvm-svn: 214966
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Format/Format.cpp7
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;
}
};
OpenPOWER on IntegriCloud