diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-08-07 21:35:41 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-08-07 21:35:41 +0000 |
commit | 873b2e201a66ae7243aef8e96642f375a9d3ca25 (patch) | |
tree | e6300388f4570c07001c299a7c87a2286d462ee6 /lib/Sema/SemaCXXScopeSpec.cpp | |
parent | 493ce822337498f4b3fc2d8835ba97cd7e6622d0 (diff) | |
download | clang-873b2e201a66ae7243aef8e96642f375a9d3ca25.tar.gz |
Clean up and simplify RequireCompleteType.
No functional change intended, except that we will now produce more
"declared here" notes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339187 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCXXScopeSpec.cpp')
-rw-r--r-- | lib/Sema/SemaCXXScopeSpec.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/Sema/SemaCXXScopeSpec.cpp b/lib/Sema/SemaCXXScopeSpec.cpp index 4e39d06754..2354ffe7fb 100644 --- a/lib/Sema/SemaCXXScopeSpec.cpp +++ b/lib/Sema/SemaCXXScopeSpec.cpp @@ -209,11 +209,13 @@ bool Sema::RequireCompleteDeclContext(CXXScopeSpec &SS, if (!tag || tag->isDependentContext()) return false; + // Grab the tag definition, if there is one. + QualType type = Context.getTypeDeclType(tag); + tag = type->getAsTagDecl(); + // If we're currently defining this type, then lookup into the // type is okay: don't complain that it isn't complete yet. - QualType type = Context.getTypeDeclType(tag); - const TagType *tagType = type->getAs<TagType>(); - if (tagType && tagType->isBeingDefined()) + if (tag->isBeingDefined()) return false; SourceLocation loc = SS.getLastQualifierNameLoc(); @@ -229,13 +231,13 @@ bool Sema::RequireCompleteDeclContext(CXXScopeSpec &SS, // Fixed enum types are complete, but they aren't valid as scopes // until we see a definition, so awkwardly pull out this special // case. - const EnumType *enumType = dyn_cast_or_null<EnumType>(tagType); - if (!enumType) + auto *EnumD = dyn_cast<EnumDecl>(tag); + if (!EnumD) return false; - if (enumType->getDecl()->isCompleteDefinition()) { + if (EnumD->isCompleteDefinition()) { // If we know about the definition but it is not visible, complain. NamedDecl *SuggestedDef = nullptr; - if (!hasVisibleDefinition(enumType->getDecl(), &SuggestedDef, + if (!hasVisibleDefinition(EnumD, &SuggestedDef, /*OnlyNeedComplete*/false)) { // If the user is going to see an error here, recover by making the // definition visible. @@ -249,11 +251,11 @@ bool Sema::RequireCompleteDeclContext(CXXScopeSpec &SS, // Try to instantiate the definition, if this is a specialization of an // enumeration temploid. - EnumDecl *ED = enumType->getDecl(); - if (EnumDecl *Pattern = ED->getInstantiatedFromMemberEnum()) { - MemberSpecializationInfo *MSI = ED->getMemberSpecializationInfo(); + if (EnumDecl *Pattern = EnumD->getInstantiatedFromMemberEnum()) { + MemberSpecializationInfo *MSI = EnumD->getMemberSpecializationInfo(); if (MSI->getTemplateSpecializationKind() != TSK_ExplicitSpecialization) { - if (InstantiateEnum(loc, ED, Pattern, getTemplateInstantiationArgs(ED), + if (InstantiateEnum(loc, EnumD, Pattern, + getTemplateInstantiationArgs(EnumD), TSK_ImplicitInstantiation)) { SS.SetInvalid(SS.getRange()); return true; |