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
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 84e22cb..1c2a540 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -3246,6 +3246,7 @@
verifyFormat("int a = (int)+2;");
verifyFormat("my_int a = (my_int)2.0f;");
verifyFormat("my_int a = (my_int)sizeof(int);");
+ verifyFormat("return (my_int)aaa;");
// FIXME: Without type knowledge, this can still fall apart miserably.
verifyFormat("void f() { my_int a = (my_int) * b; }");
@@ -3271,6 +3272,8 @@
verifyFormat("void f(int i = (kA * kB) & kMask) {}");
verifyFormat("int a = sizeof(int) * b;");
verifyFormat("int a = alignof(int) * b;");
+ verifyFormat("template <> void f<int>(int i) SOME_ANNOTATION;");
+ verifyFormat("f(\"%\" SOME_MACRO(ll) \"d\");");
// These are not casts, but at some point were confused with casts.
verifyFormat("virtual void foo(int *) override;");