]> granicus.if.org Git - clang/commitdiff
Fix incorrect incorrect cast identification in clang-format.
authorDaniel Jasper <djasper@google.com>
Mon, 8 Jul 2013 14:58:01 +0000 (14:58 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 8 Jul 2013 14:58:01 +0000 (14:58 +0000)
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

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp

index 1bcdac8e21a3d34ba877bc02c1a4e54094cae42b..3c2ae52c998f65b75bbdd03ed270d8ae6cdbccbc 100644 (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;
index dd137aabd6d843e2d6ab46492882809c02c9c6cc..2afd91e482ff96f295c814f7e81c0bf94e862f0f 100644 (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;");