Remove PointerLikeType.
- Having pointers and references share a base was not a useful notion. llvm-svn: 65567
This commit is contained in:
		
							parent
							
								
									201351933a
								
							
						
					
					
						commit
						d26d5c220b
					
				| 
						 | 
				
			
			@ -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?
 | 
			
		||||
///
 | 
			
		||||
class PointerLikeType : public Type {
 | 
			
		||||
  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 {
 | 
			
		||||
class PointerType : public Type, public llvm::FoldingSetNode {
 | 
			
		||||
  QualType PointeeType;
 | 
			
		||||
 | 
			
		||||
  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();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -36,7 +36,6 @@ namespace clang {
 | 
			
		|||
  class FunctionTypeProto;
 | 
			
		||||
  class ObjCInterfaceDecl;
 | 
			
		||||
  class ObjCIvarDecl;
 | 
			
		||||
  class PointerLikeType;
 | 
			
		||||
  class PointerType;
 | 
			
		||||
  class QualType;
 | 
			
		||||
  class RecordDecl;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue