diff options
| author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2010-08-02 18:27:05 +0000 |
|---|---|---|
| committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2010-08-02 18:27:05 +0000 |
| commit | 9d8854ec6014b3cb9db87f7a385e9000cfa3ef5b (patch) | |
| tree | d9d782dc87e8f5383fd6524d34e6ac4dd59816a0 /clang/lib | |
| parent | 9c6a39e8628970a2d5d2ca443b6a2ab17bbf0aea (diff) | |
| download | bcm5719-llvm-9d8854ec6014b3cb9db87f7a385e9000cfa3ef5b.tar.gz bcm5719-llvm-9d8854ec6014b3cb9db87f7a385e9000cfa3ef5b.zip | |
Remove mutable data on TagType and InjectedClassNameType, by instead walking the declaration chain in search of a definition. This is necessary for a sane chained PCH implementation. No observable performance change on Carbon.h syntax-only, and bootstraps cleanly.
llvm-svn: 110051
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/Decl.cpp | 21 | ||||
| -rw-r--r-- | clang/lib/AST/Type.cpp | 25 |
2 files changed, 26 insertions, 20 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index a30a4303824..0e0bbf34a1a 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -1534,14 +1534,7 @@ void TagDecl::setTypedefForAnonDecl(TypedefDecl *TDD) { } void TagDecl::startDefinition() { - if (TagType *TagT = const_cast<TagType *>(TypeForDecl->getAs<TagType>())) { - TagT->decl.setPointer(this); - TagT->decl.setInt(1); - } else if (InjectedClassNameType *Injected - = const_cast<InjectedClassNameType *>( - TypeForDecl->getAs<InjectedClassNameType>())) { - Injected->Decl = cast<CXXRecordDecl>(this); - } + IsBeingDefined = true; if (isa<CXXRecordDecl>(this)) { CXXRecordDecl *D = cast<CXXRecordDecl>(this); @@ -1558,17 +1551,7 @@ void TagDecl::completeDefinition() { "definition completed but not started"); IsDefinition = true; - if (TagType *TagT = const_cast<TagType *>(TypeForDecl->getAs<TagType>())) { - assert(TagT->decl.getPointer() == this && - "Attempt to redefine a tag definition?"); - TagT->decl.setInt(0); - } else if (InjectedClassNameType *Injected - = const_cast<InjectedClassNameType *>( - TypeForDecl->getAs<InjectedClassNameType>())) { - assert(Injected->Decl == this && - "Attempt to redefine a class template definition?"); - (void)Injected; - } + IsBeingDefined = false; } TagDecl* TagDecl::getDefinition() const { diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index 49d579f4a0b..1085efec19b 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -1072,7 +1072,30 @@ void DependentDecltypeType::Profile(llvm::FoldingSetNodeID &ID, TagType::TagType(TypeClass TC, const TagDecl *D, QualType can) : Type(TC, can, D->isDependentType()), - decl(const_cast<TagDecl*>(D), 0) {} + decl(const_cast<TagDecl*>(D)) {} + +static TagDecl *getInterestingTagDecl(TagDecl *decl) { + for (TagDecl::redecl_iterator I = decl->redecls_begin(), + E = decl->redecls_end(); + I != E; ++I) { + if (I->isDefinition() || I->isBeingDefined()) + return *I; + } + // If there's no definition (not even in progress), return what we have. + return decl; +} + +TagDecl *TagType::getDecl() const { + return getInterestingTagDecl(decl); +} + +bool TagType::isBeingDefined() const { + return getDecl()->isBeingDefined(); +} + +CXXRecordDecl *InjectedClassNameType::getDecl() const { + return cast<CXXRecordDecl>(getInterestingTagDecl(Decl)); +} bool RecordType::classof(const TagType *TT) { return isa<RecordDecl>(TT->getDecl()); |

