From 78c2ec43284537f65bbd95b0628271a140ba0ec4 Mon Sep 17 00:00:00 2001 From: Anna Zaks Date: Fri, 12 Jul 2013 17:58:33 +0000 Subject: [PATCH] [analyzer] Treat nullPtrType as a location type. Fixes PR16584 (radar://14415223). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186172 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h | 2 +- test/Analysis/nullptr.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h b/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h index 326e784e83..5a426ef001 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h @@ -290,7 +290,7 @@ public: static inline bool isLocType(QualType T) { return T->isAnyPointerType() || T->isBlockPointerType() || - T->isReferenceType(); + T->isReferenceType() || T->isNullPtrType(); } private: diff --git a/test/Analysis/nullptr.cpp b/test/Analysis/nullptr.cpp index 050c3f8dc5..56151dc6b6 100644 --- a/test/Analysis/nullptr.cpp +++ b/test/Analysis/nullptr.cpp @@ -81,3 +81,9 @@ int materializeTempExpr() { const S &s = S(*n); // expected-warning{{Dereference of null pointer}} return s.a; } + +typedef decltype(nullptr) nullptr_t; +void testMaterializeTemporaryExprWithNullPtr() { + // Create MaterializeTemporaryExpr with a nullptr inside. + const nullptr_t &r = nullptr; +} -- 2.40.0