Index: lib/Format/FormatToken.h =================================================================== --- lib/Format/FormatToken.h +++ lib/Format/FormatToken.h @@ -652,6 +652,8 @@ kw_qsignals = &IdentTable.get("Q_SIGNALS"); kw_slots = &IdentTable.get("slots"); kw_qslots = &IdentTable.get("Q_SLOTS"); + kw_qunused = &IdentTable.get("Q_UNUSED"); + kw_qtrequireversion = &IdentTable.get("QT_REQUIRE_VERSION"); } // Context sensitive keywords. @@ -711,6 +713,8 @@ IdentifierInfo *kw_qsignals; IdentifierInfo *kw_slots; IdentifierInfo *kw_qslots; + IdentifierInfo *kw_qunused; + IdentifierInfo *kw_qtrequireversion; }; } // namespace format Index: lib/Format/UnwrappedLineParser.cpp =================================================================== --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -926,6 +926,17 @@ return; } } + if (Style.isCpp() && FormatTok->isOneOf(Keywords.kw_qunused, + Keywords.kw_qtrequireversion)) { + nextToken(); + if (FormatTok->is(tok::l_paren)) { + parseParens(); + if (FormatTok->is(tok::semi)) + nextToken(); + addUnwrappedLine(); + return; + } + } // In all other cases, parse the declaration. break; default: Index: unittests/Format/FormatTest.cpp =================================================================== --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -1976,6 +1976,16 @@ getLLVMStyleWithColumns(40))); verifyFormat("MACRO(>)"); + + // Some macros contain an implicit semicolon + verifyFormat("Q_UNUSED(a)\n" + "int b = 0;"); + verifyFormat("Q_UNUSED(a);\n" + "int b = 0;"); + verifyFormat("QT_REQUIRE_VERSION(argc, argv, \"4.0.2\")\n" + "int b = 0;"); + verifyFormat("QT_REQUIRE_VERSION(argc, argv, \"4.0.2\");\n" + "int b = 0;"); } TEST_F(FormatTest, LayoutMacroDefinitionsStatementsSpanningBlocks) {