diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-06-27 21:43:17 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-06-27 21:43:17 +0000 |
commit | 5a0ef78cd7d4651ffe4bfd74d202fa8c98afbd65 (patch) | |
tree | 9c05981287d21965503befbf3d77d3ec72c26915 /clang/lib/Analysis/CFG.cpp | |
parent | 9fb40ee966268ca016e43166b80cc6bf37911b9f (diff) | |
download | bcm5719-llvm-5a0ef78cd7d4651ffe4bfd74d202fa8c98afbd65.tar.gz bcm5719-llvm-5a0ef78cd7d4651ffe4bfd74d202fa8c98afbd65.zip |
Remove bogus VarDecl::extendsLifetimeOfTemporary function and inline it into
its only caller with a FIXME explaining why it's bogus.
llvm-svn: 185109
Diffstat (limited to 'clang/lib/Analysis/CFG.cpp')
-rw-r--r-- | clang/lib/Analysis/CFG.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index 14b8fd4a101..695440c9cbe 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -974,10 +974,23 @@ LocalScope* CFGBuilder::addLocalScopeForVarDecl(VarDecl *VD, // Check for const references bound to temporary. Set type to pointee. QualType QT = VD->getType(); if (QT.getTypePtr()->isReferenceType()) { - if (!VD->extendsLifetimeOfTemporary()) + // Attempt to determine whether this declaration lifetime-extends a + // temporary. + // + // FIXME: This is incorrect. Non-reference declarations can lifetime-extend + // temporaries, and a single declaration can extend multiple temporaries. + // We should look at the storage duration on each nested + // MaterializeTemporaryExpr instead. + const Expr *Init = VD->getInit(); + if (!Init) + return Scope; + if (const ExprWithCleanups *EWC = dyn_cast<ExprWithCleanups>(Init)) + Init = EWC->getSubExpr(); + if (!isa<MaterializeTemporaryExpr>(Init)) return Scope; - QT = getReferenceInitTemporaryType(*Context, VD->getInit()); + // Lifetime-extending a temporary. + QT = getReferenceInitTemporaryType(*Context, Init); } // Check for constant size array. Set type to array element type. |