diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-12-06 17:49:01 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-12-06 17:49:01 +0000 |
commit | b5f35bae05f1ce3ae62ca52b266a086fd019e89b (patch) | |
tree | 1c1cf8fa52a6b48cadcd272ce140d704ffaf2963 /lib/AST/Decl.cpp | |
parent | d016ec204c54d766c4561d43548551ffde0e6b43 (diff) |
Revert r120808, my previous implementation of caching for the linkage
and visibility of declarations, because it was extremely messy and it
increased the size of NamedDecl.
An improved implementation is forthcoming.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121012 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r-- | lib/AST/Decl.cpp | 75 |
1 files changed, 2 insertions, 73 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index a8959b8d91..71bda4156f 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -526,57 +526,7 @@ static LinkageInfo getLVForClassMember(const NamedDecl *D, LVFlags F) { } LinkageInfo NamedDecl::getLinkageAndVisibility() const { - // If we have already cached linkage and visibility, just return the - // cached information. - if (HasLinkageAndVisibilityCached) { -#ifndef NDEBUG - LinkageInfo LI = getLVForDecl(this, LVFlags()); - assert(LI.visibility() == Visibility(CachedVisibility)); - assert(LI.visibilityExplicit() == CachedVisibilityIsExplicit); - assert(LI.linkage() == Linkage(CachedLinkage)); -#endif - return LinkageInfo(Linkage(CachedLinkage), Visibility(CachedVisibility), - CachedVisibilityIsExplicit); - } - - LinkageInfo LI = getLVForDecl(this, LVFlags()); - HasLinkageAndVisibilityCached = 1; - CachedVisibility = LI.visibility(); - CachedVisibilityIsExplicit = LI.visibilityExplicit(); - CachedLinkage = LI.linkage(); - return LI; -} - -void NamedDecl::ClearLinkageAndVisibilityCache() { - HasLinkageAndVisibilityCached = 0; - - if (VarDecl *VD = dyn_cast<VarDecl>(this)) { - for (VarDecl::redecl_iterator R = VD->redecls_begin(), - REnd = VD->redecls_end(); - R != REnd; ++R) - R->HasLinkageAndVisibilityCached = 0; - - return; - } - - if (FunctionDecl *FD = dyn_cast<FunctionDecl>(this)) { - for (FunctionDecl::redecl_iterator R = FD->redecls_begin(), - REnd = FD->redecls_end(); - R != REnd; ++R) - R->HasLinkageAndVisibilityCached = 0; - - return; - } - - // Changing the linkage or visibility of a C++ class affect the linkage and - // visibility of all of its members. Clear their caches, too. - if (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(this)) { - for (DeclContext::decl_iterator D = RD->decls_begin(), - DEnd = RD->decls_end(); - D != DEnd; ++D) - if (NamedDecl *ND = dyn_cast<NamedDecl>(*D)) - ND->ClearLinkageAndVisibilityCache(); - } + return getLVForDecl(this, LVFlags()); } static LinkageInfo getLVForDecl(const NamedDecl *D, LVFlags Flags) { @@ -928,14 +878,6 @@ VarDecl *VarDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, return new (C) VarDecl(Var, DC, L, Id, T, TInfo, S, SCAsWritten); } -void VarDecl::setStorageClass(StorageClass SC) { - assert(isLegalForVariable(SC)); - if (getStorageClass() != SC) - ClearLinkageAndVisibilityCache(); - - SClass = SC; -} - SourceLocation VarDecl::getInnerLocStart() const { SourceLocation Start = getTypeSpecStartLoc(); if (Start.isInvalid()) @@ -1154,7 +1096,6 @@ void VarDecl::setTemplateSpecializationKind(TemplateSpecializationKind TSK, PointOfInstantiation.isValid() && MSI->getPointOfInstantiation().isInvalid()) MSI->setPointOfInstantiation(PointOfInstantiation); - ClearLinkageAndVisibilityCache(); } //===----------------------------------------------------------------------===// @@ -1254,10 +1195,8 @@ Stmt *FunctionDecl::getBody(const FunctionDecl *&Definition) const { void FunctionDecl::setBody(Stmt *B) { Body = B; - if (B) { + if (B) EndRangeLoc = B->getLocEnd(); - ClearLinkageAndVisibilityCache(); - } } void FunctionDecl::setPure(bool P) { @@ -1338,14 +1277,6 @@ FunctionDecl *FunctionDecl::getCanonicalDecl() { return getFirstDeclaration(); } -void FunctionDecl::setStorageClass(StorageClass SC) { - assert(isLegalForFunction(SC)); - if (getStorageClass() != SC) - ClearLinkageAndVisibilityCache(); - - SClass = SC; -} - /// \brief Returns a value indicating whether this function /// corresponds to a builtin function. /// @@ -1778,7 +1709,6 @@ FunctionDecl::setTemplateSpecializationKind(TemplateSpecializationKind TSK, MSInfo->setPointOfInstantiation(PointOfInstantiation); } else assert(false && "Function cannot have a template specialization kind"); - ClearLinkageAndVisibilityCache(); } SourceLocation FunctionDecl::getPointOfInstantiation() const { @@ -1857,7 +1787,6 @@ void TagDecl::setTypedefForAnonDecl(TypedefDecl *TDD) { TypedefDeclOrQualifier = TDD; if (TypeForDecl) TypeForDecl->ClearLinkageCache(); - ClearLinkageAndVisibilityCache(); } void TagDecl::startDefinition() { |