Skip to content

Commit 3a4c1a9

Browse files
committed
Fix crashes when the macro expansion is empty
1 parent f408171 commit 3a4c1a9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

clang/lib/Format/MacroExpander.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ MacroExpander::expand(FormatToken *ID,
233233
if (Result.size() > 1) {
234234
++Result[0]->MacroCtx->StartOfExpansion;
235235
++Result[Result.size() - 2]->MacroCtx->EndOfExpansion;
236+
} else {
237+
// If the macro expansion is empty, mark the start and end
238+
Result[0]->MacroCtx->StartOfExpansion = 1;
239+
Result[0]->MacroCtx->EndOfExpansion = 1;
236240
}
237241
return Result;
238242
}

0 commit comments

Comments
 (0)