aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-02-11 18:22:40 +0000
committerDouglas Gregor <dgregor@apple.com>2009-02-11 18:22:40 +0000
commit8e6563ba097732dc1fffcfc85f8dbbceac899a80 (patch)
tree83d8fc9d910746dfb98a4434075ea1c0f5dd9cfc
parent62cb18dd11472965e03374d40bc27d650bc331b6 (diff)
Reverted r64307. Moved hasSameType and hasSameUnqualifiedType from
Sema to ASTContext. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64312 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/ASTContext.h13
-rw-r--r--include/clang/AST/Type.h19
-rw-r--r--lib/Sema/SemaTemplate.cpp10
3 files changed, 18 insertions, 24 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h
index 2329ff5fe8..a0caf4f4b7 100644
--- a/include/clang/AST/ASTContext.h
+++ b/include/clang/AST/ASTContext.h
@@ -463,6 +463,19 @@ public:
return T->getCanonicalTypeInternal().getTypePtr();
}
+ /// \brief Determine whether the given types are equivalent.
+ bool hasSameType(QualType T1, QualType T2) {
+ return getCanonicalType(T1) == getCanonicalType(T2);
+ }
+
+ /// \brief Determine whether the given types are equivalent after
+ /// cvr-qualifiers have been removed.
+ bool hasSameUnqualifiedType(QualType T1, QualType T2) {
+ T1 = getCanonicalType(T1);
+ T2 = getCanonicalType(T2);
+ return T1.getUnqualifiedType() == T2.getUnqualifiedType();
+ }
+
/// \brief Retrieves the "canonical" declaration of the given tag
/// declaration.
///
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index 9d3f2c98bc..39e1495cd9 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -155,8 +155,6 @@ public:
QualType withRestrict() const { return getWithAdditionalQualifiers(Restrict);}
QualType getUnqualifiedType() const;
- bool isSameAs(QualType Other) const;
- bool isSameIgnoringQualifiers(QualType Other) const;
bool isMoreQualifiedThan(QualType Other) const;
bool isAtLeastAsQualifiedAs(QualType Other) const;
QualType getNonReferenceType() const;
@@ -1702,23 +1700,6 @@ inline unsigned QualType::getAddressSpace() const {
return 0;
}
-/// \brief Determine whether this type and Other represent the same type.
-inline bool QualType::isSameAs(QualType Other) const {
- return getTypePtr()->getCanonicalTypeInternal() ==
- Other.getTypePtr()->getCanonicalTypeInternal();
-}
-
-/// \brief Determine whether the unqualified forms of this type and
-/// Other represent the same type.
-///
-/// Only top-level CVR qualifiers are stripped.
-inline bool
-QualType::isSameIgnoringQualifiers(QualType Other) const {
- QualType ThisCanon = getTypePtr()->getCanonicalTypeInternal();
- QualType OtherCanon = Other->getCanonicalTypeInternal();
- return ThisCanon.getUnqualifiedType() == OtherCanon.getUnqualifiedType();
-}
-
/// isMoreQualifiedThan - Determine whether this type is more
/// qualified than the Other type. For example, "const volatile int"
/// is more qualified than "const int", "volatile int", and
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index b4436a2c3c..5fe592d5e3 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -920,7 +920,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
(ParamType->isMemberPointerType() &&
ParamType->getAsMemberPointerType()->getPointeeType()
->isFunctionType())) {
- if (ArgType.isSameIgnoringQualifiers(ParamType.getNonReferenceType())) {
+ if (Context.hasSameUnqualifiedType(ArgType, ParamType.getNonReferenceType())) {
// We don't have to do anything: the types already match.
} else if (ArgType->isFunctionType() && ParamType->isPointerType()) {
ArgType = Context.getPointerType(ArgType);
@@ -935,7 +935,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
}
}
- if (!ArgType.isSameIgnoringQualifiers(ParamType.getNonReferenceType())) {
+ if (!Context.hasSameUnqualifiedType(ArgType, ParamType.getNonReferenceType())) {
// We can't perform this conversion.
Diag(Arg->getSourceRange().getBegin(),
diag::err_template_arg_not_convertible)
@@ -965,7 +965,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
ImpCastExprToType(Arg, ParamType);
}
- if (!ArgType.isSameIgnoringQualifiers(ParamType)) {
+ if (!Context.hasSameUnqualifiedType(ArgType, ParamType)) {
// We can't perform this conversion.
Diag(Arg->getSourceRange().getBegin(),
diag::err_template_arg_not_convertible)
@@ -988,7 +988,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
assert(ParamRefType->getPointeeType()->isObjectType() &&
"Only object references allowed here");
- if (!ArgType.isSameIgnoringQualifiers(ParamRefType->getPointeeType())) {
+ if (!Context.hasSameUnqualifiedType(ParamRefType->getPointeeType(), ArgType)) {
Diag(Arg->getSourceRange().getBegin(),
diag::err_template_arg_no_ref_bind)
<< Param->getType() << Arg->getType()
@@ -1020,7 +1020,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
// member, qualification conversions (4.4) are applied.
assert(ParamType->isMemberPointerType() && "Only pointers to members remain");
- if (ParamType.isSameIgnoringQualifiers(ArgType)) {
+ if (Context.hasSameUnqualifiedType(ParamType, ArgType)) {
// Types match exactly: nothing more to do here.
} else if (IsQualificationConversion(ArgType, ParamType)) {
ImpCastExprToType(Arg, ParamType);