From c425488a0e40c788a55e99854fccef13582ca7a4 Mon Sep 17 00:00:00 2001
From: Daniel Jasper <djasper@google.com>
Date: Fri, 24 Apr 2015 07:50:34 +0000
Subject: [PATCH] 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
---
 lib/Format/UnwrappedLineParser.cpp | 6 +++++-
 unittests/Format/FormatTest.cpp    | 4 ++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp
index 905f9c1ba5f..2aa4414d67a 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 6e2b9505238..a891ba2a679 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) {
-- 
GitLab