diff options
| author | Dinesh Dwivedi <dinesh.d@samsung.com> | 2014-05-05 13:14:35 +0000 |
|---|---|---|
| committer | Dinesh Dwivedi <dinesh.d@samsung.com> | 2014-05-05 13:14:35 +0000 |
| commit | 76f98f8047dee94a3131f733ed99fb6fc23a0cfc (patch) | |
| tree | e0d982509294069df912f883917489e630e65310 /clang/unittests/Format/FormatTest.cpp | |
| parent | 6af073b636b0a3149f4c5dbb88b73c2746fcbc79 (diff) | |
| download | bcm5719-llvm-76f98f8047dee94a3131f733ed99fb6fc23a0cfc.tar.gz bcm5719-llvm-76f98f8047dee94a3131f733ed99fb6fc23a0cfc.zip | |
Added some heuristics to identify c style casting
Before:
void f() { my_int a = (my_int) * b; }
void f() { return P ? (my_int) * P : (my_int)0; }
After:
void f() { my_int a = (my_int)*b; }
void f() { return P ? (my_int)*P : (my_int)0; }
Differential Revision: http://reviews.llvm.org/D3576
llvm-svn: 207964
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 7db87cb3ce5..d1f4c86bda8 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -4741,12 +4741,18 @@ TEST_F(FormatTest, FormatsCasts) { verifyFormat("#define x ((int)-1)"); verifyFormat("#define p(q) ((int *)&q)"); - // FIXME: Without type knowledge, this can still fall apart miserably. - verifyFormat("void f() { my_int a = (my_int) * b; }"); - verifyFormat("void f() { return P ? (my_int) * P : (my_int)0; }"); - verifyFormat("my_int a = (my_int) ~0;"); - verifyFormat("my_int a = (my_int)++ a;"); - verifyFormat("my_int a = (my_int) + 2;"); + verifyFormat("void f() { my_int a = (my_int)*b; }"); + verifyFormat("void f() { return P ? (my_int)*P : (my_int)0; }"); + verifyFormat("my_int a = (my_int)~0;"); + verifyFormat("my_int a = (my_int)++a;"); + verifyFormat("my_int a = (my_int)+2;"); + verifyFormat("my_int a = (my_int)1;"); + verifyFormat("my_int a = (my_int *)1;"); + verifyFormat("my_int a = (const my_int)-1;"); + verifyFormat("my_int a = (const my_int *)-1;"); + + // FIXME: single value wrapped with paren will be treated as cast. + verifyFormat("void f(int i = (kValue)*kMask) {}"); // Don't break after a cast's verifyFormat("int aaaaaaaaaaaaaaaaaaaaaaaaaaa =\n" @@ -4767,7 +4773,6 @@ TEST_F(FormatTest, FormatsCasts) { verifyFormat("void f(SmallVector<int>) {}"); verifyFormat("void f(SmallVector<int>);"); verifyFormat("void f(SmallVector<int>) = 0;"); - verifyFormat("void f(int i = (kValue) * kMask) {}"); verifyFormat("void f(int i = (kA * kB) & kMask) {}"); verifyFormat("int a = sizeof(int) * b;"); verifyFormat("int a = alignof(int) * b;", getGoogleStyle()); |

