Remove unused and undesirable reference from BindingDecl to DecompositionDecl.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 12 Aug 2016 00:53:41 +0000 (00:53 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 12 Aug 2016 00:53:41 +0000 (00:53 +0000)
llvm-svn: 278448

clang/include/clang/AST/DeclCXX.h
clang/lib/AST/DeclCXX.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

index baeafe6..48ada29 100644 (file)
@@ -3385,28 +3385,20 @@ public:
 class BindingDecl : public ValueDecl {
   void anchor() override;
 
-  DecompositionDecl *Decomp;
-
   /// The binding represented by this declaration. References to this
   /// declaration are effectively equivalent to this expression (except
   /// that it is only evaluated once at the point of declaration of the
   /// binding).
   Expr *Binding;
 
-  BindingDecl(DeclContext *DC, DecompositionDecl *Decomp, SourceLocation IdLoc,
-              IdentifierInfo *Id)
-      : ValueDecl(Decl::Binding, DC, IdLoc, Id, QualType()), Decomp(Decomp),
-        Binding(nullptr) {}
+  BindingDecl(DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id)
+      : ValueDecl(Decl::Binding, DC, IdLoc, Id, QualType()), Binding(nullptr) {}
 
 public:
   static BindingDecl *Create(ASTContext &C, DeclContext *DC,
-                             DecompositionDecl *Decomp, SourceLocation IdLoc,
-                             IdentifierInfo *Id);
+                             SourceLocation IdLoc, IdentifierInfo *Id);
   static BindingDecl *CreateDeserialized(ASTContext &C, unsigned ID);
 
-  void setDecompositionDecl(DecompositionDecl *DD) { Decomp = DD; }
-  DecompositionDecl *getDecompositionDecl() const { return Decomp; }
-
   /// Get the expression to which this declaration is bound. This may be null
   /// in two different cases: while parsing the initializer for the
   /// decomposition declaration, and when the initializer is type-dependent.
index 772ce10..14df382 100644 (file)
@@ -2309,13 +2309,12 @@ StaticAssertDecl *StaticAssertDecl::CreateDeserialized(ASTContext &C,
 void BindingDecl::anchor() {}
 
 BindingDecl *BindingDecl::Create(ASTContext &C, DeclContext *DC,
-                                 DecompositionDecl *Decomp,
                                  SourceLocation IdLoc, IdentifierInfo *Id) {
-  return new (C, DC) BindingDecl(DC, Decomp, IdLoc, Id);
+  return new (C, DC) BindingDecl(DC, IdLoc, Id);
 }
 
 BindingDecl *BindingDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
-  return new (C, ID) BindingDecl(nullptr, nullptr, SourceLocation(), nullptr);
+  return new (C, ID) BindingDecl(nullptr, SourceLocation(), nullptr);
 }
 
 void DecompositionDecl::anchor() {}
index 6445dac..4a68d60 100644 (file)
@@ -6107,12 +6107,9 @@ NamedDecl *Sema::ActOnVariableDeclarator(
       NewVD = cast<VarDecl>(Res.get());
       AddToScope = false;
     } else if (D.isDecompositionDeclarator()) {
-      auto *NewDD = DecompositionDecl::Create(Context, DC, D.getLocStart(),
-                                              D.getIdentifierLoc(), R, TInfo,
-                                              SC, Bindings);
-      for (auto *B : Bindings)
-        B->setDecompositionDecl(NewDD);
-      NewVD = NewDD;
+      NewVD = DecompositionDecl::Create(Context, DC, D.getLocStart(),
+                                        D.getIdentifierLoc(), R, TInfo, SC,
+                                        Bindings);
     } else
       NewVD = VarDecl::Create(Context, DC, D.getLocStart(),
                               D.getIdentifierLoc(), II, R, TInfo, SC);
index cecbee1..a1ef6b4 100644 (file)
@@ -791,7 +791,7 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D,
       Diag(Old->getLocation(), diag::note_previous_definition);
     }
 
-    auto *BD = BindingDecl::Create(Context, DC, nullptr, B.NameLoc, B.Name);
+    auto *BD = BindingDecl::Create(Context, DC, B.NameLoc, B.Name);
     PushOnScopeChains(BD, S, true);
     Bindings.push_back(BD);
     ParsingInitForAutoVars.insert(BD);
index 5c8aa72..208afa6 100644 (file)
@@ -599,13 +599,7 @@ TemplateDeclInstantiator::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) {
 }
 
 Decl *TemplateDeclInstantiator::VisitBindingDecl(BindingDecl *D) {
-  auto *NewDD =
-      dyn_cast_or_null<DecompositionDecl>(SemaRef.FindInstantiatedDecl(
-          D->getLocation(), D->getDecompositionDecl(), TemplateArgs));
-  if (!NewDD)
-    return nullptr;
-
-  return BindingDecl::Create(SemaRef.Context, Owner, NewDD, D->getLocation(),
+  return BindingDecl::Create(SemaRef.Context, Owner, D->getLocation(),
                              D->getIdentifier());
 }