r211487 - clang-format: Fix corner case in pointer/reference detection.
Daniel Jasper
djasper at google.com
Mon Jun 23 00:36:19 PDT 2014
Author: djasper
Date: Mon Jun 23 02:36:18 2014
New Revision: 211487
URL: http://llvm.org/viewvc/llvm-project?rev=211487&view=rev
Log:
clang-format: Fix corner case in pointer/reference detection.
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=211487&r1=211486&r2=211487&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jun 23 02:36:18 2014
@@ -918,6 +918,8 @@ private:
if (NextToken->is(tok::l_square) && NextToken->Type != TT_LambdaLSquare)
return TT_PointerOrReference;
+ if (NextToken->is(tok::kw_operator))
+ return TT_PointerOrReference;
if (PrevToken->is(tok::r_paren) && PrevToken->MatchingParen &&
PrevToken->MatchingParen->Previous &&
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=211487&r1=211486&r2=211487&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jun 23 02:36:18 2014
@@ -4844,6 +4844,8 @@ TEST_F(FormatTest, UnderstandsUsesOfStar
// FIXME: Is there a way to make this work?
// verifyIndependentOfContext("MACRO(A *a);");
+ verifyFormat("DatumHandle const *operator->() const { return input_; }");
+
EXPECT_EQ("#define OP(x) \\\n"
" ostream &operator<<(ostream &s, const A &a) { \\\n"
" return s << a.DebugString(); \\\n"
More information about the cfe-commits
mailing list