diff options
author | John McCall <rjmccall@apple.com> | 2009-09-29 23:03:30 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2009-09-29 23:03:30 +0000 |
commit | bf1cc05907ceb2081e8158b26f3d3f48b31caad3 (patch) | |
tree | bca78feafa7d2dfa963070e2c2db681971722dd7 /lib/Sema | |
parent | 1070c9f7acc889336be6f80c70dc1b32622cc83d (diff) |
Desugaring optimizations. Add single-step desugaring methods to all
concrete types. Use unqualified desugaring for getAs<> and sundry.
Fix a few users to either not desugar or use qualified desugar, as seemed
appropriate. Removed Type's qualified desugar method, as it was easy
to accidentally use instead of QualType's.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83116 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/Sema.cpp | 13 | ||||
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 6 |
2 files changed, 13 insertions, 6 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 81f7283e23..3aae2563d1 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -44,16 +44,23 @@ static void ConvertArgToStringFn(Diagnostic::ArgumentKind Kind, intptr_t Val, // If this is a sugared type (like a typedef, typeof, etc), then unwrap one // level of the sugar so that the type is more obvious to the user. - QualType DesugaredTy = Ty.getDesugaredType(true); + QualType DesugaredTy = Ty.getDesugaredType(); if (Ty != DesugaredTy && // If the desugared type is a vector type, we don't want to expand it, // it will turn into an attribute mess. People want their "vec4". !isa<VectorType>(DesugaredTy) && - // Don't aka just because we saw an elaborated type. + // Don't aka just because we saw an elaborated type... (!isa<ElaboratedType>(Ty) || - cast<ElaboratedType>(Ty)->getUnderlyingType() != DesugaredTy) && + cast<ElaboratedType>(Ty)->desugar() != DesugaredTy) && + + // ...or a qualified name type... + (!isa<QualifiedNameType>(Ty) || + cast<QualifiedNameType>(Ty)->desugar() != DesugaredTy) && + + // ...or a non-dependent template specialization. + (!isa<TemplateSpecializationType>(Ty) || Ty->isDependentType()) && // Don't desugar magic Objective-C types. Ty.getUnqualifiedType() != Context.getObjCIdType() && diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 7aa0261ff6..223662afce 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -1267,7 +1267,7 @@ void Sema::ActOnMemInitializers(DeclPtrTy ConstructorDecl, assert(BaseClass && "ActOnMemInitializers - neither field or base"); Diag(Member->getSourceLocation(), diag::error_multiple_base_initialization) - << BaseClass->getDesugaredType(true); + << QualType(BaseClass, 0); } Diag(PrevMember->getSourceLocation(), diag::note_previous_initializer) << 0; @@ -1336,7 +1336,7 @@ void Sema::ActOnMemInitializers(DeclPtrTy ConstructorDecl, Type *BaseClass = PrevMember->getBaseClass(); Diag(PrevMember->getSourceLocation(), diag::warn_base_initialized) - << BaseClass->getDesugaredType(true); + << QualType(BaseClass, 0); } else { FieldDecl *Field = PrevMember->getMember(); Diag(PrevMember->getSourceLocation(), @@ -1352,7 +1352,7 @@ void Sema::ActOnMemInitializers(DeclPtrTy ConstructorDecl, Type *BaseClass = Member->getBaseClass(); Diag(Member->getSourceLocation(), diag::note_fieldorbase_initialized_here) << 1 - << BaseClass->getDesugaredType(true); + << QualType(BaseClass, 0); } for (curIndex = 0; curIndex < Last; curIndex++) if (MemberInCtorList == AllBaseOrMembers[curIndex]) |