Fix incorrect incorrect cast identification in clang-format.

This fixes llvm.org/PR16534.

Before:
aaaaa& operator+(const aaaaa&)LLVM_DELETED_FUNCTION;
After:
aaaaa& operator+(const aaaaa&) LLVM_DELETED_FUNCTION;

llvm-svn: 185828
This commit is contained in:
Daniel Jasper 2013-07-08 14:58:01 +00:00
parent 4c409494d8
commit 6a09df7964
2 changed files with 2 additions and 0 deletions

View File

@ -633,6 +633,7 @@ private:
// there is also an identifier before the ().
if (LeftOfParens && (LeftOfParens->Tok.getIdentifierInfo() == NULL ||
LeftOfParens->is(tok::kw_return)) &&
LeftOfParens->Type != TT_OverloadedOperator &&
LeftOfParens->Type != TT_TemplateCloser && Current.Next &&
Current.Next->is(tok::identifier))
IsCast = true;

View File

@ -3498,6 +3498,7 @@ TEST_F(FormatTest, FormatsCasts) {
verifyFormat("int a = alignof(int) * b;", getGoogleStyle());
verifyFormat("template <> void f<int>(int i) SOME_ANNOTATION;");
verifyFormat("f(\"%\" SOME_MACRO(ll) \"d\");");
verifyFormat("aaaaa &operator=(const aaaaa &) LLVM_DELETED_FUNCTION;");
// These are not casts, but at some point were confused with casts.
verifyFormat("virtual void foo(int *) override;");