================
@@ -108,9 +108,14 @@ bool tryToFindPtrOrigin(
if (auto *decl = memberCall->getMethodDecl()) {
std::optional<bool> IsGetterOfRefCt = isGetterOfSafePtr(decl);
if (IsGetterOfRefCt && *IsGetterOfRefCt) {
- E = memberCall->getImplicitObjectArgument();
- if (StopAtFirstRefCountedObj) {
- return callback(E, true);
+ E = memberCall->getImplicitObjectArgument()->IgnoreParenCasts();
+ if (auto *DRE = dyn_cast<DeclRefExpr>(E)) {
+ if (auto *Decl = dyn_cast_or_null<VarDecl>(DRE->getDecl())) {
+ if (isa<ParmVarDecl>(Decl) || Decl->isLocalVarDecl()) {
+ if (StopAtFirstRefCountedObj)
+ return callback(E, true);
+ }
+ }
----------------
rniwa wrote:
Oh, this is checking if we're calling a getter function on a smart pointer
that's declared locally or passed in as a parameter. In those cases, it's safe
to continue with the function call because we have that smart pointer in stack
(as opposed to heap).
https://github.com/llvm/llvm-project/pull/184243
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits