diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-06-25 20:48:44 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-06-25 20:48:44 +0000 |
commit | c90c3532b1666e20c1666a96c921ac93c6ac7257 (patch) | |
tree | 16abe604304b9d7e3ff5fa44d5bcbfb2e7ed1d0f /include/clang/Lex/Preprocessor.h | |
parent | 4e0fee847b7c709f6175e9e8c68446688b7df25e (diff) |
[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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240691 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Lex/Preprocessor.h')
-rw-r--r-- | include/clang/Lex/Preprocessor.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index 439a28041e..f02364a385 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -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) { |