]> granicus.if.org Git - clang/commitdiff
Rename Sema::hasSameType to QualType::isSameAs
authorDouglas Gregor <dgregor@apple.com>
Wed, 11 Feb 2009 16:47:37 +0000 (16:47 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 11 Feb 2009 16:47:37 +0000 (16:47 +0000)
Rename Sema::hasSameUnqualifiedType to QualType::isSameIgnoringQalifiers

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64307 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Type.h
lib/Sema/Sema.h
lib/Sema/SemaTemplate.cpp
lib/Sema/SemaType.cpp

index 39e1495cd923fe7a791e9b141bf0c0151750ff2c..9d3f2c98bc0d0467be68ca0f3445ba9e95321e8c 100644 (file)
@@ -155,6 +155,8 @@ 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;
@@ -1700,6 +1702,23 @@ 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
index 5ee14faaca7ba6d8851812eb855f4b3506b8e715..b11cc76cee01024fa6889770ba54096dc8972edf 100644 (file)
@@ -281,9 +281,6 @@ public:
                               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.
   //
index d816151ef270a3cb52bcb270f926ebe798205ef4..86f1e2017f19e662b0d035c41e49bdca307d0c7a 100644 (file)
@@ -919,7 +919,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
       (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 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
       }
     }
 
-    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 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
       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 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
     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 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
   //        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);
index 7049a301f72b804d9537293233b30ceb78f9a9d5..e898782f31d80c0f97c3caf47e4ba16217f18245 100644 (file)
@@ -835,17 +835,3 @@ bool Sema::DiagnoseIncompleteType(SourceLocation Loc, QualType T, unsigned diag,
 
   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();
-}
-