From: Daniel Dunbar Date: Thu, 26 Feb 2009 19:54:52 +0000 (+0000) Subject: Remove PointerLikeType. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=68694ada8f4d8f6c4b00ea5b900df96428b28fc8;p=clang Remove PointerLikeType. - Having pointers and references share a base was not a useful notion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65567 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index 8b7b09c91f..f05185b339 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -45,7 +45,6 @@ namespace clang { class Expr; class Stmt; class SourceLocation; - class PointerLikeType; class PointerType; class BlockPointerType; class ReferenceType; @@ -362,7 +361,6 @@ public: // Type Predicates: Check to see if this type is structurally the specified // type, ignoring typedefs and qualifiers. bool isFunctionType() const; - bool isPointerLikeType() const; // Pointer or Reference. bool isPointerType() const; bool isBlockPointerType() const; bool isReferenceType() const; @@ -399,7 +397,6 @@ public: const FunctionType *getAsFunctionType() const; const FunctionTypeNoProto *getAsFunctionTypeNoProto() const; const FunctionTypeProto *getAsFunctionTypeProto() const; - const PointerLikeType *getAsPointerLikeType() const; // Pointer or Reference. const PointerType *getAsPointerType() const; const BlockPointerType *getAsBlockPointerType() const; const ReferenceType *getAsReferenceType() const; @@ -626,38 +623,21 @@ protected: friend class Type; }; -/// PointerLikeType - Common base class for pointers and references. -/// FIXME: Add more documentation on this classes design point. For example, -/// should BlockPointerType inherit from it? Is the concept of a PointerLikeType -/// in the C++ standard? +/// PointerType - C99 6.7.5.1 - Pointer Declarators. /// -class PointerLikeType : public Type { +class PointerType : public Type, public llvm::FoldingSetNode { QualType PointeeType; -protected: - PointerLikeType(TypeClass K, QualType Pointee, QualType CanonicalPtr) : - Type(K, CanonicalPtr, Pointee->isDependentType()), PointeeType(Pointee) { - } -public: - - QualType getPointeeType() const { return PointeeType; } - - static bool classof(const Type *T) { - return T->getTypeClass() == Pointer || T->getTypeClass() == Reference; - } - static bool classof(const PointerLikeType *) { return true; } -}; -/// PointerType - C99 6.7.5.1 - Pointer Declarators. -/// -class PointerType : public PointerLikeType, public llvm::FoldingSetNode { PointerType(QualType Pointee, QualType CanonicalPtr) : - PointerLikeType(Pointer, Pointee, CanonicalPtr) { + Type(Pointer, CanonicalPtr, Pointee->isDependentType()), PointeeType(Pointee) { } friend class ASTContext; // ASTContext creates these. public: virtual void getAsStringInternal(std::string &InnerString) const; + QualType getPointeeType() const { return PointeeType; } + void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, getPointeeType()); } @@ -677,9 +657,6 @@ protected: /// BlockPointerType - pointer to a block type. /// This type is to represent types syntactically represented as /// "void (^)(int)", etc. Pointee is required to always be a function type. -/// FIXME: Should BlockPointerType inherit from PointerLikeType? It could -/// simplfy some type checking code, however PointerLikeType doesn't appear -/// to be used by the type checker. /// class BlockPointerType : public Type, public llvm::FoldingSetNode { QualType PointeeType; // Block is some kind of pointer type @@ -715,14 +692,19 @@ public: /// ReferenceType - C++ 8.3.2 - Reference Declarators. /// -class ReferenceType : public PointerLikeType, public llvm::FoldingSetNode { +class ReferenceType : public Type, public llvm::FoldingSetNode { + QualType PointeeType; + ReferenceType(QualType Referencee, QualType CanonicalRef) : - PointerLikeType(Reference, Referencee, CanonicalRef) { + Type(Reference, CanonicalRef, Referencee->isDependentType()), + PointeeType(Referencee) { } friend class ASTContext; // ASTContext creates these. public: virtual void getAsStringInternal(std::string &InnerString) const; + QualType getPointeeType() const { return PointeeType; } + void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, getPointeeType()); } @@ -1888,9 +1870,6 @@ inline bool Type::isBlockPointerType() const { inline bool Type::isReferenceType() const { return isa(CanonicalType.getUnqualifiedType()); } -inline bool Type::isPointerLikeType() const { - return isa(CanonicalType.getUnqualifiedType()); -} inline bool Type::isFunctionPointerType() const { if (const PointerType* T = getAsPointerType()) return T->getPointeeType()->isFunctionType(); diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 7b07b9cbe4..210be03fa8 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -225,24 +225,6 @@ const FunctionTypeProto *Type::getAsFunctionTypeProto() const { } -const PointerLikeType *Type::getAsPointerLikeType() const { - // If this is directly a pointer-like type, return it. - if (const PointerLikeType *PTy = dyn_cast(this)) - return PTy; - - // If the canonical form of this type isn't the right kind, reject it. - if (!isa(CanonicalType)) { - // Look through type qualifiers - if (isa(CanonicalType.getUnqualifiedType())) - return CanonicalType.getUnqualifiedType()->getAsPointerLikeType(); - return 0; - } - - // If this is a typedef for a pointer type, strip the typedef off without - // losing all typedef information. - return getDesugaredType()->getAsPointerLikeType(); -} - const PointerType *Type::getAsPointerType() const { // If this is directly a pointer type, return it. if (const PointerType *PTy = dyn_cast(this)) @@ -331,8 +313,10 @@ bool Type::isVariablyModifiedType() const { // Also, C++ references and member pointers can point to a variably modified // type, where VLAs appear as an extension to C++, and should be treated // correctly. - if (const PointerLikeType *PT = getAsPointerLikeType()) + if (const PointerType *PT = getAsPointerType()) return PT->getPointeeType()->isVariablyModifiedType(); + if (const ReferenceType *RT = getAsReferenceType()) + return RT->getPointeeType()->isVariablyModifiedType(); if (const MemberPointerType *PT = getAsMemberPointerType()) return PT->getPointeeType()->isVariablyModifiedType(); diff --git a/lib/CodeGen/CodeGenTypes.h b/lib/CodeGen/CodeGenTypes.h index 9c548ec099..228502d0cd 100644 --- a/lib/CodeGen/CodeGenTypes.h +++ b/lib/CodeGen/CodeGenTypes.h @@ -36,7 +36,6 @@ namespace clang { class FunctionTypeProto; class ObjCInterfaceDecl; class ObjCIvarDecl; - class PointerLikeType; class PointerType; class QualType; class RecordDecl;