r185828 - Fix incorrect incorrect cast identification in clang-format.
Daniel Jasper
djasper at google.com
Mon Jul 8 07:58:01 PDT 2013
Author: djasper
Date: Mon Jul 8 09:58:01 2013
New Revision: 185828
URL: http://llvm.org/viewvc/llvm-project?rev=185828&view=rev
Log:
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;
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=185828&r1=185827&r2=185828&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jul 8 09:58:01 2013
@@ -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;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=185828&r1=185827&r2=185828&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jul 8 09:58:01 2013
@@ -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;");
More information about the cfe-commits
mailing list