r272357 - Remove CXXConstructExpr::getFoundDecl(); it turned out to not be useful.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 9 17:58:20 PDT 2016


Author: rsmith
Date: Thu Jun  9 19:58:19 2016
New Revision: 272357

URL: http://llvm.org/viewvc/llvm-project?rev=272357&view=rev
Log:
Remove CXXConstructExpr::getFoundDecl(); it turned out to not be useful.

Modified:
    cfe/trunk/include/clang/AST/ExprCXX.h
    cfe/trunk/include/clang/Sema/Sema.h
    cfe/trunk/lib/AST/ASTImporter.cpp
    cfe/trunk/lib/AST/ExprCXX.cpp
    cfe/trunk/lib/CodeGen/CGObjC.cpp
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/lib/Sema/SemaInit.cpp
    cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=272357&r1=272356&r2=272357&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Thu Jun  9 19:58:19 2016
@@ -1187,7 +1187,7 @@ private:
 protected:
   CXXConstructExpr(const ASTContext &C, StmtClass SC, QualType T,
                    SourceLocation Loc,
-                   NamedDecl *Found, CXXConstructorDecl *Ctor,
+                   CXXConstructorDecl *Ctor,
                    bool Elidable,
                    ArrayRef<Expr *> Args,
                    bool HadMultipleCandidates,
@@ -1211,7 +1211,6 @@ public:
 
   static CXXConstructExpr *Create(const ASTContext &C, QualType T,
                                   SourceLocation Loc,
-                                  NamedDecl *Found,
                                   CXXConstructorDecl *Ctor,
                                   bool Elidable,
                                   ArrayRef<Expr *> Args,
@@ -1222,9 +1221,6 @@ public:
                                   ConstructionKind ConstructKind,
                                   SourceRange ParenOrBraceRange);
 
-  /// \brief Get the declaration that was found by name lookup.
-  NamedDecl *getFoundDecl() const;
-
   /// \brief Get the constructor that this expression will (ultimately) call.
   CXXConstructorDecl *getConstructor() const { return Constructor; }
 
@@ -1393,7 +1389,6 @@ class CXXTemporaryObjectExpr : public CX
 
 public:
   CXXTemporaryObjectExpr(const ASTContext &C,
-                         NamedDecl *Found,
                          CXXConstructorDecl *Cons,
                          TypeSourceInfo *Type,
                          ArrayRef<Expr *> Args,

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=272357&r1=272356&r2=272357&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Jun  9 19:58:19 2016
@@ -4283,6 +4283,17 @@ public:
                         bool RequiresZeroInit, unsigned ConstructKind,
                         SourceRange ParenRange);
 
+  /// Build a CXXConstructExpr whose constructor has already been resolved if
+  /// it denotes an inherited constructor.
+  ExprResult
+  BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
+                        CXXConstructorDecl *Constructor, bool Elidable,
+                        MultiExprArg Exprs,
+                        bool HadMultipleCandidates, bool IsListInitialization,
+                        bool IsStdInitListInitialization,
+                        bool RequiresZeroInit, unsigned ConstructKind,
+                        SourceRange ParenRange);
+
   // FIXME: Can we remove this and have the above BuildCXXConstructExpr check if
   // the constructor can be elidable?
   ExprResult

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=272357&r1=272356&r2=272357&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Thu Jun  9 19:58:19 2016
@@ -5796,11 +5796,6 @@ Expr *ASTNodeImporter::VisitCXXConstruct
   if (T.isNull())
     return nullptr;
 
-  NamedDecl *ToFound =
-    dyn_cast_or_null<NamedDecl>(Importer.Import(E->getFoundDecl()));
-  if (!ToFound)
-    return nullptr;
-
   CXXConstructorDecl *ToCCD =
     dyn_cast_or_null<CXXConstructorDecl>(Importer.Import(E->getConstructor()));
   if (!ToCCD)
@@ -5813,7 +5808,7 @@ Expr *ASTNodeImporter::VisitCXXConstruct
 
   return CXXConstructExpr::Create(Importer.getToContext(), T,
                                   Importer.Import(E->getLocation()),
-                                  ToFound, ToCCD, E->isElidable(),
+                                  ToCCD, E->isElidable(),
                                   ToArgs, E->hadMultipleCandidates(),
                                   E->isListInitialization(),
                                   E->isStdInitListInitialization(),

Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=272357&r1=272356&r2=272357&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Thu Jun  9 19:58:19 2016
@@ -432,12 +432,6 @@ SourceLocation CXXConstructExpr::getLocE
   return End;
 }
 
