clang-format: More selectively detect QT's "signals".
authorDaniel Jasper <djasper@google.com>
Fri, 24 Apr 2015 07:50:34 +0000 (07:50 +0000)
committerDaniel Jasper <djasper@google.com>
Fri, 24 Apr 2015 07:50:34 +0000 (07:50 +0000)
llvm-svn: 235702

clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTest.cpp

index 905f9c1..2aa4414 100644 (file)
@@ -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.
index 6e2b950..a891ba2 100644 (file)
@@ -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) {