r241188 - clang-format: Support member function reference qualifiers with
Daniel Jasper
djasper at google.com
Wed Jul 1 14:02:24 PDT 2015
Author: djasper
Date: Wed Jul 1 16:02:24 2015
New Revision: 241188
URL: http://llvm.org/viewvc/llvm-project?rev=241188&view=rev
Log:
clang-format: Support member function reference qualifiers with
trailing return types.
Before:
template <typename T>
auto x() & -> int {}
After:
template <typename T>
auto x() & -> int {}
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=241188&r1=241187&r2=241188&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Jul 1 16:02:24 2015
@@ -1123,7 +1123,7 @@ private:
return TT_UnaryOperator;
const FormatToken *NextToken = Tok.getNextNonComment();
- if (!NextToken ||
+ if (!NextToken || NextToken->is(tok::arrow) ||
(NextToken->is(tok::l_brace) && !NextToken->getNextNonComment()))
return TT_Unknown;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=241188&r1=241187&r2=241188&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Jul 1 16:02:24 2015
@@ -5258,11 +5258,6 @@ TEST_F(FormatTest, UnderstandsOverloaded
verifyGoogleFormat("operator ::A();");
verifyFormat("using A::operator+;");
-
- verifyFormat("string // break\n"
- "operator()() & {}");
- verifyFormat("string // break\n"
- "operator()() && {}");
}
TEST_F(FormatTest, UnderstandsFunctionRefQualification) {
@@ -5526,6 +5521,14 @@ TEST_F(FormatTest, UnderstandsUsesOfStar
verifyFormat("A = new SomeType *[Length]();", PointerMiddle);
verifyFormat("A = new SomeType *[Length];", PointerMiddle);
verifyFormat("T ** t = new T *;", PointerMiddle);
+
+ // Member function reference qualifiers aren't binary operators.
+ verifyFormat("string // break\n"
+ "operator()() & {}");
+ verifyFormat("string // break\n"
+ "operator()() && {}");
+ verifyGoogleFormat("template <typename T>\n"
+ "auto x() & -> int {}");
}
TEST_F(FormatTest, UnderstandsAttributes) {
More information about the cfe-commits
mailing list