Per offline discussion with Steve Naroff, add back Type::getAsXXXType() methods
until Doug Gregor's Type smart pointer code lands (or more discussion occurs).
These methods just call the new Type::getAs<XXX> methods, so we still have
reduced implementation redundancy. Having explicit getAsXXXType() methods makes
it easier to set breakpoints in the debugger.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76193 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp
index d8d1259..73200fe 100644
--- a/lib/CodeGen/CGBlocks.cpp
+++ b/lib/CodeGen/CGBlocks.cpp
@@ -388,7 +388,7 @@
RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E) {
const BlockPointerType *BPT =
- E->getCallee()->getType()->getAs<BlockPointerType>();
+ E->getCallee()->getType()->getAsBlockPointerType();
llvm::Value *Callee = EmitScalarExpr(E->getCallee());
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp
index 9031caf..07f387f 100644
--- a/lib/CodeGen/CGCXX.cpp
+++ b/lib/CodeGen/CGCXX.cpp
@@ -179,7 +179,7 @@
assert(Dest && "Must have a destination!");
const CXXRecordDecl *RD =
- cast<CXXRecordDecl>(E->getType()->getAs<RecordType>()->getDecl());
+ cast<CXXRecordDecl>(E->getType()->getAsRecordType()->getDecl());
if (RD->hasTrivialConstructor())
return;
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index ab7b70e..346b670 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -934,7 +934,7 @@
assert(E->getBase()->getType()->isVectorType());
Base = EmitLValue(E->getBase());
} else {
- const PointerType *PT = E->getBase()->getType()->getAs<PointerType>();
+ const PointerType *PT = E->getBase()->getType()->getAsPointerType();
llvm::Value *Ptr = EmitScalarExpr(E->getBase());
Base = LValue::MakeAddr(Ptr, PT->getPointeeType().getCVRQualifiers());
}
@@ -976,7 +976,7 @@
if (E->isArrow()) {
BaseValue = EmitScalarExpr(BaseExpr);
const PointerType *PTy =
- BaseExpr->getType()->getAs<PointerType>();
+ BaseExpr->getType()->getAsPointerType();
if (PTy->getPointeeType()->isUnionType())
isUnion = true;
CVRQualifiers = PTy->getPointeeType().getCVRQualifiers();
@@ -1317,7 +1317,7 @@
assert(CalleeType->isFunctionPointerType() &&
"Call must have function pointer type!");
- QualType FnType = CalleeType->getAs<PointerType>()->getPointeeType();
+ QualType FnType = CalleeType->getAsPointerType()->getPointeeType();
QualType ResultType = FnType->getAsFunctionType()->getResultType();
CallArgList Args;
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp
index 58be86d..e4192d6 100644
--- a/lib/CodeGen/CGExprAgg.cpp
+++ b/lib/CodeGen/CGExprAgg.cpp
@@ -253,7 +253,7 @@
} else {
if (CGF.getContext().getLangOptions().NeXTRuntime) {
QualType LHSTy = E->getLHS()->getType();
- if (const RecordType *FDTTy = LHSTy.getTypePtr()->getAs<RecordType>())
+ if (const RecordType *FDTTy = LHSTy.getTypePtr()->getAsRecordType())
if (FDTTy->getDecl()->hasObjectMember()) {
LValue RHS = CGF.EmitLValue(E->getRHS());
CGF.CGM.getObjCRuntime().EmitGCMemmoveCollectable(CGF, LHS.getAddress(),
@@ -441,7 +441,7 @@
// the disadvantage is that the generated code is more difficult for
// the optimizer, especially with bitfields.
unsigned NumInitElements = E->getNumInits();
- RecordDecl *SD = E->getType()->getAs<RecordType>()->getDecl();
+ RecordDecl *SD = E->getType()->getAsRecordType()->getDecl();
unsigned CurInitVal = 0;
if (E->getType()->isUnionType()) {
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp
index dea207c..4f1f58f 100644
--- a/lib/CodeGen/CGExprConstant.cpp
+++ b/lib/CodeGen/CGExprConstant.cpp
@@ -188,7 +188,7 @@
llvm::Constant *EmitStructInitialization(InitListExpr *ILE) {
const llvm::StructType *SType =
cast<llvm::StructType>(ConvertType(ILE->getType()));
- RecordDecl *RD = ILE->getType()->getAs<RecordType>()->getDecl();
+ RecordDecl *RD = ILE->getType()->getAsRecordType()->getDecl();
std::vector<llvm::Constant*> Elts;
// Initialize the whole structure to zero.
@@ -264,7 +264,7 @@
#ifndef NDEBUG
// Make sure that it's really an empty and not a failure of
// semantic analysis.
- RecordDecl *RD = ILE->getType()->getAs<RecordType>()->getDecl();
+ RecordDecl *RD = ILE->getType()->getAsRecordType()->getDecl();
for (RecordDecl::field_iterator Field = RD->field_begin(),
FieldEnd = RD->field_end();
Field != FieldEnd; ++Field)
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index 8103506..129b4c7 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -679,7 +679,7 @@
int AmountVal = isInc ? 1 : -1;
if (ValTy->isPointerType() &&
- ValTy->getAs<PointerType>()->isVariableArrayType()) {
+ ValTy->getAsPointerType()->isVariableArrayType()) {
// The amount of the addition/subtraction needs to account for the VLA size
CGF.ErrorUnsupported(E, "VLA pointer inc/dec");
}
@@ -1020,13 +1020,13 @@
}
if (Ops.Ty->isPointerType() &&
- Ops.Ty->getAs<PointerType>()->isVariableArrayType()) {
+ Ops.Ty->getAsPointerType()->isVariableArrayType()) {
// The amount of the addition needs to account for the VLA size
CGF.ErrorUnsupported(Ops.E, "VLA pointer addition");
}
Value *Ptr, *Idx;
Expr *IdxExp;
- const PointerType *PT = Ops.E->getLHS()->getType()->getAs<PointerType>();
+ const PointerType *PT = Ops.E->getLHS()->getType()->getAsPointerType();
const ObjCObjectPointerType *OPT =
Ops.E->getLHS()->getType()->getAsObjCObjectPointerType();
if (PT || OPT) {
@@ -1034,7 +1034,7 @@
Idx = Ops.RHS;
IdxExp = Ops.E->getRHS();
} else { // int + pointer
- PT = Ops.E->getRHS()->getType()->getAs<PointerType>();
+ PT = Ops.E->getRHS()->getType()->getAsPointerType();
OPT = Ops.E->getRHS()->getType()->getAsObjCObjectPointerType();
assert((PT || OPT) && "Invalid add expr");
Ptr = Ops.RHS;
@@ -1091,7 +1091,7 @@
}
if (Ops.E->getLHS()->getType()->isPointerType() &&
- Ops.E->getLHS()->getType()->getAs<PointerType>()->isVariableArrayType()) {
+ Ops.E->getLHS()->getType()->getAsPointerType()->isVariableArrayType()) {
// The amount of the addition needs to account for the VLA size for
// ptr-int
// The amount of the division needs to account for the VLA size for
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 02516d7..661f75a 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -3008,7 +3008,7 @@
if (FQT->isObjCObjectPointerType())
return QualType::Strong;
- if (const PointerType *PT = FQT->getAs<PointerType>())
+ if (const PointerType *PT = FQT->getAsPointerType())
return GetGCAttrTypeForType(Ctx, PT->getPointeeType());
return QualType::GCNone;
@@ -3072,7 +3072,7 @@
if (FQT->isUnionType())
HasUnion = true;
- BuildAggrIvarRecordLayout(FQT->getAs<RecordType>(),
+ BuildAggrIvarRecordLayout(FQT->getAsRecordType(),
BytePos + FieldOffset,
ForStrongLayout, HasUnion);
continue;
@@ -3097,7 +3097,7 @@
int OldIndex = IvarsInfo.size() - 1;
int OldSkIndex = SkipIvars.size() -1;
- const RecordType *RT = FQT->getAs<RecordType>();
+ const RecordType *RT = FQT->getAsRecordType();
BuildAggrIvarRecordLayout(RT, BytePos + FieldOffset,
ForStrongLayout, HasUnion);
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index 250ccce..a72f2ae 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -380,7 +380,7 @@
/// getCGRecordLayout - Return record layout info.
const CGRecordLayout *CodeGenFunction::getCGRecordLayout(CodeGenTypes &CGT,
QualType Ty) {
- const RecordType *RTy = Ty->getAs<RecordType>();
+ const RecordType *RTy = Ty->getAsRecordType();
assert (RTy && "Unexpected type. RecordType expected here.");
return CGT.getCGRecordLayout(RTy->getDecl());
@@ -490,7 +490,7 @@
return SizeEntry;
} else if (const ArrayType *AT = dyn_cast<ArrayType>(Ty)) {
EmitVLASize(AT->getElementType());
- } else if (const PointerType *PT = Ty->getAs<PointerType>())
+ } else if (const PointerType *PT = Ty->getAsPointerType())
EmitVLASize(PT->getPointeeType());
else {
assert(0 && "unknown VM type!");
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index adc88a0..d502d79 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -1251,7 +1251,7 @@
}
QualType CFTy = getContext().getCFConstantStringType();
- RecordDecl *CFRD = CFTy->getAs<RecordType>()->getDecl();
+ RecordDecl *CFRD = CFTy->getAsRecordType()->getDecl();
const llvm::StructType *STy =
cast<llvm::StructType>(getTypes().ConvertType(CFTy));
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp
index 2117e6d..e97cbbd 100644
--- a/lib/CodeGen/CodeGenTypes.cpp
+++ b/lib/CodeGen/CodeGenTypes.cpp
@@ -142,12 +142,12 @@
// and all of the argument types are complete.
static const TagType *VerifyFuncTypeComplete(const Type* T) {
const FunctionType *FT = cast<FunctionType>(T);
- if (const TagType* TT = FT->getResultType()->getAs<TagType>())
+ if (const TagType* TT = FT->getResultType()->getAsTagType())
if (!TT->getDecl()->isDefinition())
return TT;
if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(T))
for (unsigned i = 0; i < FPT->getNumArgs(); i++)
- if (const TagType* TT = FPT->getArgType(i)->getAs<TagType>())
+ if (const TagType* TT = FPT->getArgType(i)->getAsTagType())
if (!TT->getDecl()->isDefinition())
return TT;
return 0;
diff --git a/lib/CodeGen/TargetABIInfo.cpp b/lib/CodeGen/TargetABIInfo.cpp
index 7063327..c3f3545 100644
--- a/lib/CodeGen/TargetABIInfo.cpp
+++ b/lib/CodeGen/TargetABIInfo.cpp
@@ -68,7 +68,7 @@
/// fields. Note that a structure with a flexible array member is not
/// considered empty.
static bool isEmptyRecord(ASTContext &Context, QualType T) {
- const RecordType *RT = T->getAs<RecordType>();
+ const RecordType *RT = T->getAsRecordType();
if (!RT)
return 0;
const RecordDecl *RD = RT->getDecl();
@@ -168,7 +168,7 @@
Context.getTypeSize(FD->getType()) >= 128)
return true;
- if (const RecordType* RT = FD->getType()->getAs<RecordType>())
+ if (const RecordType* RT = FD->getType()->getAsRecordType())
if (typeContainsSSEVector(RT->getDecl(), Context))
return true;
}
@@ -272,7 +272,7 @@
return shouldReturnTypeInRegister(AT->getElementType(), Context);
// Otherwise, it must be a record type.
- const RecordType *RT = Ty->getAs<RecordType>();
+ const RecordType *RT = Ty->getAsRecordType();
if (!RT) return false;
// Structure types are passed in register if all fields would be
@@ -385,7 +385,7 @@
ASTContext &Context) {
unsigned Align = Context.getTypeAlign(Ty);
if (Align < 128) return 0;
- if (const RecordType* RT = Ty->getAs<RecordType>())
+ if (const RecordType* RT = Ty->getAsRecordType())
if (typeContainsSSEVector(RT->getDecl(), Context))
return 16;
return 0;
@@ -704,7 +704,7 @@
if (Hi == Memory)
Lo = Memory;
assert((Hi != SSEUp || Lo == SSE) && "Invalid SSEUp array classification.");
- } else if (const RecordType *RT = Ty->getAs<RecordType>()) {
+ } else if (const RecordType *RT = Ty->getAsRecordType()) {
uint64_t Size = Context.getTypeSize(Ty);
// AMD64-ABI 3.2.3p2: Rule 1. If the size of an object is larger