Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions clang/lib/Format/UnwrappedLineParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1182,10 +1182,8 @@ void UnwrappedLineParser::parsePPDefine() {
if (MaybeIncludeGuard && !eof())
IncludeGuard = IG_Rejected;

if (FormatTok->Tok.getKind() == tok::l_paren &&
!FormatTok->hasWhitespaceBefore()) {
if (FormatTok->is(tok::l_paren) && !FormatTok->hasWhitespaceBefore())
parseParens();
}
if (Style.IndentPPDirectives != FormatStyle::PPDIS_None)
Line->Level += PPBranchLevel + 1;
addUnwrappedLine();
Expand All @@ -1196,6 +1194,11 @@ void UnwrappedLineParser::parsePPDefine() {
Line->InMacroBody = true;

if (Style.SkipMacroDefinitionBody) {
if (auto *Prev = Tokens->getPreviousToken(); Prev->is(tok::comment) &&
Prev->NewlinesBefore > 0 &&
!Prev->HasUnescapedNewline) {
Prev->Finalized = true;
}
while (!eof()) {
FormatTok->Finalized = true;
FormatTok = Tokens->getNextToken();
Expand Down
4 changes: 4 additions & 0 deletions clang/unittests/Format/FormatTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26022,6 +26022,10 @@ TEST_F(FormatTest, SkipMacroDefinitionBody) {
" A a \\\n "
" A a",
Style);
verifyNoChange("#define MY_MACRO \\\n"
" /* this is a comment */ \\\n"
" 1",
Style);
}

TEST_F(FormatTest, VeryLongNamespaceCommentSplit) {
Expand Down