diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2009-12-29 07:16:59 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2009-12-29 07:16:59 +0000 |
commit | 28e318cc6008c2bc008f0caee70dc736a03d6289 (patch) | |
tree | 4974fee65ebbb9fe424d960de3830072247da3ae /lib/AST/ASTContext.cpp | |
parent | f5f7d864f5067d1ea4bff7fcf41b53a43b7b48ba (diff) |
Correctly refer to element CVR qualifications when determining if a type is
more or less cv-qualified than another during implicit conversion and overload
resolution ([basic.type.qualifier] p5). Factors the logic out of template
deduction and into the ASTContext so it can be shared.
This fixes several aspects of PR5542, but not all of them.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92248 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r-- | lib/AST/ASTContext.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 4bfea2421c..fe96280609 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -2372,6 +2372,36 @@ CanQualType ASTContext::getCanonicalType(QualType T) { VAT->getBracketsRange())); } +QualType ASTContext::getUnqualifiedArrayType(QualType T, + Qualifiers &Quals) { + assert(T.isCanonical() && "Only operates on canonical types"); + if (!isa<ArrayType>(T)) { + Quals = T.getLocalQualifiers(); + return T.getLocalUnqualifiedType(); + } + + assert(!T.hasQualifiers() && "canonical array type has qualifiers!"); + const ArrayType *AT = cast<ArrayType>(T); + QualType Elt = AT->getElementType(); + QualType UnqualElt = getUnqualifiedArrayType(Elt, Quals); + if (Elt == UnqualElt) + return T; + + if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(T)) { + return getConstantArrayType(UnqualElt, CAT->getSize(), + CAT->getSizeModifier(), 0); + } + + if (const IncompleteArrayType *IAT = dyn_cast<IncompleteArrayType>(T)) { + return getIncompleteArrayType(UnqualElt, IAT->getSizeModifier(), 0); + } + + const DependentSizedArrayType *DSAT = cast<DependentSizedArrayType>(T); + return getDependentSizedArrayType(UnqualElt, DSAT->getSizeExpr()->Retain(), + DSAT->getSizeModifier(), 0, + SourceRange()); +} + DeclarationName ASTContext::getNameForTemplate(TemplateName Name) { if (TemplateDecl *TD = Name.getAsTemplateDecl()) return TD->getDeclName(); |