aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaType.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-07-16 19:58:26 +0000
committerTed Kremenek <kremenek@apple.com>2009-07-16 19:58:26 +0000
commit1a1a6e2bd4c5aefd7fd643cf25915f9623a02e59 (patch)
tree333652f464e28debc770fc4b30bc5b8f74254d28 /lib/Sema/SemaType.cpp
parente41611aa2237d06a0ef61db4528fb2883a8defcd (diff)
Add member template 'Type::getAs<T>', which converts a Type* to a respective T*.
This method is intended to eventually replace the individual Type::getAsXXXType<> methods. The motivation behind this change is twofold: 1) Reduce redundant implementations of Type::getAsXXXType() methods. Most of them are basically copy-and-paste. 2) By centralizing the implementation of the getAs<Type> logic we can more smoothly move over to Doug Gregor's proposed canonical type smart pointer scheme. Along with this patch: a) Removed 'Type::getAsPointerType()'; now clients use getAs<PointerType>. b) Removed 'Type::getAsBlockPointerTypE()'; now clients use getAs<BlockPointerType>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76098 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaType.cpp')
-rw-r--r--lib/Sema/SemaType.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 8195aba967..ee4cd204b9 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -300,7 +300,7 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS,
if (TypeQuals & QualType::Restrict) {
if (Result->isPointerType() || Result->isReferenceType()) {
QualType EltTy = Result->isPointerType() ?
- Result->getAsPointerType()->getPointeeType() :
+ Result->getAs<PointerType>()->getPointeeType() :
Result->getAsReferenceType()->getPointeeType();
// If we have a pointer or reference, the pointee must have an object
@@ -1185,7 +1185,7 @@ bool Sema::CheckSpecifiedExceptionType(QualType T, const SourceRange &Range) {
// an incomplete type a pointer or reference to an incomplete type, other
// than (cv) void*.
int kind;
- if (const PointerType* IT = T->getAsPointerType()) {
+ if (const PointerType* IT = T->getAs<PointerType>()) {
T = IT->getPointeeType();
kind = 1;
} else if (const ReferenceType* IT = T->getAsReferenceType()) {
@@ -1205,7 +1205,7 @@ bool Sema::CheckSpecifiedExceptionType(QualType T, const SourceRange &Range) {
/// to member to a function with an exception specification. This means that
/// it is invalid to add another level of indirection.
bool Sema::CheckDistantExceptionSpec(QualType T) {
- if (const PointerType *PT = T->getAsPointerType())
+ if (const PointerType *PT = T->getAs<PointerType>())
T = PT->getPointeeType();
else if (const MemberPointerType *PT = T->getAsMemberPointerType())
T = PT->getPointeeType();
@@ -1287,7 +1287,7 @@ bool Sema::CheckExceptionSpecSubset(unsigned DiagID, unsigned NoteID,
bool SubIsPointer = false;
if (const ReferenceType *RefTy = CanonicalSubT->getAsReferenceType())
CanonicalSubT = RefTy->getPointeeType();
- if (const PointerType *PtrTy = CanonicalSubT->getAsPointerType()) {
+ if (const PointerType *PtrTy = CanonicalSubT->getAs<PointerType>()) {
CanonicalSubT = PtrTy->getPointeeType();
SubIsPointer = true;
}
@@ -1308,7 +1308,7 @@ bool Sema::CheckExceptionSpecSubset(unsigned DiagID, unsigned NoteID,
if (const ReferenceType *RefTy = CanonicalSuperT->getAsReferenceType())
CanonicalSuperT = RefTy->getPointeeType();
if (SubIsPointer) {
- if (const PointerType *PtrTy = CanonicalSuperT->getAsPointerType())
+ if (const PointerType *PtrTy = CanonicalSuperT->getAs<PointerType>())
CanonicalSuperT = PtrTy->getPointeeType();
else {
continue;
@@ -1384,8 +1384,8 @@ QualType Sema::ObjCGetTypeForMethodDefinition(DeclPtrTy D) {
/// be called in a loop that successively "unwraps" pointer and
/// pointer-to-member types to compare them at each level.
bool Sema::UnwrapSimilarPointerTypes(QualType& T1, QualType& T2) {
- const PointerType *T1PtrType = T1->getAsPointerType(),
- *T2PtrType = T2->getAsPointerType();
+ const PointerType *T1PtrType = T1->getAs<PointerType>(),
+ *T2PtrType = T2->getAs<PointerType>();
if (T1PtrType && T2PtrType) {
T1 = T1PtrType->getPointeeType();
T2 = T2PtrType->getPointeeType();