summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/ContinuationIndenter.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-11-04 12:41:02 +0000
committerDaniel Jasper <djasper@google.com>2014-11-04 12:41:02 +0000
commitd0ec0d62d67a89084bd299f5162446b89e6ef072 (patch)
tree4a1f9acc562cf9fc4e51648e590bdb83811ff629 /clang/lib/Format/ContinuationIndenter.cpp
parentc1f30877e0357a2513fdf4f99a90cfc35be6572e (diff)
downloadbcm5719-llvm-d0ec0d62d67a89084bd299f5162446b89e6ef072.tar.gz
bcm5719-llvm-d0ec0d62d67a89084bd299f5162446b89e6ef072.zip
clang-format: Use identifier table for keywords in other languages.
Slightly easier to write, more efficient and prevents bugs by misspelling them. No functional changes intended. llvm-svn: 221259
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.cpp')
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index f6fbbba440e..adbd8a3d1d0 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -57,12 +57,13 @@ static bool startsNextParameter(const FormatToken &Current,
}
ContinuationIndenter::ContinuationIndenter(const FormatStyle &Style,
+ const AdditionalKeywords &Keywords,
SourceManager &SourceMgr,
WhitespaceManager &Whitespaces,
encoding::Encoding Encoding,
bool BinPackInconclusiveFunctions)
- : Style(Style), SourceMgr(SourceMgr), Whitespaces(Whitespaces),
- Encoding(Encoding),
+ : Style(Style), Keywords(Keywords), SourceMgr(SourceMgr),
+ Whitespaces(Whitespaces), Encoding(Encoding),
BinPackInconclusiveFunctions(BinPackInconclusiveFunctions),
CommentPragmasRegex(Style.CommentPragmas) {}
@@ -507,8 +508,8 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) {
NextNonComment = &Current;
// Java specific bits.
- if (Style.Language == FormatStyle::LK_Java && Current.is(tok::identifier) &&
- (Current.TokenText == "implements" || Current.TokenText == "extends"))
+ if (Style.Language == FormatStyle::LK_Java &&
+ Current.isOneOf(Keywords.kw_implements, Keywords.kw_extends))
return std::max(State.Stack.back().LastSpace,
State.Stack.back().Indent + Style.ContinuationIndentWidth);
@@ -673,7 +674,7 @@ unsigned ContinuationIndenter::moveStateToNextToken(LineState &State,
}
State.Stack[State.Stack.size() - 2].JSFunctionInlined = false;
}
- if (Current.TokenText == "function")
+ if (Current.is(Keywords.kw_function))
State.Stack.back().JSFunctionInlined =
!Newline && Previous && Previous->Type != TT_DictLiteral &&
Previous->Type != TT_ConditionalExpr &&
OpenPOWER on IntegriCloud