summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
diff options
context:
space:
mode:
authorGeorge Karpenkov <ekarpenkov@apple.com>2019-02-01 02:13:02 +0000
committerGeorge Karpenkov <ekarpenkov@apple.com>2019-02-01 02:13:02 +0000
commitb6c6ab312e9ffa0f1144e3fccc2d25e3afef0e31 (patch)
tree15793ede65976a23f400cd37de50880dc4d76d9a /clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
parent6fa43f8b9c5e86636a4e8b1948309b6b6036ca34 (diff)
downloadbcm5719-llvm-b6c6ab312e9ffa0f1144e3fccc2d25e3afef0e31.tar.gz
bcm5719-llvm-b6c6ab312e9ffa0f1144e3fccc2d25e3afef0e31.zip
[analyzer] [RetainCountChecker] Fix object type for CF/Obj-C bridged casts
Having an incorrect type for a cast causes the checker to incorrectly dismiss the operation under ARC, leading to a false positive use-after-release on the test. rdar://47709885 Differential Revision: https://reviews.llvm.org/D57557 llvm-svn: 352824
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
index 2fe0d286bb3..9d2d8cd82aa 100644
--- a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
@@ -185,7 +185,16 @@ void RetainCountChecker::checkPostStmt(const CastExpr *CE,
if (!BE)
return;
- ArgEffect AE = ArgEffect(IncRef, ObjKind::ObjC);
+ QualType QT = CE->getType();
+ ObjKind K;
+ if (coreFoundation::isCFObjectRef(QT)) {
+ K = ObjKind::CF;
+ } else {
+ assert(cocoa::isCocoaObjectRef(QT));
+ K = ObjKind::ObjC;
+ }
+
+ ArgEffect AE = ArgEffect(IncRef, K);
switch (BE->getBridgeKind()) {
case OBC_Bridge:
OpenPOWER on IntegriCloud