-NamedDecl *CXXConstructExpr::getFoundDecl() const {
-  if (auto *Template = Constructor->getPrimaryTemplate())
-    return Template;
-  return Constructor;
-}
-
 SourceRange CXXOperatorCallExpr::getSourceRangeImpl() const {
   OverloadedOperatorKind Kind = getOperator();
   if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
@@ -723,7 +717,6 @@ CXXBindTemporaryExpr *CXXBindTemporaryEx
 }
 
 CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(const ASTContext &C,
-                                               NamedDecl *Found,
                                                CXXConstructorDecl *Cons,
                                                TypeSourceInfo *Type,
                                                ArrayRef<Expr*> Args,
@@ -735,7 +728,7 @@ CXXTemporaryObjectExpr::CXXTemporaryObje
   : CXXConstructExpr(C, CXXTemporaryObjectExprClass, 
                      Type->getType().getNonReferenceType(), 
                      Type->getTypeLoc().getBeginLoc(),
-                     Found, Cons, false, Args,
+                     Cons, false, Args,
                      HadMultipleCandidates,
                      ListInitialization,
                      StdInitListInitialization,
@@ -757,7 +750,6 @@ SourceLocation CXXTemporaryObjectExpr::g
 
 CXXConstructExpr *CXXConstructExpr::Create(const ASTContext &C, QualType T,
                                            SourceLocation Loc,
-                                           NamedDecl *Found,
                                            CXXConstructorDecl *Ctor,
                                            bool Elidable,
                                            ArrayRef<Expr*> Args,
@@ -768,7 +760,7 @@ CXXConstructExpr *CXXConstructExpr::Crea
                                            ConstructionKind ConstructKind,
                                            SourceRange ParenOrBraceRange) {
   return new (C) CXXConstructExpr(C, CXXConstructExprClass, T, Loc,
-                                  Found, Ctor, Elidable, Args,
+                                  Ctor, Elidable, Args,
                                   HadMultipleCandidates, ListInitialization,
                                   StdInitListInitialization,
                                   ZeroInitialization, ConstructKind,
@@ -777,7 +769,7 @@ CXXConstructExpr *CXXConstructExpr::Crea
 
 CXXConstructExpr::CXXConstructExpr(const ASTContext &C, StmtClass SC,
                                    QualType T, SourceLocation Loc,
-                                   NamedDecl *Found, CXXConstructorDecl *Ctor,
+                                   CXXConstructorDecl *Ctor,
                                    bool Elidable,
                                    ArrayRef<Expr*> Args,
                                    bool HadMultipleCandidates,
@@ -798,8 +790,6 @@ CXXConstructExpr::CXXConstructExpr(const
     ZeroInitialization(ZeroInitialization),
     ConstructKind(ConstructKind), Args(nullptr)
 {
-  assert(declaresSameEntity(Found, Ctor) ||
-         declaresSameEntity(Found, Ctor->getPrimaryTemplate()));
   if (NumArgs) {
     this->Args = new (C) Stmt*[Args.size()];
     

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=272357&r1=272356&r2=272357&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Thu Jun  9 19:58:19 2016
@@ -3312,7 +3312,6 @@ CodeGenFunction::GenerateObjCAtomicGette
 
   CXXConstructExpr *TheCXXConstructExpr =
     CXXConstructExpr::Create(C, Ty, SourceLocation(),
-                             CXXConstExpr->getFoundDecl(),
                              CXXConstExpr->getConstructor(),
                              CXXConstExpr->isElidable(),
                              ConstructorArgs,

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=272357&r1=272356&r2=272357&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Jun  9 19:58:19 2016
@@ -11495,11 +11495,28 @@ Sema::BuildCXXConstructExpr(SourceLocati
                                ConstructKind, ParenRange);
 }
 
+ExprResult
+Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
+                            NamedDecl *FoundDecl,
+                            CXXConstructorDecl *Constructor,
+                            bool Elidable,
+                            MultiExprArg ExprArgs,
+                            bool HadMultipleCandidates,
+                            bool IsListInitialization,
+                            bool IsStdInitListInitialization,
+                            bool RequiresZeroInit,
+                            unsigned ConstructKind,
+                            SourceRange ParenRange) {
+  return BuildCXXConstructExpr(
+      ConstructLoc, DeclInitType, Constructor, Elidable, ExprArgs,
+      HadMultipleCandidates, IsListInitialization, IsStdInitListInitialization,
+      RequiresZeroInit, ConstructKind, ParenRange);
+}
+
 /// BuildCXXConstructExpr - Creates a complete call to a constructor,
 /// including handling of its default argument expressions.
 ExprResult
 Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
-                            NamedDecl *FoundDecl,
                             CXXConstructorDecl *Constructor,
                             bool Elidable,
                             MultiExprArg ExprArgs,
@@ -11511,7 +11528,7 @@ Sema::BuildCXXConstructExpr(SourceLocati
                             SourceRange ParenRange) {
   MarkFunctionReferenced(ConstructLoc, Constructor);
   return CXXConstructExpr::Create(
-      Context, DeclInitType, ConstructLoc, FoundDecl, Constructor, Elidable,
+      Context, DeclInitType, ConstructLoc, Constructor, Elidable,
       ExprArgs, HadMultipleCandidates, IsListInitialization,
       IsStdInitListInitialization, RequiresZeroInit,
       static_cast<CXXConstructExpr::ConstructionKind>(ConstructKind),

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=272357&r1=272356&r2=272357&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Thu Jun  9 19:58:19 2016
@@ -5742,7 +5742,7 @@ PerformConstructorInitialization(Sema &S
       : Kind.getParenRange();
 
     CurInit = new (S.Context) CXXTemporaryObjectExpr(
-        S.Context, Step.Function.FoundDecl, Constructor, TSInfo,
+        S.Context, Constructor, TSInfo,
         ConstructorArgs, ParenOrBraceRange, HadMultipleCandidates,
         IsListInitialization, IsStdInitListInitialization,
         ConstructorInitRequiresZeroInit);

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=272357&r1=272356&r2=272357&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Thu Jun  9 19:58:19 2016
@@ -2660,7 +2660,6 @@ public:
   /// Subclasses may override this routine to provide different behavior.
   ExprResult RebuildCXXConstructExpr(QualType T,
                                      SourceLocation Loc,
-                                     NamedDecl *Found,
                                      CXXConstructorDecl *Constructor,
                                      bool IsElidable,
                                      MultiExprArg Args,
@@ -2675,7 +2674,7 @@ public:
                                           ConvertedArgs))
       return ExprError();
 
-    return getSema().BuildCXXConstructExpr(Loc, T, Found, Constructor,
+    return getSema().BuildCXXConstructExpr(Loc, T, Constructor,
                                            IsElidable,
                                            ConvertedArgs,
                                            HadMultipleCandidates,
@@ -9944,11 +9943,6 @@ TreeTransform<Derived>::TransformCXXCons
   if (T.isNull())
     return ExprError();
 
-  NamedDecl *FoundDecl = cast_or_null<NamedDecl>(
-      getDerived().TransformDecl(E->getLocStart(), E->getFoundDecl()));
-  if (!FoundDecl)
-    return ExprError();
-
   CXXConstructorDecl *Constructor
     = cast_or_null<CXXConstructorDecl>(
                                 getDerived().TransformDecl(E->getLocStart(),
@@ -9964,7 +9958,6 @@ TreeTransform<Derived>::TransformCXXCons
 
   if (!getDerived().AlwaysRebuild() &&
       T == E->getType() &&
-      FoundDecl == E->getFoundDecl() &&
       Constructor == E->getConstructor() &&
       !ArgumentChanged) {
     // Mark the constructor as referenced.
@@ -9974,7 +9967,7 @@ TreeTransform<Derived>::TransformCXXCons
   }
 
   return getDerived().RebuildCXXConstructExpr(T, /*FIXME:*/E->getLocStart(),
-                                              FoundDecl, Constructor,
+                                              Constructor,
                                               E->isElidable(), Args,
                                               E->hadMultipleCandidates(),
                                               E->isListInitialization(),




More information about the cfe-commits mailing list