From 5c585253e5f66affee0ce1d3db18ea2cfdfcdd82 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Wed, 4 Mar 2015 16:03:07 +0000 Subject: [Modules] Fix crash in Preprocessor::getLastMacroWithSpelling(). Macro names that got undefined inside a module may not have their MacroInfo set. llvm-svn: 231251 --- clang/lib/Lex/Preprocessor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'clang/lib/Lex/Preprocessor.cpp') diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index b2a6d933a0f..51a038ac728 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -321,11 +321,11 @@ StringRef Preprocessor::getLastMacroWithSpelling( StringRef BestSpelling; for (Preprocessor::macro_iterator I = macro_begin(), E = macro_end(); I != E; ++I) { - if (!I->second->getMacroInfo()->isObjectLike()) - continue; const MacroDirective::DefInfo Def = I->second->findDirectiveAtLoc(Loc, SourceMgr); - if (!Def) + if (!Def || !Def.getMacroInfo()) + continue; + if (!Def.getMacroInfo()->isObjectLike()) continue; if (!MacroDefinitionEquals(Def.getMacroInfo(), Tokens)) continue; -- cgit v1.2.3