summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclCXX.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-08-14 23:15:52 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-08-14 23:15:52 +0000
commit97fcf4be9be72b9d1b5650da8ca76e3badbf49ff (patch)
treef5b7093b76db2ffa0e9bce81d0ef86cbdeb55424 /clang/lib/AST/DeclCXX.cpp
parent52fe9ae99043cc9131ed8260cfda15b575e67d69 (diff)
downloadbcm5719-llvm-97fcf4be9be72b9d1b5650da8ca76e3badbf49ff.tar.gz
bcm5719-llvm-97fcf4be9be72b9d1b5650da8ca76e3badbf49ff.zip
Explicitly generate a reference variable to hold the initializer for a
tuple-like decomposition declaration. This significantly simplifies the semantics of BindingDecls for AST consumers (they can now always be evalated at the point of use). llvm-svn: 278640
Diffstat (limited to 'clang/lib/AST/DeclCXX.cpp')
-rw-r--r--clang/lib/AST/DeclCXX.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 54fd723d978..7e85619c819 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -2317,6 +2317,19 @@ BindingDecl *BindingDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
return new (C, ID) BindingDecl(nullptr, SourceLocation(), nullptr);
}
+VarDecl *BindingDecl::getHoldingVar() const {
+ Expr *B = getBinding();
+ if (!B)
+ return nullptr;
+ auto *DRE = dyn_cast<DeclRefExpr>(B->IgnoreImplicit());
+ if (!DRE)
+ return nullptr;
+
+ auto *VD = dyn_cast<VarDecl>(DRE->getDecl());
+ assert(VD->isImplicit() && "holding var for binding decl not implicit");
+ return VD;
+}
+
void DecompositionDecl::anchor() {}
DecompositionDecl *DecompositionDecl::Create(ASTContext &C, DeclContext *DC,
OpenPOWER on IntegriCloud