diff options
author | Anders Carlsson <andersca@mac.com> | 2010-11-06 14:58:53 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-11-06 14:58:53 +0000 |
commit | 624259984448cf19f4e94b7e31c7c32e99a39ea5 (patch) | |
tree | 12f9febba2166cfda43eb7b69e251abc23f9de1a | |
parent | 3030eb82593097502469a8b3fc26112c79c75605 (diff) |
Don't warn when matching %p to nullptr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118344 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/FormatString.cpp | 4 | ||||
-rw-r--r-- | test/SemaCXX/nullptr.cpp | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/Analysis/FormatString.cpp b/lib/Analysis/FormatString.cpp index 388b9d34a2..c1b5ea8a65 100644 --- a/lib/Analysis/FormatString.cpp +++ b/lib/Analysis/FormatString.cpp @@ -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; diff --git a/test/SemaCXX/nullptr.cpp b/test/SemaCXX/nullptr.cpp index 4f6e2e6eb1..666701c3c6 100644 --- a/test/SemaCXX/nullptr.cpp +++ b/test/SemaCXX/nullptr.cpp @@ -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); + } +} |