diff options
author | Daniel Jasper <djasper@google.com> | 2015-04-22 09:45:42 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2015-04-22 09:45:42 +0000 |
commit | ee4a8a140ac653ef8a2ff03ee0c828906aac2de5 (patch) | |
tree | 8f93799cc3d271d47b0e0bcecd0571d497b12779 /clang/lib/Format | |
parent | cd2334e86e018757b5a51eb16e5a814a6d95bded (diff) | |
download | bcm5719-llvm-ee4a8a140ac653ef8a2ff03ee0c828906aac2de5.tar.gz bcm5719-llvm-ee4a8a140ac653ef8a2ff03ee0c828906aac2de5.zip |
clang-format: Fix for #pragma option formatting.
Adapted patch from Sergey Razmetov. Thank you.
llvm-svn: 235492
Diffstat (limited to 'clang/lib/Format')
-rw-r--r-- | clang/lib/Format/FormatToken.h | 5 | ||||
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 7 |
2 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h index bc14d4c5392..5e8730c71e5 100644 --- a/clang/lib/Format/FormatToken.h +++ b/clang/lib/Format/FormatToken.h @@ -545,6 +545,8 @@ struct AdditionalKeywords { kw_throws = &IdentTable.get("throws"); kw___except = &IdentTable.get("__except"); + kw_mark = &IdentTable.get("mark"); + kw_option = &IdentTable.get("option"); kw_optional = &IdentTable.get("optional"); kw_repeated = &IdentTable.get("repeated"); @@ -582,6 +584,9 @@ struct AdditionalKeywords { IdentifierInfo *kw_synchronized; IdentifierInfo *kw_throws; + // Pragma keywords. + IdentifierInfo *kw_mark; + // Proto keywords. IdentifierInfo *kw_option; IdentifierInfo *kw_optional; diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index ea5503ade68..7733b8a6e95 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -582,11 +582,14 @@ private: void parsePragma() { next(); // Consume "pragma". - if (CurrentToken && CurrentToken->TokenText == "mark") { + if (CurrentToken && + CurrentToken->isOneOf(Keywords.kw_mark, Keywords.kw_option)) { + bool IsMark = CurrentToken->is(Keywords.kw_mark); next(); // Consume "mark". next(); // Consume first token (so we fix leading whitespace). while (CurrentToken) { - CurrentToken->Type = TT_ImplicitStringLiteral; + if (IsMark || CurrentToken->Previous->is(TT_BinaryOperator)) + CurrentToken->Type = TT_ImplicitStringLiteral; next(); } } |