From: Daniel Jasper Date: Mon, 8 Jul 2013 14:58:01 +0000 (+0000) Subject: Fix incorrect incorrect cast identification in clang-format. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=526df0f3a8d436e9084bd12118a2e119aa0bd724;p=clang 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; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185828 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 1bcdac8e21..3c2ae52c99 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -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; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index dd137aabd6..2afd91e482 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -3498,6 +3498,7 @@ TEST_F(FormatTest, FormatsCasts) { verifyFormat("int a = alignof(int) * b;", getGoogleStyle()); verifyFormat("template <> void f(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;");