]> granicus.if.org Git - clang/commitdiff
Remove PointerLikeType.
authorDaniel Dunbar <daniel@zuster.org>
Thu, 26 Feb 2009 19:54:52 +0000 (19:54 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 26 Feb 2009 19:54:52 +0000 (19:54 +0000)
 - 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

include/clang/AST/Type.h
lib/AST/Type.cpp
lib/CodeGen/CodeGenTypes.h

index 8b7b09c91f6d33edfff37a6787338654c5f96d8a..f05185b339bf1f42cf9df1ed1a8e9f79c64a8dcd 100644 (file)
@@ -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<ReferenceType>(CanonicalType.getUnqualifiedType());
 }
-inline bool Type::isPointerLikeType() const {
-  return isa<PointerLikeType>(CanonicalType.getUnqualifiedType()); 
-}
 inline bool Type::isFunctionPointerType() const {
   if (const PointerType* T = getAsPointerType())
     return T->getPointeeType()->isFunctionType();
index 7b07b9cbe40b377fbc8f6b88cef33727a22cd336..210be03fa83ecd65f6732ef52da11a42f0661d85 100644 (file)
@@ -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<PointerLikeType>(this))
-    return PTy;
-  
-  // If the canonical form of this type isn't the right kind, reject it.
-  if (!isa<PointerLikeType>(CanonicalType)) {
-    // Look through type qualifiers
-    if (isa<PointerLikeType>(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<PointerType>(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();
 
index 9c548ec09973bbbfcc9052ad3cb0eecc3b847452..228502d0cdd39ab2ba61cf0bbd7fd7497be75037 100644 (file)
@@ -36,7 +36,6 @@ namespace clang {
   class FunctionTypeProto;
   class ObjCInterfaceDecl;
   class ObjCIvarDecl;
-  class PointerLikeType;
   class PointerType;
   class QualType;
   class RecordDecl;