[modules] Fix findDirectiveAtLoc to not call a member function on a null pointer.

This is exercised by existing tests, and fixes a failure with -fsanitize=null.
No observable change otherwise; the code happened to do the right thing in
practice under recent versions of Clang and GCC because
MacroDirective::getDefinition happens to check whether this == null.

llvm-svn: 240691
This commit is contained in:
Richard Smith 2015-06-25 20:48:44 +00:00
parent 198337bf42
commit 396f18f302
1 changed files with 3 additions and 1 deletions
clang/include/clang/Lex

View File

@ -454,7 +454,9 @@ class Preprocessor : public RefCountedBase<Preprocessor> {
MacroDirective::DefInfo findDirectiveAtLoc(SourceLocation Loc,
SourceManager &SourceMgr) const {
// FIXME: Incorporate module macros into the result of this.
return getLatest()->findDirectiveAtLoc(Loc, SourceMgr);
if (auto *Latest = getLatest())
return Latest->findDirectiveAtLoc(Loc, SourceMgr);
return MacroDirective::DefInfo();
}
void overrideActiveModuleMacros(Preprocessor &PP, IdentifierInfo *II) {