summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-06-25 08:38:46 +0000
committerDaniel Jasper <djasper@google.com>2015-06-25 08:38:46 +0000
commit23d3bcfe5ba07a11c70c73c59e634e83d480a526 (patch)
tree9b606fea944839d4ea1b2b2185bbe31944bb24b5 /clang/lib/Format/TokenAnnotator.cpp
parent8677baf024fa8ec82adebf1b34ed9e6fbb4e2ca4 (diff)
downloadbcm5719-llvm-23d3bcfe5ba07a11c70c73c59e634e83d480a526.tar.gz
bcm5719-llvm-23d3bcfe5ba07a11c70c73c59e634e83d480a526.zip
clang-format: [Proto] Don't treat "operator" as keyword.
Before: optional string operator= 1; After: optional string operator = 1; llvm-svn: 240624
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 8d08c3d2622..2f1aae39344 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1876,7 +1876,12 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
const FormatToken &Right) {
const FormatToken &Left = *Right.Previous;
- if (Style.Language == FormatStyle::LK_Proto) {
+ if (Right.Tok.getIdentifierInfo() && Left.Tok.getIdentifierInfo())
+ return true; // Never ever merge two identifiers.
+ if (Style.Language == FormatStyle::LK_Cpp) {
+ if (Left.is(tok::kw_operator))
+ return Right.is(tok::coloncolon);
+ } else if (Style.Language == FormatStyle::LK_Proto) {
if (Right.is(tok::period) &&
Left.isOneOf(Keywords.kw_optional, Keywords.kw_required,
Keywords.kw_repeated))
@@ -1913,8 +1918,6 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
Right.is(TT_TemplateOpener))
return true;
}
- if (Right.Tok.getIdentifierInfo() && Left.Tok.getIdentifierInfo())
- return true; // Never ever merge two identifiers.
if (Left.is(TT_ImplicitStringLiteral))
return Right.WhitespaceRange.getBegin() != Right.WhitespaceRange.getEnd();
if (Line.Type == LT_ObjCMethodDecl) {
@@ -1937,8 +1940,6 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
return false;
if (Right.isOneOf(TT_CtorInitializerColon, TT_ObjCBlockLParen))
return true;
- if (Left.is(tok::kw_operator))
- return Right.is(tok::coloncolon);
if (Right.is(TT_OverloadedOperatorLParen))
return false;
if (Right.is(tok::colon)) {
OpenPOWER on IntegriCloud