summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2013-02-13 04:13:13 +0000
committerNico Weber <nicolasweber@gmx.de>2013-02-13 04:13:13 +0000
commitc6fe2165c9ff9f755e2a51f38f7b507c88ab80ab (patch)
treed0e588dcc4198e00966cb9035cf3b7822e57296d /clang/lib/Format/TokenAnnotator.cpp
parenta789239c64b78c9286e21078949f4d117344a999 (diff)
downloadbcm5719-llvm-c6fe2165c9ff9f755e2a51f38f7b507c88ab80ab.tar.gz
bcm5719-llvm-c6fe2165c9ff9f755e2a51f38f7b507c88ab80ab.zip
Formatter: Refactor the cast detection code to be a bit more readable.
No functionality change. Also add another cast test. llvm-svn: 175029
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index ececc7c98a0..d2e19af56f1 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -578,15 +578,16 @@ private:
Current.Type = TT_LineComment;
else
Current.Type = TT_BlockComment;
- } else if (Current.is(tok::r_paren) &&
- (Current.Parent->Type == TT_PointerOrReference ||
- Current.Parent->Type == TT_TemplateCloser) &&
- (Current.Children.empty() ||
- (Current.Children[0].isNot(tok::equal) &&
- Current.Children[0].isNot(tok::semi) &&
- Current.Children[0].isNot(tok::l_brace)))) {
- // FIXME: We need to get smarter and understand more cases of casts.
- Current.Type = TT_CastRParen;
+ } else if (Current.is(tok::r_paren)) {
+ bool ParensNotExpr = Current.Parent->Type == TT_PointerOrReference ||
+ Current.Parent->Type == TT_TemplateCloser;
+ bool ParensCouldEndDecl =
+ !Current.Children.empty() && (Current.Children[0].is(tok::equal) ||
+ Current.Children[0].is(tok::semi) ||
+ Current.Children[0].is(tok::l_brace));
+ if (ParensNotExpr && !ParensCouldEndDecl)
+ // FIXME: We need to get smarter and understand more cases of casts.
+ Current.Type = TT_CastRParen;
} else if (Current.is(tok::at) && Current.Children.size()) {
switch (Current.Children[0].FormatTok.Tok.getObjCKeywordID()) {
case tok::objc_interface:
OpenPOWER on IntegriCloud