From: Daniel Jasper Date: Fri, 24 Apr 2015 07:50:34 +0000 (+0000) Subject: clang-format: More selectively detect QT's "signals". X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c425488a0e40c788a55e99854fccef13582ca7a4;p=clang clang-format: More selectively detect QT's "signals". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235702 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 905f9c1ba5..2aa4414d67 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -754,7 +754,11 @@ void UnwrappedLineParser::parseStructuralElement() { return; } if (FormatTok->is(Keywords.kw_signals)) { - parseAccessSpecifier(); + nextToken(); + if (FormatTok->is(tok::colon)) { + nextToken(); + addUnwrappedLine(); + } return; } // In all other cases, parse the declaration. diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 6e2b950523..a891ba2a67 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -1900,6 +1900,10 @@ TEST_F(FormatTest, UnderstandsAccessSpecifiers) { "signals:\n" " void g();\n" "};"); + + // Don't interpret 'signals' the wrong way. + verifyFormat("signals.set();"); + verifyFormat("for (Signals signals : f()) {\n}"); } TEST_F(FormatTest, SeparatesLogicalBlocks) {