]> granicus.if.org Git - clang/commitdiff
Replace Type::getAsReferenceType() with Type::getAs<ReferenceType>().
authorTed Kremenek <kremenek@apple.com>
Fri, 17 Jul 2009 01:01:15 +0000 (01:01 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 17 Jul 2009 01:01:15 +0000 (01:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76132 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Type.h
lib/AST/ASTContext.cpp
lib/AST/Type.cpp
lib/Sema/SemaDeclCXX.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaNamedCast.cpp
lib/Sema/SemaOverload.cpp
lib/Sema/SemaTemplate.cpp
lib/Sema/SemaTemplateDeduction.cpp
lib/Sema/SemaType.cpp

index 3dee933fcfd6a489952897ff5c6e0a99586d0635..d1bf6929f6f9a2da220fcdf3f5478316011700ef 100644 (file)
@@ -431,7 +431,6 @@ public:
   const FunctionType *getAsFunctionType() const;
   const FunctionNoProtoType *getAsFunctionNoProtoType() const;
   const FunctionProtoType *getAsFunctionProtoType() const;
-  const ReferenceType *getAsReferenceType() const;
   const LValueReferenceType *getAsLValueReferenceType() const;
   const RValueReferenceType *getAsRValueReferenceType() const;
   const MemberPointerType *getAsMemberPointerType() const;
@@ -2105,7 +2104,7 @@ inline bool QualType::isAtLeastAsQualifiedAs(QualType Other) const {
 ///   analysis, the expression designates the object or function
 ///   denoted by the reference, and the expression is an lvalue.
 inline QualType QualType::getNonReferenceType() const {
-  if (const ReferenceType *RefType = (*this)->getAsReferenceType())
+  if (const ReferenceType *RefType = (*this)->getAs<ReferenceType>())
     return RefType->getPointeeType();
   else
     return *this;
index f30927c4ecb2bbb7d097734d89ba9fb98a8be458..dcb18cb91d7f5f4331484edcd81cb4fd9fc0f976 100644 (file)
@@ -447,7 +447,7 @@ unsigned ASTContext::getDeclAlignInBytes(const Decl *D) {
 
   if (const ValueDecl *VD = dyn_cast<ValueDecl>(D)) {
     QualType T = VD->getType();
-    if (const ReferenceType* RT = T->getAsReferenceType()) {
+    if (const ReferenceType* RT = T->getAs<ReferenceType>()) {
       unsigned AS = RT->getPointeeType().getAddressSpace();
       Align = Target.getPointerAlign(AS);
     } else if (!T->isIncompleteType() && !T->isFunctionType()) {
@@ -779,7 +779,7 @@ void ASTRecordLayout::LayoutField(const FieldDecl *FD, unsigned FieldNo,
       FieldSize = 0;
       const ArrayType* ATy = Context.getAsArrayType(FD->getType());
       FieldAlign = Context.getTypeAlign(ATy->getElementType());
-    } else if (const ReferenceType *RT = FD->getType()->getAsReferenceType()) {
+    } else if (const ReferenceType *RT = FD->getType()->getAs<ReferenceType>()) {
       unsigned AS = RT->getPointeeType().getAddressSpace();
       FieldSize = Context.Target.getPointerWidth(AS);
       FieldAlign = Context.Target.getPointerAlign(AS);
@@ -3382,9 +3382,9 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
   // enough that they should be handled separately.
   // FIXME: Merging of lvalue and rvalue references is incorrect. C++ *really*
   // shouldn't be going through here!
-  if (const ReferenceType *RT = LHS->getAsReferenceType())
+  if (const ReferenceType *RT = LHS->getAs<ReferenceType>())
     LHS = RT->getPointeeType();
-  if (const ReferenceType *RT = RHS->getAsReferenceType())
+  if (const ReferenceType *RT = RHS->getAs<ReferenceType>())
     RHS = RT->getPointeeType();
 
   QualType LHSCan = getCanonicalType(LHS),
index 13d0cb03e8fdd2fb924dbc7925d8542c1f276e2a..28c3a8f42a28e6fa28bc35f6dd7bce4bb99a7fce 100644 (file)
@@ -305,24 +305,6 @@ QualType Type::getPointeeType() const {
   return QualType();
 }
 
-const ReferenceType *Type::getAsReferenceType() const {
-  // If this is directly a reference type, return it.
-  if (const ReferenceType *RTy = dyn_cast<ReferenceType>(this))
-    return RTy;
-
-  // If the canonical form of this type isn't the right kind, reject it.
-  if (!isa<ReferenceType>(CanonicalType)) {
-    // Look through type qualifiers
-    if (isa<ReferenceType>(CanonicalType.getUnqualifiedType()))
-      return CanonicalType.getUnqualifiedType()->getAsReferenceType();
-    return 0;
-  }
-
-  // If this is a typedef for a reference type, strip the typedef off without
-  // losing all typedef information.
-  return cast<ReferenceType>(getDesugaredType());
-}
-
 const LValueReferenceType *Type::getAsLValueReferenceType() const {
   // If this is directly an lvalue reference type, return it.
   if (const LValueReferenceType *RTy = dyn_cast<LValueReferenceType>(this))
@@ -395,7 +377,7 @@ bool Type::isVariablyModifiedType() const {
   // correctly.
   if (const PointerType *PT = getAs<PointerType>())
     return PT->getPointeeType()->isVariablyModifiedType();
-  if (const ReferenceType *RT = getAsReferenceType())
+  if (const ReferenceType *RT = getAs<ReferenceType>())
     return RT->getPointeeType()->isVariablyModifiedType();
   if (const MemberPointerType *PT = getAsMemberPointerType())
     return PT->getPointeeType()->isVariablyModifiedType();
index 21daa8fc030da2bbaccc946bf63cc24682592a10..d533e63c48b096a7f653dfe8d3edef09d229a153 100644 (file)
@@ -1751,7 +1751,7 @@ Sema::DeclPtrTy Sema::ActOnConversionDeclarator(CXXConversionDecl *Conversion) {
   // virtual function that overrides a virtual function in a base class.
   QualType ClassType 
     = Context.getCanonicalType(Context.getTypeDeclType(ClassDecl));
-  if (const ReferenceType *ConvTypeRef = ConvType->getAsReferenceType())
+  if (const ReferenceType *ConvTypeRef = ConvType->getAs<ReferenceType>())
     ConvType = ConvTypeRef->getPointeeType();
   if (ConvType->isRecordType()) {
     ConvType = Context.getCanonicalType(ConvType).getUnqualifiedType();
@@ -2548,7 +2548,7 @@ Sema::CheckReferenceInit(Expr *&Init, QualType DeclType,
                          bool AllowExplicit, bool ForceRValue) {
   assert(DeclType->isReferenceType() && "Reference init needs a reference");
 
-  QualType T1 = DeclType->getAsReferenceType()->getPointeeType();
+  QualType T1 = DeclType->getAs<ReferenceType>()->getPointeeType();
   QualType T2 = Init->getType();
 
   // If the initializer is the address of an overloaded function, try
@@ -3083,7 +3083,7 @@ VarDecl *Sema::BuildExceptionDeclaration(Scope *S, QualType ExDeclType,
     BaseType = Ptr->getPointeeType();
     Mode = 1;
     DK = diag::err_catch_incomplete_ptr;
-  } else if(const ReferenceType *Ref = BaseType->getAsReferenceType()) {
+  } else if(const ReferenceType *Ref = BaseType->getAs<ReferenceType>()) {
     // For the purpose of error recovery, we treat rvalue refs like lvalue refs.
     BaseType = Ref->getPointeeType();
     Mode = 2;
index a229791ea96862c19d341f17ffcf35be68c8712c..da5e6bad03413be20d0c3855166cb36797ea2ea3 100644 (file)
@@ -1073,7 +1073,7 @@ Sema::BuildDeclarationNameExpr(SourceLocation Loc, NamedDecl *D,
         Ctx = FD->getDeclContext();
         MemberType = FD->getType();
 
-        if (const ReferenceType *RefType = MemberType->getAsReferenceType())
+        if (const ReferenceType *RefType = MemberType->getAs<ReferenceType>())
           MemberType = RefType->getPointeeType();
         else if (!FD->isMutable()) {
           unsigned combinedQualifiers 
@@ -2177,7 +2177,7 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
       // Figure out the type of the member; see C99 6.5.2.3p3, C++ [expr.ref]
       // FIXME: Handle address space modifiers
       QualType MemberType = FD->getType();
-      if (const ReferenceType *Ref = MemberType->getAsReferenceType())
+      if (const ReferenceType *Ref = MemberType->getAs<ReferenceType>())
         MemberType = Ref->getPointeeType();
       else {
         unsigned combinedQualifiers =
@@ -3447,7 +3447,7 @@ Sema::CheckAssignmentConstraints(QualType lhsType, QualType rhsType) {
   // right-hand side type. The caller is responsible for adjusting
   // lhsType so that the resulting expression does not have reference
   // type.
-  if (const ReferenceType *lhsTypeRef = lhsType->getAsReferenceType()) {
+  if (const ReferenceType *lhsTypeRef = lhsType->getAs<ReferenceType>()) {
     if (Context.typesAreCompatible(lhsTypeRef->getPointeeType(), rhsType))
       return Compatible;
     return Incompatible;
index 4b58b3d0c7f291e5bf19cf5f1c36b956792ecfe0..1fdbcfe6a13ce621c1b53fa67faeacdee8d77986 100644 (file)
@@ -604,7 +604,7 @@ TryStaticReferenceDowncast(Sema &Self, Expr *SrcExpr, QualType DestType,
     return TSC_NotApplicable;
   }
 
-  const ReferenceType *DestReference = DestType->getAsReferenceType();
+  const ReferenceType *DestReference = DestType->getAs<ReferenceType>();
   if (!DestReference) {
     return TSC_NotApplicable;
   }
@@ -829,7 +829,7 @@ CheckDynamicCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
 
   QualType DestPointee;
   const PointerType *DestPointer = DestType->getAs<PointerType>();
-  const ReferenceType *DestReference = DestType->getAsReferenceType();
+  const ReferenceType *DestReference = DestType->getAs<ReferenceType>();
   if (DestPointer) {
     DestPointee = DestPointer->getPointeeType();
   } else if (DestReference) {
index dc24a0384dd60f8ea5c78fb0153e404beb0a4f7a..aef7f181e514353f072477560525c1300d550e37 100644 (file)
@@ -2704,7 +2704,7 @@ BuiltinCandidateTypeSet::AddTypesConvertedFrom(QualType Ty,
 
   // Look through reference types; they aren't part of the type of an
   // expression for the purposes of conversions.
-  if (const ReferenceType *RefTy = Ty->getAsReferenceType())
+  if (const ReferenceType *RefTy = Ty->getAs<ReferenceType>())
     Ty = RefTy->getPointeeType();
 
   // We don't care about qualifiers on the type.
@@ -3675,7 +3675,7 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType,
   bool IsMember = false;
   if (const PointerType *ToTypePtr = ToType->getAs<PointerType>())
     FunctionType = ToTypePtr->getPointeeType();
-  else if (const ReferenceType *ToTypeRef = ToType->getAsReferenceType())
+  else if (const ReferenceType *ToTypeRef = ToType->getAs<ReferenceType>())
     FunctionType = ToTypeRef->getPointeeType();
   else if (const MemberPointerType *MemTypePtr =
                     ToType->getAsMemberPointerType()) {
index 85d38671f103f58cc7fd1dde751e7d779911be37..9159cf12d5d5feb35575eab1f7bf149716967e78 100644 (file)
@@ -1654,7 +1654,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
       //    represents a set of overloaded functions, the matching
       //    function is selected from the set (13.4).
       (ParamType->isReferenceType() &&
-       ParamType->getAsReferenceType()->getPointeeType()->isFunctionType()) ||
+       ParamType->getAs<ReferenceType>()->getPointeeType()->isFunctionType()) ||
       // -- For a non-type template-parameter of type pointer to
       //    member function, no conversions apply. If the
       //    template-argument represents a set of overloaded member
@@ -1755,7 +1755,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
     return false;
   }
     
-  if (const ReferenceType *ParamRefType = ParamType->getAsReferenceType()) {
+  if (const ReferenceType *ParamRefType = ParamType->getAs<ReferenceType>()) {
     //   -- For a non-type template-parameter of type reference to
     //      object, no conversions apply. The type referred to by the
     //      reference may be more cv-qualified than the (otherwise
index b304751beb68660f6b80abed058e661d08915388..d475538586536870df847ca5e26d77ea8e236d25 100644 (file)
@@ -1282,7 +1282,7 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
     //   are ignored for type deduction. 
     if (CanonParamType.getCVRQualifiers())
       ParamType = CanonParamType.getUnqualifiedType();
-    if (const ReferenceType *ParamRefType = ParamType->getAsReferenceType()) {
+    if (const ReferenceType *ParamRefType = ParamType->getAs<ReferenceType>()) {
       //   [...] If P is a reference type, the type referred to by P is used 
       //   for type deduction. 
       ParamType = ParamRefType->getPointeeType();
index ee4cd204b99a77f471438c9a134f5618066dec83..d69227cc9424b141479cfe00c7b8277cf614dad6 100644 (file)
@@ -301,7 +301,7 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS,
       if (Result->isPointerType() || Result->isReferenceType()) {
         QualType EltTy = Result->isPointerType() ? 
           Result->getAs<PointerType>()->getPointeeType() :
-          Result->getAsReferenceType()->getPointeeType();
+          Result->getAs<ReferenceType>()->getPointeeType();
       
         // If we have a pointer or reference, the pointee must have an object
         // incomplete type.
@@ -1188,7 +1188,7 @@ bool Sema::CheckSpecifiedExceptionType(QualType T, const SourceRange &Range) {
   if (const PointerType* IT = T->getAs<PointerType>()) {
     T = IT->getPointeeType();
     kind = 1;
-  } else if (const ReferenceType* IT = T->getAsReferenceType()) {
+  } else if (const ReferenceType* IT = T->getAs<ReferenceType>()) {
     T = IT->getPointeeType();
     kind = 2;
   } else
@@ -1285,7 +1285,7 @@ bool Sema::CheckExceptionSpecSubset(unsigned DiagID, unsigned NoteID,
     // Take one type from the subset.
     QualType CanonicalSubT = Context.getCanonicalType(*SubI);
     bool SubIsPointer = false;
-    if (const ReferenceType *RefTy = CanonicalSubT->getAsReferenceType())
+    if (const ReferenceType *RefTy = CanonicalSubT->getAs<ReferenceType>())
       CanonicalSubT = RefTy->getPointeeType();
     if (const PointerType *PtrTy = CanonicalSubT->getAs<PointerType>()) {
       CanonicalSubT = PtrTy->getPointeeType();
@@ -1305,7 +1305,7 @@ bool Sema::CheckExceptionSpecSubset(unsigned DiagID, unsigned NoteID,
       QualType CanonicalSuperT = Context.getCanonicalType(*SuperI);
       // SubT must be SuperT or derived from it, or pointer or reference to
       // such types.
-      if (const ReferenceType *RefTy = CanonicalSuperT->getAsReferenceType())
+      if (const ReferenceType *RefTy = CanonicalSuperT->getAs<ReferenceType>())
         CanonicalSuperT = RefTy->getPointeeType();
       if (SubIsPointer) {
         if (const PointerType *PtrTy = CanonicalSuperT->getAs<PointerType>())