r186172 - [analyzer] Treat nullPtrType as a location type.

Anna Zaks ganna at apple.com
Fri Jul 12 10:58:34 PDT 2013


Author: zaks
Date: Fri Jul 12 12:58:33 2013
New Revision: 186172

URL: http://llvm.org/viewvc/llvm-project?rev=186172&view=rev
Log:
[analyzer] Treat nullPtrType as a location type.

Fixes PR16584 (radar://14415223).

Modified:
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
    cfe/trunk/test/Analysis/nullptr.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h?rev=186172&r1=186171&r2=186172&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h Fri Jul 12 12:58:33 2013
@@ -290,7 +290,7 @@ public:
 
   static inline bool isLocType(QualType T) {
     return T->isAnyPointerType() || T->isBlockPointerType() || 
-           T->isReferenceType();
+           T->isReferenceType() || T->isNullPtrType();
   }
 
 private:

Modified: cfe/trunk/test/Analysis/nullptr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/nullptr.cpp?rev=186172&r1=186171&r2=186172&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/nullptr.cpp (original)
+++ cfe/trunk/test/Analysis/nullptr.cpp Fri Jul 12 12:58:33 2013
@@ -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;
+}





More information about the cfe-commits mailing list