[cfe-commits] r64307 - in /cfe/trunk: include/clang/AST/Type.h lib/Sema/Sema.h lib/Sema/SemaTemplate.cpp lib/Sema/SemaType.cpp
Douglas Gregor
dgregor at apple.com
Wed Feb 11 08:47:37 PST 2009
Author: dgregor
Date: Wed Feb 11 10:47:37 2009
New Revision: 64307
URL: http://llvm.org/viewvc/llvm-project?rev=64307&view=rev
Log:
Rename Sema::hasSameType to QualType::isSameAs
Rename Sema::hasSameUnqualifiedType to QualType::isSameIgnoringQalifiers
Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaType.cpp
Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=64307&r1=64306&r2=64307&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed Feb 11 10:47:37 2009
@@ -155,6 +155,8 @@
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;
@@ -1700,6 +1702,23 @@
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
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=64307&r1=64306&r2=64307&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Wed Feb 11 10:47:37 2009
@@ -281,9 +281,6 @@
SourceRange Range2 = SourceRange(),
QualType PrintType = QualType());
- bool hasSameType(QualType T1, QualType T2);
- bool hasSameUnqualifiedType(QualType T1, QualType T2);
-
//===--------------------------------------------------------------------===//
// Symbol table / Decl tracking callbacks: SemaDecl.cpp.
//
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=64307&r1=64306&r2=64307&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Feb 11 10:47:37 2009
@@ -919,7 +919,7 @@
(ParamType->isMemberPointerType() &&
ParamType->getAsMemberPointerType()->getPointeeType()
->isFunctionType())) {
- if (hasSameUnqualifiedType(ArgType, ParamType.getNonReferenceType())) {
+ if (ArgType.isSameIgnoringQualifiers(ParamType.getNonReferenceType())) {
// We don't have to do anything: the types already match.
} else if (ArgType->isFunctionType() && ParamType->isPointerType()) {
ArgType = Context.getPointerType(ArgType);
@@ -934,7 +934,7 @@
}
}
- if (!hasSameUnqualifiedType(ArgType, ParamType.getNonReferenceType())) {
+ if (!ArgType.isSameIgnoringQualifiers(ParamType.getNonReferenceType())) {
// We can't perform this conversion.
Diag(Arg->getSourceRange().getBegin(),
diag::err_template_arg_not_convertible)
@@ -964,7 +964,7 @@
ImpCastExprToType(Arg, ParamType);
}
- if (!hasSameUnqualifiedType(ArgType, ParamType)) {
+ if (!ArgType.isSameIgnoringQualifiers(ParamType)) {
// We can't perform this conversion.
Diag(Arg->getSourceRange().getBegin(),
diag::err_template_arg_not_convertible)
@@ -987,7 +987,7 @@
assert(ParamRefType->getPointeeType()->isObjectType() &&
"Only object references allowed here");
- if (!hasSameUnqualifiedType(ParamRefType->getPointeeType(), ArgType)) {
+ if (!ArgType.isSameIgnoringQualifiers(ParamRefType->getPointeeType())) {
Diag(Arg->getSourceRange().getBegin(),
diag::err_template_arg_no_ref_bind)
<< Param->getType() << Arg->getType()
@@ -1019,7 +1019,7 @@
// member, qualification conversions (4.4) are applied.
assert(ParamType->isMemberPointerType() && "Only pointers to members remain");
- if (hasSameUnqualifiedType(ParamType, ArgType)) {
+ if (ParamType.isSameIgnoringQualifiers(ArgType)) {
// Types match exactly: nothing more to do here.
} else if (IsQualificationConversion(ArgType, ParamType)) {
ImpCastExprToType(Arg, ParamType);
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=64307&r1=64306&r2=64307&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed Feb 11 10:47:37 2009
@@ -835,17 +835,3 @@
return true;
}
-
-/// \brief Determine whether the given types are equivalent.
-bool Sema::hasSameType(QualType T1, QualType T2) {
- return Context.getCanonicalType(T1) == Context.getCanonicalType(T2);
-}
-
-/// \brief Determine whether the given types are equivalent after
-/// cvr-qualifiers have been removed.
-bool Sema::hasSameUnqualifiedType(QualType T1, QualType T2) {
- T1 = Context.getCanonicalType(T1);
- T2 = Context.getCanonicalType(T2);
- return T1.getUnqualifiedType() == T2.getUnqualifiedType();
-}
-
More information about the cfe-commits
mailing list