]> granicus.if.org Git - clang/commitdiff
Don't warn when matching %p to nullptr.
authorAnders Carlsson <andersca@mac.com>
Sat, 6 Nov 2010 14:58:53 +0000 (14:58 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 6 Nov 2010 14:58:53 +0000 (14:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118344 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/FormatString.cpp
test/SemaCXX/nullptr.cpp

index 388b9d34a2382113527ce368c476075ce4664f2c..c1b5ea8a652a7c4849fb76358ae2d0a12d46e266 100644 (file)
@@ -296,8 +296,8 @@ bool ArgTypeResult::matchesType(ASTContext &C, QualType argTy) const {
     }
 
     case CPointerTy:
-      return argTy->getAs<PointerType>() != NULL ||
-             argTy->getAs<ObjCObjectPointerType>() != NULL;
+      return argTy->isPointerType() || argTy->isObjCObjectPointerType() ||
+        argTy->isNullPtrType();
 
     case ObjCPointerTy:
       return argTy->getAs<ObjCObjectPointerType>() != NULL;
index 4f6e2e6eb1c58f8c564fa1c0b83e7b808207531e..666701c3c6ef9bd525cd5f09d7cf39a50b41669f 100644 (file)
@@ -93,3 +93,12 @@ namespace test2 {
     f(10, nullptr);
   }
 }
+
+namespace test3 {
+  void f(const char*, ...) __attribute__((format(printf, 1, 2)));
+
+  void g() {
+    // Don't warn when using nullptr with %p.
+    f("%p", nullptr);
+  }
+}