summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-06-25 20:48:44 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-06-25 20:48:44 +0000
commit396f18f30218a0c3474dc48b88b999613ad7dcdf (patch)
tree03dbf26fad205a2fdd196ebaf40ec9297527e2e9
parent198337bf4200dd9d33c6223fc8ce5a488e60187f (diff)
downloadbcm5719-llvm-396f18f30218a0c3474dc48b88b999613ad7dcdf.tar.gz
bcm5719-llvm-396f18f30218a0c3474dc48b88b999613ad7dcdf.zip
[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
-rw-r--r--clang/include/clang/Lex/Preprocessor.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h
index 439a28041e2..f02364a385e 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/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) {
OpenPOWER on IntegriCloud