diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-02-06 21:45:29 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-02-06 21:45:29 +0000 |
commit | d22b98aad24577c224813c0a301affa9fae8e57f (patch) | |
tree | e3dc647bc1c6ffa4509aa6185a339abc3c1e9fc8 /clang/lib/Analysis/FormatString.cpp | |
parent | 0aef16afd5ff7d1eacc818bec5a69679cce2f115 (diff) | |
download | bcm5719-llvm-d22b98aad24577c224813c0a301affa9fae8e57f.tar.gz bcm5719-llvm-d22b98aad24577c224813c0a301affa9fae8e57f.zip |
Tweak format string checking to work with %@ and ObjC toll-free bridging. <rdar://problem/10814120>
llvm-svn: 149907
Diffstat (limited to 'clang/lib/Analysis/FormatString.cpp')
-rw-r--r-- | clang/lib/Analysis/FormatString.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/clang/lib/Analysis/FormatString.cpp b/clang/lib/Analysis/FormatString.cpp index 30bfe4bf884..1c911c45c3b 100644 --- a/clang/lib/Analysis/FormatString.cpp +++ b/clang/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!"); |