summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis
diff options
context:
space:
mode:
authorDevin Coughlin <dcoughlin@apple.com>2016-08-02 21:07:23 +0000
committerDevin Coughlin <dcoughlin@apple.com>2016-08-02 21:07:23 +0000
commit6eb1ca74165a4e17d4f0193e879e729170257e39 (patch)
tree13d9f137cc0debfaf1dbb8d82f4499c878e96e3a /clang/lib/Analysis
parent368c4223b8182fcdf87aa5c5d4a1487de1ccf654 (diff)
downloadbcm5719-llvm-6eb1ca74165a4e17d4f0193e879e729170257e39.tar.gz
bcm5719-llvm-6eb1ca74165a4e17d4f0193e879e729170257e39.zip
[CFG] Fix crash finding destructor of lifetime-extended temporary.
Fix a crash under -Wthread-safety when finding the destructor for a lifetime-extending reference. A patch by Nandor Licker! Differential Revision: https://reviews.llvm.org/D22419 llvm-svn: 277522
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r--clang/lib/Analysis/CFG.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index d7a9bdb3d82..a67f0910e15 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -3902,7 +3902,17 @@ CFGImplicitDtor::getDestructorDecl(ASTContext &astContext) const {
case CFGElement::AutomaticObjectDtor: {
const VarDecl *var = castAs<CFGAutomaticObjDtor>().getVarDecl();
QualType ty = var->getType();
- ty = ty.getNonReferenceType();
+
+ // FIXME: See CFGBuilder::addLocalScopeForVarDecl.
+ //
+ // Lifetime-extending constructs are handled here. This works for a single
+ // temporary in an initializer expression.
+ if (ty->isReferenceType()) {
+ if (const Expr *Init = var->getInit()) {
+ ty = getReferenceInitTemporaryType(astContext, Init);
+ }
+ }
+
while (const ArrayType *arrayType = astContext.getAsArrayType(ty)) {
ty = arrayType->getElementType();
}
OpenPOWER on IntegriCloud