diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-11-16 21:35:15 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-11-16 21:35:15 +0000 |
commit | a4923eb7c4b04d360cb2747641a5e92818edf804 (patch) | |
tree | 573c9d43fd0b6daf0f1d5ee02ebbffd7e3e84cfd /lib/Sema/SemaTemplateDeduction.cpp | |
parent | ad35a83102683b00a7e28707eee7f2d8c994b742 (diff) |
First part of changes to eliminate problems with cv-qualifiers and
sugared types. The basic problem is that our qualifier accessors
(getQualifiers, getCVRQualifiers, isConstQualified, etc.) only look at
the current QualType and not at any qualifiers that come from sugared
types, meaning that we won't see these qualifiers through, e.g.,
typedefs:
typedef const int CInt;
typedef CInt Self;
Self.isConstQualified() currently returns false!
Various bugs (e.g., PR5383) have cropped up all over the front end due
to such problems. I'm addressing this problem by splitting each
qualifier accessor into two versions:
- the "local" version only returns qualifiers on this particular
QualType instance
- the "normal" version that will eventually combine qualifiers from this
QualType instance with the qualifiers on the canonical type to
produce the full set of qualifiers.
This commit adds the local versions and switches a few callers from
the "normal" version (e.g., isConstQualified) over to the "local"
version (e.g., isLocalConstQualified) when that is the right thing to
do, e.g., because we're printing or serializing the qualifiers. Also,
switch a bunch of
Context.getCanonicalType(T1).getUnqualifiedType() == Context.getCanonicalType(T2).getQualifiedType()
expressions over to
Context.hasSameUnqualifiedType(T1, T2)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88969 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateDeduction.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateDeduction.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp index 244bb37c37..10594c728f 100644 --- a/lib/Sema/SemaTemplateDeduction.cpp +++ b/lib/Sema/SemaTemplateDeduction.cpp @@ -354,8 +354,8 @@ static QualType getUnqualifiedArrayType(ASTContext &Context, QualType T, Qualifiers &Quals) { assert(T.isCanonical() && "Only operates on canonical types"); if (!isa<ArrayType>(T)) { - Quals = T.getQualifiers(); - return T.getUnqualifiedType(); + Quals = T.getLocalQualifiers(); + return T.getLocalUnqualifiedType(); } assert(!T.hasQualifiers() && "canonical array type has qualifiers!"); @@ -1440,16 +1440,16 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, // - If A is a cv-qualified type, the top level cv-qualifiers of A’s // type are ignored for type deduction. QualType CanonArgType = Context.getCanonicalType(ArgType); - if (CanonArgType.getCVRQualifiers()) - ArgType = CanonArgType.getUnqualifiedType(); + if (CanonArgType.getLocalCVRQualifiers()) + ArgType = CanonArgType.getLocalUnqualifiedType(); } } // C++0x [temp.deduct.call]p3: // If P is a cv-qualified type, the top level cv-qualifiers of P’s type // are ignored for type deduction. - if (CanonParamType.getCVRQualifiers()) - ParamType = CanonParamType.getUnqualifiedType(); + if (CanonParamType.getLocalCVRQualifiers()) + ParamType = CanonParamType.getLocalUnqualifiedType(); if (const ReferenceType *ParamRefType = ParamType->getAs<ReferenceType>()) { // [...] If P is a reference type, the type referred to by P is used // for type deduction. |