]> granicus.if.org Git - clang/commitdiff
Eliminate the ASTContext parameter from RecordDecl::getDefinition()
authorDouglas Gregor <dgregor@apple.com>
Thu, 11 Feb 2010 01:04:33 +0000 (01:04 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 11 Feb 2010 01:04:33 +0000 (01:04 +0000)
and CXXRecordDecl::getDefinition(); it's totally unnecessary. No
functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95836 91177308-0d34-0410-b5e6-96231b3b80d8

18 files changed:
include/clang/AST/Decl.h
include/clang/AST/DeclCXX.h
lib/AST/ASTContext.cpp
lib/AST/ASTImporter.cpp
lib/AST/CXXInheritance.cpp
lib/AST/Decl.cpp
lib/Checker/MemRegion.cpp
lib/Checker/RegionStore.cpp
lib/Checker/Store.cpp
lib/CodeGen/CGDebugInfo.cpp
lib/Frontend/ASTConsumers.cpp
lib/Sema/SemaCXXCast.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclCXX.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaTemplate.cpp
lib/Sema/SemaTemplateInstantiate.cpp
tools/CIndex/CIndex.cpp

index 58fb01d4fca7252f0b219ef04f83d4418f5b0e60..6d495522caaa7954cc9fd37cbd953a031124b8c8 100644 (file)
@@ -1595,7 +1595,7 @@ public:
   ///  specific TagDecl is defining declaration, not whether or not the
   ///  struct/union/class/enum type is defined.  This method returns NULL if
   ///  there is no TagDecl that defines the struct/union/class/enum.
-  TagDecl* getDefinition(ASTContext& C) const;
+  TagDecl* getDefinition() const;
 
   void setDefinition(bool V) { IsDefinition = V; }
 
@@ -1801,8 +1801,8 @@ public:
   ///  RecordDecl is defining declaration, not whether or not the record
   ///  type is defined.  This method returns NULL if there is no RecordDecl
   ///  that defines the struct/union/tag.
-  RecordDecl* getDefinition(ASTContext& C) const {
-    return cast_or_null<RecordDecl>(TagDecl::getDefinition(C));
+  RecordDecl* getDefinition() const {
+    return cast_or_null<RecordDecl>(TagDecl::getDefinition());
   }
 
   // Iterator access to field members. The field iterator only visits
index c0790f33b8327c941934e294ea45f595a734c4f4..a3a66885c21d9384c264ef8a7c2c4019e9ab0b6b 100644 (file)
@@ -362,7 +362,7 @@ public:
     return cast<CXXRecordDecl>(RecordDecl::getCanonicalDecl());
   }
 
-  CXXRecordDecl *getDefinition(ASTContext& C) const {
+  CXXRecordDecl *getDefinition() const {
     if (!DefinitionData) return 0;
     return data().Definition;
   }
index 7912a93421f193cb14dd8e8dbda98d2484726353..982ca7faa173eda2770d8f88efd47ab406d499be 100644 (file)
@@ -1097,7 +1097,7 @@ ASTContext::getASTObjCImplementationLayout(const ObjCImplementationDecl *D) {
 /// specified record (struct/union/class), which indicates its size and field
 /// position information.
 const ASTRecordLayout &ASTContext::getASTRecordLayout(const RecordDecl *D) {
-  D = D->getDefinition(*this);
+  D = D->getDefinition();
   assert(D && "Cannot get layout of forward declarations!");
 
   // Look up this layout, if already laid out, return what we have.
@@ -1114,7 +1114,7 @@ const ASTRecordLayout &ASTContext::getASTRecordLayout(const RecordDecl *D) {
 }
 
 const CXXMethodDecl *ASTContext::getKeyFunction(const CXXRecordDecl *RD) {
-  RD = cast<CXXRecordDecl>(RD->getDefinition(*this));
+  RD = cast<CXXRecordDecl>(RD->getDefinition());
   assert(RD && "Cannot get key function for forward declarations!");
   
   const CXXMethodDecl *&Entry = KeyFunctions[RD];
index f321ce2b9bbbffd032bd61269525253de8821a55..710a4635c1596524b587318e6ba51c9b08bc52e6 100644 (file)
@@ -652,7 +652,7 @@ Decl *ASTNodeImporter::VisitRecordDecl(RecordDecl *D) {
   // If this record has a definition in the translation unit we're coming from,
   // but this particular declaration is not that definition, import the
   // definition and map to that.
-  TagDecl *Definition = D->getDefinition(Importer.getFromContext());
+  TagDecl *Definition = D->getDefinition();
   if (Definition && Definition != D) {
     Decl *ImportedDef = Importer.Import(Definition);
     Importer.getImportedDecls()[D] = ImportedDef;
index 7d9e553eaf809881a81842ddb3e240ff4bd9489f..99f908caeab689734e580a6148068c4f02a12966 100644 (file)
@@ -102,7 +102,6 @@ bool CXXRecordDecl::isProvablyNotDerivedFrom(const CXXRecordDecl *Base) const {
 bool CXXRecordDecl::forallBases(ForallBasesCallback *BaseMatches,
                                 void *OpaqueData,
                                 bool AllowShortCircuit) const {
-  ASTContext &Context = getASTContext();
   llvm::SmallVector<const CXXRecordDecl*, 8> Queue;
 
   const CXXRecordDecl *Record = this;
@@ -118,7 +117,7 @@ bool CXXRecordDecl::forallBases(ForallBasesCallback *BaseMatches,
       }
 
       CXXRecordDecl *Base = 
-            cast_or_null<CXXRecordDecl>(Ty->getDecl()->getDefinition(Context));
+            cast_or_null<CXXRecordDecl>(Ty->getDecl()->getDefinition());
       if (!Base) {
         if (AllowShortCircuit) return false;
         AllMatches = false;
index a23f28cb37958e7cfe3cac8c1a5de9d7dbb333bf..80c1244698f18c8ba22d421f7abf4e4a8973e98f 100644 (file)
@@ -1398,7 +1398,7 @@ void TagDecl::completeDefinition() {
   }
 }
 
-TagDecl* TagDecl::getDefinition(ASTContext& C) const {
+TagDecl* TagDecl::getDefinition() const {
   if (isDefinition())
     return const_cast<TagDecl *>(this);
 
index cfa855e195c0b1d23a1025d2039bfb6698cc4e26..194015a11b1158cbab684b3300f304653aada0f6 100644 (file)
@@ -681,7 +681,7 @@ const MemRegion *MemRegion::StripCasts() const {
 static bool IsCompleteType(ASTContext &Ctx, QualType Ty) {
   if (const RecordType *RT = Ty->getAs<RecordType>()) {
     const RecordDecl *D = RT->getDecl();
-    if (!D->getDefinition(Ctx))
+    if (!D->getDefinition())
       return false;
   }
 
index d97fdbb7fd001e4d6e9bfc04c4e08785c6ae7b3d..4a8d9a0b0a9ff423e3ce9a632bced2aa6c8eff39 100644 (file)
@@ -606,7 +606,7 @@ Store InvalidateRegionsWorker::InvalidateRegions(RegionStoreManager &RM,
     
     // Invalidate the binding.      
     if (const RecordType *RT = T->getAsStructureType()) {
-      const RecordDecl *RD = RT->getDecl()->getDefinition(Ctx);      
+      const RecordDecl *RD = RT->getDecl()->getDefinition();      
       // No record definition.  There is nothing we can do.
       if (!RD) {
         B = RM.Remove(B, baseR);
index d68369dfa5de7b27eae9798452cd52f8f3dd347b..e524cb3d7cc327132c5975f280d5b14fa8daccd9 100644 (file)
@@ -31,7 +31,7 @@ const MemRegion *StoreManager::MakeElementRegion(const MemRegion *Base,
 static bool IsCompleteType(ASTContext &Ctx, QualType Ty) {
   if (const RecordType *RT = Ty->getAs<RecordType>()) {
     const RecordDecl *D = RT->getDecl();
-    if (!D->getDefinition(Ctx))
+    if (!D->getDefinition())
       return false;
   }
 
index 51f82db61d6fe727099b237678afba13ec43dcf7..620ecc81629612a8434fb1b88fcc6ea18729a295 100644 (file)
@@ -799,7 +799,7 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty,
                                      llvm::DIType(), llvm::DIArray());
 
   // If this is just a forward declaration, return it.
-  if (!RD->getDefinition(CGM.getContext()))
+  if (!RD->getDefinition())
     return FwdDecl;
 
   llvm::TrackingVH<llvm::MDNode> FwdDeclNode = FwdDecl.getNode();
index 33cb94e02dc3185e3c388b06fd73b1cd2b94cedd..ebbd720ceb637a2809ffbee1ae119b72b4c0bfac 100644 (file)
@@ -564,7 +564,7 @@ public:
       if (RD->isInvalidDecl())
         continue;
       
-      if (!RD->getDefinition(C))
+      if (!RD->getDefinition())
         continue;
       
       // FIXME: Do we really need to hard code this?
index 48258ff6ad6a68a74f6a022316f76fccfe391394..0097cd363c8caa81a8040813062df7a664f5b4cd 100644 (file)
@@ -391,7 +391,7 @@ CheckDynamicCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
   }
 
   // C++ 5.2.7p6: Otherwise, v shall be [polymorphic].
-  const RecordDecl *SrcDecl = SrcRecord->getDecl()->getDefinition(Self.Context);
+  const RecordDecl *SrcDecl = SrcRecord->getDecl()->getDefinition();
   assert(SrcDecl && "Definition missing");
   if (!cast<CXXRecordDecl>(SrcDecl)->isPolymorphic()) {
     Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_polymorphic)
index e12902bff6bdd2f3fe381e61fa2e4b2b96061609..82fd4379f66fc847b4963b2af389804b1512a810 100644 (file)
@@ -4633,7 +4633,7 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
 
           // Diagnose attempts to redefine a tag.
           if (TUK == TUK_Definition) {
-            if (TagDecl *Def = PrevTagDecl->getDefinition(Context)) {
+            if (TagDecl *Def = PrevTagDecl->getDefinition()) {
               // If we're defining a specialization and the previous definition
               // is from an implicit instantiation, don't emit an error
               // here; we'll catch this in the general case below.
index b42a27cdcb2cf1369f8794051b4f4873890446f7..2653633a952594e6652dbc4179dc118fdae3d4dd 100644 (file)
@@ -486,7 +486,7 @@ Sema::CheckBaseSpecifier(CXXRecordDecl *Class,
   // If the base class is polymorphic or isn't empty, the new one is/isn't, too.
   RecordDecl *BaseDecl = BaseType->getAs<RecordType>()->getDecl();
   assert(BaseDecl && "Record type has no declaration");
-  BaseDecl = BaseDecl->getDefinition(Context);
+  BaseDecl = BaseDecl->getDefinition();
   assert(BaseDecl && "Base type is not incomplete, but has no definition");
   CXXRecordDecl * CXXBaseDecl = cast<CXXRecordDecl>(BaseDecl);
   assert(CXXBaseDecl && "Base type is not a C++ type");
@@ -2013,7 +2013,7 @@ bool Sema::RequireNonAbstractType(SourceLocation Loc, QualType T,
     return false;
 
   // FIXME: is this reasonable?  It matches current behavior, but....
-  if (!RD->getDefinition(Context))
+  if (!RD->getDefinition())
     return false;
 
   if (!RD->isAbstract())
index 044216381cfb414ab2b870fec4d66cc751f793f4..c12c7776ee3c6cbd6da34f44b2e985a8f0ae66ff 100644 (file)
@@ -747,7 +747,7 @@ static bool IsProvablyNotDerivedFrom(Sema &SemaRef,
   if (Bases.count(Record->getCanonicalDecl()))
     return false;
 
-  RecordDecl *RD = Record->getDefinition(SemaRef.Context);
+  RecordDecl *RD = Record->getDefinition();
   if (!RD) return false;
   Record = cast<CXXRecordDecl>(RD);
 
index 1779bde666cbe51834a8f753e131b2c2116e4a2e..83bc6f39b85efe902f823f1871c7b1eb46881660 100644 (file)
@@ -823,7 +823,7 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK,
 
     // Check for redefinition of this class template.
     if (TUK == TUK_Definition) {
-      if (TagDecl *Def = PrevRecordDecl->getDefinition(Context)) {
+      if (TagDecl *Def = PrevRecordDecl->getDefinition()) {
         Diag(NameLoc, diag::err_redefinition) << Name;
         Diag(Def->getLocation(), diag::note_previous_definition);
         // FIXME: Would it make sense to try to "forget" the previous
@@ -3568,7 +3568,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
 
   // Check that this isn't a redefinition of this specialization.
   if (TUK == TUK_Definition) {
-    if (RecordDecl *Def = Specialization->getDefinition(Context)) {
+    if (RecordDecl *Def = Specialization->getDefinition()) {
       SourceRange Range(TemplateNameLoc, RAngleLoc);
       Diag(TemplateNameLoc, diag::err_redefinition)
         << Context.getTypeDeclType(Specialization) << Range;
@@ -4325,13 +4325,13 @@ Sema::ActOnExplicitInstantiation(Scope *S,
   // instantiation.
   ClassTemplateSpecializationDecl *Def
     = cast_or_null<ClassTemplateSpecializationDecl>(
-                                        Specialization->getDefinition(Context));
+                                              Specialization->getDefinition());
   if (!Def)
     InstantiateClassTemplateSpecialization(TemplateNameLoc, Specialization, TSK);
   
   // Instantiate the members of this class template specialization.
   Def = cast_or_null<ClassTemplateSpecializationDecl>(
-                                       Specialization->getDefinition(Context));
+                                       Specialization->getDefinition());
   if (Def)
     InstantiateClassTemplateSpecializationMembers(TemplateNameLoc, Def, TSK);
 
@@ -4408,7 +4408,7 @@ Sema::ActOnExplicitInstantiation(Scope *S,
   // Verify that it is okay to explicitly instantiate here.
   CXXRecordDecl *PrevDecl 
     = cast_or_null<CXXRecordDecl>(Record->getPreviousDeclaration());
-  if (!PrevDecl && Record->getDefinition(Context))
+  if (!PrevDecl && Record->getDefinition())
     PrevDecl = Record;
   if (PrevDecl) {
     MemberSpecializationInfo *MSInfo = PrevDecl->getMemberSpecializationInfo();
@@ -4425,13 +4425,13 @@ Sema::ActOnExplicitInstantiation(Scope *S,
   }
   
   CXXRecordDecl *RecordDef
-    = cast_or_null<CXXRecordDecl>(Record->getDefinition(Context));
+    = cast_or_null<CXXRecordDecl>(Record->getDefinition());
   if (!RecordDef) {
     // C++ [temp.explicit]p3:
     //   A definition of a member class of a class template shall be in scope 
     //   at the point of an explicit instantiation of the member class.
     CXXRecordDecl *Def 
-      = cast_or_null<CXXRecordDecl>(Pattern->getDefinition(Context));
+      = cast_or_null<CXXRecordDecl>(Pattern->getDefinition());
     if (!Def) {
       Diag(TemplateLoc, diag::err_explicit_instantiation_undefined_member)
         << 0 << Record->getDeclName() << Record->getDeclContext();
@@ -4444,7 +4444,7 @@ Sema::ActOnExplicitInstantiation(Scope *S,
                            TSK))
         return true;
 
-      RecordDef = cast_or_null<CXXRecordDecl>(Record->getDefinition(Context));
+      RecordDef = cast_or_null<CXXRecordDecl>(Record->getDefinition());
       if (!RecordDef)
         return true;
     }
index 99c1de619817bfe14781a96f380f30ef4ccdc633..0dd7990f504ee7a6985791165d5b57587fdf2ba6 100644 (file)
@@ -1054,7 +1054,7 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation,
   bool Invalid = false;
 
   CXXRecordDecl *PatternDef
-    = cast_or_null<CXXRecordDecl>(Pattern->getDefinition(Context));
+    = cast_or_null<CXXRecordDecl>(Pattern->getDefinition());
   if (!PatternDef) {
     if (!Complain) {
       // Say nothing
@@ -1397,8 +1397,8 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation,
       CXXRecordDecl *Pattern = Record->getInstantiatedFromMemberClass();
       assert(Pattern && "Missing instantiated-from-template information");
       
-      if (!Record->getDefinition(Context)) {
-        if (!Pattern->getDefinition(Context)) {
+      if (!Record->getDefinition()) {
+        if (!Pattern->getDefinition()) {
           // C++0x [temp.explicit]p8:
           //   An explicit instantiation definition that names a class template
           //   specialization explicitly instantiates the class template 
@@ -1418,7 +1418,7 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation,
                          TSK);
       }
       
-      Pattern = cast_or_null<CXXRecordDecl>(Record->getDefinition(Context));
+      Pattern = cast_or_null<CXXRecordDecl>(Record->getDefinition());
       if (Pattern)
         InstantiateClassMembers(PointOfInstantiation, Pattern, TemplateArgs, 
                                 TSK);
index 920c5ec0702b08042ecc3230e98b19bceb430bcb..dc1608bbc8bee3cdf820a971c55ab8d3fc9546e3 100644 (file)
@@ -1719,7 +1719,7 @@ CXCursor clang_getCursorDefinition(CXCursor C) {
   case Decl::CXXRecord:
   case Decl::ClassTemplateSpecialization:
   case Decl::ClassTemplatePartialSpecialization:
-    if (TagDecl *Def = cast<TagDecl>(D)->getDefinition(D->getASTContext()))
+    if (TagDecl *Def = cast<TagDecl>(D)->getDefinition())
       return MakeCXCursor(Def, CXXUnit);
     return clang_getNullCursor();
 
@@ -1750,7 +1750,7 @@ CXCursor clang_getCursorDefinition(CXCursor C) {
    
   case Decl::ClassTemplate: {
     if (RecordDecl *Def = cast<ClassTemplateDecl>(D)->getTemplatedDecl()
-                                          ->getDefinition(D->getASTContext()))
+                                                            ->getDefinition())
       return MakeCXCursor(
                          cast<CXXRecordDecl>(Def)->getDescribedClassTemplate(), 
                           CXXUnit);