diff options
Diffstat (limited to 'include/clang/AST/Decl.h')
-rw-r--r-- | include/clang/AST/Decl.h | 95 |
1 files changed, 10 insertions, 85 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index f2cb672bb8..bdc91a168e 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -99,25 +99,10 @@ class NamedDecl : public Decl { /// constructor, Objective-C selector, etc.) DeclarationName Name; - /// \brief Whether we have already cached linkage and visibility. - mutable unsigned HasLinkageAndVisibilityCached : 1; - - /// \brief The cached visibility, if \c HasLinkageAndVisibilityCached is - /// non-zero. - mutable unsigned CachedVisibility : 2; - - /// \brief Whether the cached visibility was explicitly placed on this - /// declaration. - mutable unsigned CachedVisibilityIsExplicit : 1; - - /// \brief The cached linkage, if \c HasLinkageAndVisibilityCached is - /// non-zero. - mutable unsigned CachedLinkage : 2; - protected: NamedDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N) - : Decl(DK, DC, L), Name(N), HasLinkageAndVisibilityCached(0) { } - + : Decl(DK, DC, L), Name(N) { } + public: /// getIdentifier - Get the identifier that names this declaration, /// if there is one. This will return NULL if this declaration has @@ -287,13 +272,6 @@ public: /// \brief Determines the linkage and visibility of this entity. LinkageInfo getLinkageAndVisibility() const; - /// \brief Clear the linkage and visibility cache in response to a change - /// to the declaration. - /// - /// \param Redeclarations When true, we also have to clear out the linkage - /// and visibility cache for all redeclarations. - void ClearLinkageAndVisibilityCache(); - /// \brief Looks through UsingDecls and ObjCCompatibleAliasDecls for /// the underlying named decl. NamedDecl *getUnderlyingDecl(); @@ -647,8 +625,6 @@ private: bool NRVOVariable : 1; friend class StmtIteratorBase; - friend class ASTDeclReader; - protected: VarDecl(Kind DK, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass SC, @@ -684,7 +660,10 @@ public: StorageClass getStorageClassAsWritten() const { return (StorageClass) SClassAsWritten; } - void setStorageClass(StorageClass SC); + void setStorageClass(StorageClass SC) { + assert(isLegalForVariable(SC)); + SClass = SC; + } void setStorageClassAsWritten(StorageClass SC) { assert(isLegalForVariable(SC)); SClassAsWritten = SC; @@ -1499,7 +1478,10 @@ public: } StorageClass getStorageClass() const { return StorageClass(SClass); } - void setStorageClass(StorageClass SC); + void setStorageClass(StorageClass SC) { + assert(isLegalForFunction(SC)); + SClass = SC; + } StorageClass getStorageClassAsWritten() const { return StorageClass(SClassAsWritten); @@ -2576,63 +2558,6 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, return DB; } -template<typename decl_type> -void Redeclarable<decl_type>::setPreviousDeclaration(decl_type *PrevDecl) { - // Note: This routine is implemented here because we need both NamedDecl - // and Redeclarable to be defined. - decl_type *First; - - if (PrevDecl) { - // Point to previous. Make sure that this is actually the most recent - // redeclaration, or we can build invalid chains. If the most recent - // redeclaration is invalid, it won't be PrevDecl, but we want it anyway. - RedeclLink = PreviousDeclLink(llvm::cast<decl_type>( - PrevDecl->getMostRecentDeclaration())); - First = PrevDecl->getFirstDeclaration(); - assert(First->RedeclLink.NextIsLatest() && "Expected first"); - } else { - // Make this first. - First = static_cast<decl_type*>(this); - } - - // First one will point to this one as latest. - First->RedeclLink = LatestDeclLink(static_cast<decl_type*>(this)); - - // If this declaration has a visibility attribute that differs from the - // previous visibility attribute, or has private extern storage while the - // previous declaration merely had extern storage, clear out the linkage and - ///visibility cache. This is required because declarations after the first - // declaration can change the visibility for all previous and future - // declarations. - if (NamedDecl *ND = dyn_cast<NamedDecl>(static_cast<decl_type*>(this))) { - bool MustClear = false; - if (VisibilityAttr *Visibility = ND->getAttr<VisibilityAttr>()) { - VisibilityAttr *PrevVisibility - = PrevDecl->template getAttr<VisibilityAttr>(); - if (!PrevVisibility || - PrevVisibility->getVisibility() != Visibility->getVisibility()) - MustClear = true; - } - - if (!MustClear) { - if (VarDecl *VD = dyn_cast<VarDecl>(ND)) { - if (VD->getStorageClass() != cast<VarDecl>(PrevDecl)->getStorageClass()) - MustClear = true; - } else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) { - FunctionDecl *PrevFD = cast<FunctionDecl>(PrevDecl); - if (FD->getStorageClass() != PrevFD->getStorageClass()) - MustClear = true; - else if (FD->isInlineSpecified() && !PrevFD->isInlined()) - MustClear = true; - } - } - - if (MustClear) - ND->ClearLinkageAndVisibilityCache(); - } -} - - } // end namespace clang #endif |