From 5b21db89d04f6b0923e333b55f8c500e968243f7 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 23 Apr 2014 18:20:42 +0000 Subject: Make TypeDecl much less friendly. llvm-svn: 207007 --- clang/lib/AST/DeclBase.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'clang/lib/AST/DeclBase.cpp') 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(this); - assert(isa(Tag->TypeForDecl) || - isa(Tag->TypeForDecl)); if (TagDecl *Def = Tag->getDefinition()) return Def; - if (!isa(Tag->TypeForDecl)) { - const TagType *TagTy = cast(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(Tag->getTypeForDecl())) { + // Note, TagType::getDecl returns the (partial) definition one exists. + TagDecl *PossiblePartialDef = TagTy->getDecl(); + if (PossiblePartialDef->isBeingDefined()) + return PossiblePartialDef; + } else { + assert(isa(Tag->getTypeForDecl())); } return Tag; -- cgit v1.2.3