summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclBase.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-04-23 18:20:42 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-04-23 18:20:42 +0000
commit5b21db89d04f6b0923e333b55f8c500e968243f7 (patch)
treef978e5213a735c156c7f00f199cf0bbd5ec3dc80 /clang/lib/AST/DeclBase.cpp
parent36e997ff804ff6959e4e5f50380acdad426481e8 (diff)
downloadbcm5719-llvm-5b21db89d04f6b0923e333b55f8c500e968243f7.tar.gz
bcm5719-llvm-5b21db89d04f6b0923e333b55f8c500e968243f7.zip
Make TypeDecl much less friendly.
llvm-svn: 207007
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r--clang/lib/AST/DeclBase.cpp15
1 files changed, 7 insertions, 8 deletions
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;
OpenPOWER on IntegriCloud