From: Daniel Jasper Date: Fri, 31 Mar 2017 12:04:37 +0000 (+0000) Subject: clang-format: [JavaScript] Ignore QT keywords. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=39309450ec530e37a96cf986e8cba20e5284e1de;p=clang clang-format: [JavaScript] Ignore QT keywords. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@299204 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 25bc99118f..a0354a32a8 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -916,7 +916,9 @@ void UnwrappedLineParser::parseStructuralElement() { return; } } - if (FormatTok->isOneOf(Keywords.kw_signals, Keywords.kw_qsignals, + if ((Style.Language == FormatStyle::LK_Cpp || + Style.Language == FormatStyle::LK_ObjC) && + FormatTok->isOneOf(Keywords.kw_signals, Keywords.kw_qsignals, Keywords.kw_slots, Keywords.kw_qslots)) { nextToken(); if (FormatTok->is(tok::colon)) { diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index 62d7ec86c9..f24ddc8fa2 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -167,6 +167,8 @@ TEST_F(FormatTestJS, ReservedWordsMethods) { TEST_F(FormatTestJS, CppKeywords) { // Make sure we don't mess stuff up because of C++ keywords. verifyFormat("return operator && (aa);"); + // .. or QT ones. + verifyFormat("slots: Slot[];"); } TEST_F(FormatTestJS, ES6DestructuringAssignment) {