aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/FormatString.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2012-02-06 21:45:29 +0000
committerTed Kremenek <kremenek@apple.com>2012-02-06 21:45:29 +0000
commitb4a3ef783cb3e9c8a927130d65385988a6aabaa3 (patch)
tree4a1be7a4eebf5e83ad4a668ead937f4e07f4d323 /lib/Analysis/FormatString.cpp
parentfd8fed902dee1cd2a4cab793b80280550e476668 (diff)
Tweak format string checking to work with %@ and ObjC toll-free bridging. <rdar://problem/10814120>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149907 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/FormatString.cpp')
-rw-r--r--lib/Analysis/FormatString.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/Analysis/FormatString.cpp b/lib/Analysis/FormatString.cpp
index 30bfe4bf88..1c911c45c3 100644
--- a/lib/Analysis/FormatString.cpp
+++ b/lib/Analysis/FormatString.cpp
@@ -336,9 +336,23 @@ bool ArgTypeResult::matchesType(ASTContext &C, QualType argTy) const {
return argTy->isPointerType() || argTy->isObjCObjectPointerType() ||
argTy->isNullPtrType();
- case ObjCPointerTy:
- return argTy->getAs<ObjCObjectPointerType>() ||
- argTy->getAs<BlockPointerType>();
+ case ObjCPointerTy: {
+ if (argTy->getAs<ObjCObjectPointerType>() ||
+ argTy->getAs<BlockPointerType>())
+ return true;
+
+ // Handle implicit toll-free bridging.
+ if (const PointerType *PT = argTy->getAs<PointerType>()) {
+ // Things such as CFTypeRef are really just opaque pointers
+ // to C structs representing CF types that can often be bridged
+ // to Objective-C objects. Since the compiler doesn't know which
+ // structs can be toll-free bridged, we just accept them all.
+ QualType pointee = PT->getPointeeType();
+ if (pointee->getAsStructureType() || pointee->isVoidType())
+ return true;
+ }
+ return false;
+ }
}
llvm_unreachable("Invalid ArgTypeResult Kind!");