forked from OSchip/llvm-project
[clang][extract-api] Undefining macros should not result in a crash
This fixes the situation where a undefining a not previously defined macro resulted in a crash. Before trying to remove a definition from PendingMacros we first check to see if the macro did indeed have a previous definition. Differential Revision: https://reviews.llvm.org/D123056
This commit is contained in:
parent
4661a65f4b
commit
8b63622b9f
|
@ -534,6 +534,11 @@ public:
|
|||
// macro definition for it.
|
||||
void MacroUndefined(const Token &MacroNameToken, const MacroDefinition &MD,
|
||||
const MacroDirective *Undef) override {
|
||||
// If this macro wasn't previously defined we don't need to do anything
|
||||
// here.
|
||||
if (!Undef)
|
||||
return;
|
||||
|
||||
llvm::erase_if(PendingMacros, [&MD](const PendingMacro &PM) {
|
||||
return MD.getMacroInfo()->getDefinitionLoc() ==
|
||||
PM.MD->getMacroInfo()->getDefinitionLoc();
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
FUNC_GEN(foo)
|
||||
FUNC_GEN(bar, const int *, unsigned);
|
||||
#undef FUNC_GEN
|
||||
// Undefining a not previously defined macro should not result in a crash.
|
||||
#undef FOO
|
||||
|
||||
//--- reference.output.json.in
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue