summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-06-06 08:20:20 +0000
committerDaniel Jasper <djasper@google.com>2013-06-06 08:20:20 +0000
commit058663787e7563605d426048a863df079d66e4c1 (patch)
tree754fa2542e0563c02e51327a5a20847791a4e6f6 /clang/lib
parentea4ad5d8419bf512398a26269b11d72b8fb04599 (diff)
downloadbcm5719-llvm-058663787e7563605d426048a863df079d66e4c1.tar.gz
bcm5719-llvm-058663787e7563605d426048a863df079d66e4c1.zip
Improve c-style cast detection.
Before: return (my_int) aaaa; template <> void f<int>(int i)SOME_ANNOTATION; f("aaaa" SOME_MACRO(aaaa)"aaaa"); After: return (my_int)aaaa; template <> void f<int>(int i) SOME_ANNOTATION; f("aaaa" SOME_MACRO(aaaa) "aaaa"); llvm-svn: 183389
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 62177b3efd7..fc53681394e 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -626,12 +626,15 @@ private:
Contexts.back().IsExpression)
IsCast = true;
if (Current.Next &&
+ Current.Next->isNot(tok::string_literal) &&
(Current.Next->Tok.isLiteral() ||
Current.Next->isOneOf(tok::kw_sizeof, tok::kw_alignof)))
IsCast = true;
// If there is an identifier after the (), it is likely a cast, unless
// there is also an identifier before the ().
- if (LeftOfParens && LeftOfParens->Tok.getIdentifierInfo() == NULL &&
+ if (LeftOfParens && (LeftOfParens->Tok.getIdentifierInfo() == NULL ||
+ LeftOfParens->is(tok::kw_return)) &&
+ LeftOfParens->Type != TT_TemplateCloser &&
LeftOfParens->Type != TT_ObjCMethodExpr && Current.Next &&
(Current.Next->is(tok::identifier)))
IsCast = true;
OpenPOWER on IntegriCloud