diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-04-23 18:20:42 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-04-23 18:20:42 +0000 |
commit | 5b21db89d04f6b0923e333b55f8c500e968243f7 (patch) | |
tree | f978e5213a735c156c7f00f199cf0bbd5ec3dc80 /clang/lib | |
parent | 36e997ff804ff6959e4e5f50380acdad426481e8 (diff) | |
download | bcm5719-llvm-5b21db89d04f6b0923e333b55f8c500e968243f7.tar.gz bcm5719-llvm-5b21db89d04f6b0923e333b55f8c500e968243f7.zip |
Make TypeDecl much less friendly.
llvm-svn: 207007
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/Decl.cpp | 4 | ||||
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 15 | ||||
-rw-r--r-- | clang/lib/AST/DeclTemplate.cpp | 8 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 2 |
4 files changed, 14 insertions, 15 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index dd7b0c81941..f3a4ff33b9b 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -3202,8 +3202,8 @@ TagDecl *TagDecl::getCanonicalDecl() { return getFirstDecl(); } void TagDecl::setTypedefNameForAnonDecl(TypedefNameDecl *TDD) { NamedDeclOrQualifier = TDD; - if (TypeForDecl) - assert(TypeForDecl->isLinkageValid()); + if (const Type *T = getTypeForDecl()) + assert(T->isLinkageValid()); assert(isLinkageValid()); } diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index c12f53c6766..f15639130a2 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -900,18 +900,17 @@ DeclContext *DeclContext::getPrimaryContext() { // If this is a tag type that has a definition or is currently // being defined, that definition is our primary context. TagDecl *Tag = cast<TagDecl>(this); - assert(isa<TagType>(Tag->TypeForDecl) || - isa<InjectedClassNameType>(Tag->TypeForDecl)); if (TagDecl *Def = Tag->getDefinition()) return Def; - if (!isa<InjectedClassNameType>(Tag->TypeForDecl)) { - const TagType *TagTy = cast<TagType>(Tag->TypeForDecl); - if (TagTy->isBeingDefined()) - // FIXME: is it necessarily being defined in the decl - // that owns the type? - return TagTy->getDecl(); + if (const TagType *TagTy = dyn_cast<TagType>(Tag->getTypeForDecl())) { + // Note, TagType::getDecl returns the (partial) definition one exists. + TagDecl *PossiblePartialDef = TagTy->getDecl(); + if (PossiblePartialDef->isBeingDefined()) + return PossiblePartialDef; + } else { + assert(isa<InjectedClassNameType>(Tag->getTypeForDecl())); } return Tag; diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp index fc73e6f4125..408e8548b1d 100644 --- a/clang/lib/AST/DeclTemplate.cpp +++ b/clang/lib/AST/DeclTemplate.cpp @@ -472,7 +472,7 @@ TemplateTypeParmDecl::Create(const ASTContext &C, DeclContext *DC, TemplateTypeParmDecl *TTPDecl = new (C, DC) TemplateTypeParmDecl(DC, KeyLoc, NameLoc, Id, Typename); QualType TTPType = C.getTemplateTypeParmType(D, P, ParameterPack, TTPDecl); - TTPDecl->TypeForDecl = TTPType.getTypePtr(); + TTPDecl->setTypeForDecl(TTPType.getTypePtr()); return TTPDecl; } @@ -497,15 +497,15 @@ SourceRange TemplateTypeParmDecl::getSourceRange() const { } unsigned TemplateTypeParmDecl::getDepth() const { - return TypeForDecl->getAs<TemplateTypeParmType>()->getDepth(); + return getTypeForDecl()->getAs<TemplateTypeParmType>()->getDepth(); } unsigned TemplateTypeParmDecl::getIndex() const { - return TypeForDecl->getAs<TemplateTypeParmType>()->getIndex(); + return getTypeForDecl()->getAs<TemplateTypeParmType>()->getIndex(); } bool TemplateTypeParmDecl::isParameterPack() const { - return TypeForDecl->getAs<TemplateTypeParmType>()->isParameterPack(); + return getTypeForDecl()->getAs<TemplateTypeParmType>()->isParameterPack(); } //===----------------------------------------------------------------------===// diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 14075462bec..44e98f94c8f 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -8019,7 +8019,7 @@ void ASTReader::finishPendingActions() { DEnd = PendingDefinitions.end(); D != DEnd; ++D) { if (TagDecl *TD = dyn_cast<TagDecl>(*D)) { - if (const TagType *TagT = dyn_cast<TagType>(TD->TypeForDecl)) { + if (const TagType *TagT = dyn_cast<TagType>(TD->getTypeForDecl())) { // Make sure that the TagType points at the definition. const_cast<TagType*>(TagT)->decl = TD; } |