return;
} else if (auto *OCE = dyn_cast<CXXOperatorCallExpr>(Call)) {
FunctionDecl *Callee = OCE->getDirectCallee();
- if (Callee->isCXXInstanceMember() &&
+ if (Callee && Callee->isCXXInstanceMember() &&
shouldTrackImplicitObjectArg(cast<CXXMethodDecl>(Callee)))
VisitPointerArg(Callee, OCE->getArg(0));
return;
// supporting lifetime extension.
break;
- case IndirectLocalPathEntry::DefaultInit:
case IndirectLocalPathEntry::VarInit:
+ if (cast<VarDecl>(Path[I].D)->isImplicit())
+ return SourceRange();
+ LLVM_FALLTHROUGH;
+ case IndirectLocalPathEntry::DefaultInit:
return Path[I].E->getSourceRange();
}
}
return false;
}
- if (IsGslPtrInitWithGslTempOwner) {
+ if (IsGslPtrInitWithGslTempOwner && DiagLoc.isValid()) {
Diag(DiagLoc, diag::warn_dangling_lifetime_pointer) << DiagRange;
return false;
}
std::vector<int> getTempVec();
std::optional<std::vector<int>> getTempOptVec();
+void testLoops() {
+ for (auto i : getTempVec()) // ok
+ ;
+ for (auto i : *getTempOptVec()) // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}}
+ ;
+}
+
int &usedToBeFalsePositive(std::vector<int> &v) {
std::vector<int>::iterator it = v.begin();
int& value = *it;