Skip to content

Commit 2c3b12b

Browse files
[clang-format][NFCish] Obey debug settings
Differential Revision: https://reviews.llvm.org/D156228
1 parent 77a38f4 commit 2c3b12b

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

clang/lib/Format/MacroCallReconstructor.cpp

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -319,30 +319,31 @@ void MacroCallReconstructor::endReconstruction(FormatToken *Token) {
319319
assert(Token->MacroCtx &&
320320
(ActiveExpansions.size() >= Token->MacroCtx->EndOfExpansion));
321321
for (size_t I = 0; I < Token->MacroCtx->EndOfExpansion; ++I) {
322-
#ifndef NDEBUG
323-
// Check all remaining tokens but the final closing parenthesis and optional
324-
// trailing comment were already reconstructed at an inner expansion level.
325-
for (auto T = ActiveExpansions.back().SpelledI;
326-
T != ActiveExpansions.back().SpelledE; ++T) {
327-
FormatToken *Token = T->Tok;
328-
bool ClosingParen = (std::next(T) == ActiveExpansions.back().SpelledE ||
329-
std::next(T)->Tok->isTrailingComment()) &&
330-
!Token->MacroCtx && Token->is(tok::r_paren);
331-
bool TrailingComment = Token->isTrailingComment();
332-
bool PreviousLevel =
333-
Token->MacroCtx &&
334-
(ActiveExpansions.size() < Token->MacroCtx->ExpandedFrom.size());
335-
if (!ClosingParen && !TrailingComment && !PreviousLevel)
336-
llvm::dbgs() << "At token: " << Token->TokenText << "\n";
337-
// In addition to the following cases, we can also run into this
338-
// when a macro call had more arguments than expected; in that case,
339-
// the comma and the remaining tokens in the macro call will potentially
340-
// end up in the line when we finish the expansion.
341-
// FIXME: Add the information which arguments are unused, and assert
342-
// one of the cases below plus reconstructed macro argument tokens.
343-
// assert(ClosingParen || TrailingComment || PreviousLevel);
344-
}
345-
#endif
322+
LLVM_DEBUG([&] {
323+
// Check all remaining tokens but the final closing parenthesis and
324+
// optional trailing comment were already reconstructed at an inner
325+
// expansion level.
326+
for (auto T = ActiveExpansions.back().SpelledI;
327+
T != ActiveExpansions.back().SpelledE; ++T) {
328+
FormatToken *Token = T->Tok;
329+
bool ClosingParen = (std::next(T) == ActiveExpansions.back().SpelledE ||
330+
std::next(T)->Tok->isTrailingComment()) &&
331+
!Token->MacroCtx && Token->is(tok::r_paren);
332+
bool TrailingComment = Token->isTrailingComment();
333+
bool PreviousLevel =
334+
Token->MacroCtx &&
335+
(ActiveExpansions.size() < Token->MacroCtx->ExpandedFrom.size());
336+
if (!ClosingParen && !TrailingComment && !PreviousLevel)
337+
llvm::dbgs() << "At token: " << Token->TokenText << "\n";
338+
// In addition to the following cases, we can also run into this
339+
// when a macro call had more arguments than expected; in that case,
340+
// the comma and the remaining tokens in the macro call will
341+
// potentially end up in the line when we finish the expansion.
342+
// FIXME: Add the information which arguments are unused, and assert
343+
// one of the cases below plus reconstructed macro argument tokens.
344+
// assert(ClosingParen || TrailingComment || PreviousLevel);
345+
}
346+
}());
346347
// Handle the remaining open tokens:
347348
// - expand the closing parenthesis, if it exists, including an optional
348349
// trailing comment

0 commit comments

Comments
 (0)