From de0d1f3c26628d6666d02e52353f56cd604160e6 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Fri, 24 Apr 2015 07:50:34 +0000 Subject: [PATCH] clang-format: More selectively detect QT's "signals". llvm-svn: 235702 --- clang/lib/Format/UnwrappedLineParser.cpp | 6 +++++- clang/unittests/Format/FormatTest.cpp | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 905f9c1..2aa4414d 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 6e2b950..a891ba2 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/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) { -- 2.7.4