@@ -26,6 +26,7 @@ bool tryToFindPtrOrigin(
2626 const Expr *E, bool StopAtFirstRefCountedObj,
2727 std::function<bool (const clang::CXXRecordDecl *)> isSafePtr,
2828 std::function<bool(const clang::QualType)> isSafePtrType,
29+ std::function<bool(const clang::Decl *)> isSafeGlobalDecl,
2930 std::function<bool(const clang::Expr *, bool )> callback) {
3031 while (E) {
3132 if (auto *DRE = dyn_cast<DeclRefExpr>(E)) {
@@ -34,6 +35,8 @@ bool tryToFindPtrOrigin(
3435 auto IsImmortal = safeGetName (VD) == " NSApp" ;
3536 if (VD->hasGlobalStorage () && (IsImmortal || QT.isConstQualified ()))
3637 return callback (E, true );
38+ if (VD->hasGlobalStorage () && isSafeGlobalDecl (VD))
39+ return callback (E, true );
3740 }
3841 }
3942 if (auto *tempExpr = dyn_cast<MaterializeTemporaryExpr>(E)) {
@@ -71,9 +74,11 @@ bool tryToFindPtrOrigin(
7174 }
7275 if (auto *Expr = dyn_cast<ConditionalOperator>(E)) {
7376 return tryToFindPtrOrigin (Expr->getTrueExpr (), StopAtFirstRefCountedObj,
74- isSafePtr, isSafePtrType, callback) &&
77+ isSafePtr, isSafePtrType, isSafeGlobalDecl,
78+ callback) &&
7579 tryToFindPtrOrigin (Expr->getFalseExpr (), StopAtFirstRefCountedObj,
76- isSafePtr, isSafePtrType, callback);
80+ isSafePtr, isSafePtrType, isSafeGlobalDecl,
81+ callback);
7782 }
7883 if (auto *cast = dyn_cast<CastExpr>(E)) {
7984 if (StopAtFirstRefCountedObj) {
0 commit comments