summaryrefslogtreecommitdiff
path: root/lib/Sema
diff options
context:
space:
mode:
authorGabor Horvath <xazax.hun@gmail.com>2019-09-03 16:17:24 +0000
committerGabor Horvath <xazax.hun@gmail.com>2019-09-03 16:17:24 +0000
commit89e632ecc72fc21e447a9c772bb57eabf364c0fa (patch)
treea8772b9e605ca499ba78665170f91b325ebcccc6 /lib/Sema
parentcfb041434e33a16d7ba0ba4576194a7d42b2f3f8 (diff)
downloadclang-89e632ecc72fc21e447a9c772bb57eabf364c0fa.tar.gz
[LifetimeAnalysis] Fix some false positives
Differential Revision: https://reviews.llvm.org/D66806 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@370773 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r--lib/Sema/SemaInit.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 51e9f3d632..ff9b225207 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -6775,6 +6775,10 @@ static bool shouldTrackFirstArgument(const FunctionDecl *FD) {
static void handleGslAnnotatedTypes(IndirectLocalPath &Path, Expr *Call,
LocalVisitor Visit) {
auto VisitPointerArg = [&](const Decl *D, Expr *Arg) {
+ // We are not interested in the temporary base objects of gsl Pointers:
+ // Temp().ptr; // Here ptr might not dangle.
+ if (isa<MemberExpr>(Arg->IgnoreImpCasts()))
+ return;
Path.push_back({IndirectLocalPathEntry::GslPointerInit, Arg, D});
if (Arg->isGLValue())
visitLocalsRetainedByReferenceBinding(Path, Arg, RK_ReferenceBinding,
@@ -7295,6 +7299,8 @@ static bool pathOnlyInitializesGslPointer(IndirectLocalPath &Path) {
for (auto It = Path.rbegin(), End = Path.rend(); It != End; ++It) {
if (It->Kind == IndirectLocalPathEntry::VarInit)
continue;
+ if (It->Kind == IndirectLocalPathEntry::AddressOf)
+ continue;
return It->Kind == IndirectLocalPathEntry::GslPointerInit;
}
return false;