diff options
author | Daniel Grumberg <dgrumberg@apple.com> | 2022-04-04 18:53:51 +0100 |
---|---|---|
committer | Daniel Grumberg <dgrumberg@apple.com> | 2022-04-05 11:42:45 +0100 |
commit | 8b63622b9fd9ad2a86487da6098b7a4351d3e8eb (patch) | |
tree | 9f91e2d81517dd6e564879b318e51933ff126b54 /clang/lib/ExtractAPI/ExtractAPIConsumer.cpp | |
parent | 4661a65f4beaa25060f1f92cdd66ce862f840d1b (diff) | |
download | llvm-8b63622b9fd9ad2a86487da6098b7a4351d3e8eb.zip llvm-8b63622b9fd9ad2a86487da6098b7a4351d3e8eb.tar.gz llvm-8b63622b9fd9ad2a86487da6098b7a4351d3e8eb.tar.bz2 |
[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
Diffstat (limited to 'clang/lib/ExtractAPI/ExtractAPIConsumer.cpp')
-rw-r--r-- | clang/lib/ExtractAPI/ExtractAPIConsumer.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp index cf95c3d..e4ae040 100644 --- a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp +++ b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp @@ -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(); |