[cfe-commits] r65567 - in /cfe/trunk: include/clang/AST/Type.h lib/AST/Type.cpp lib/CodeGen/CodeGenTypes.h
Daniel Dunbar
daniel at zuster.org
Thu Feb 26 11:54:52 PST 2009
Author: ddunbar
Date: Thu Feb 26 13:54:52 2009
New Revision: 65567
URL: http://llvm.org/viewvc/llvm-project?rev=65567&view=rev
Log:
Remove PointerLikeType.
- Having pointers and references share a base was not a useful
notion.
Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.h
Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=65567&r1=65566&r2=65567&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Thu Feb 26 13:54:52 2009
@@ -45,7 +45,6 @@
class Expr;
class Stmt;
class SourceLocation;
- class PointerLikeType;
class PointerType;
class BlockPointerType;
class ReferenceType;
@@ -362,7 +361,6 @@
// 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 @@
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 @@
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 @@
/// 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 @@
/// 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::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();
Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=65567&r1=65566&r2=65567&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Thu Feb 26 13:54:52 2009
@@ -225,24 +225,6 @@
}
-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 @@
// 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();
Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.h?rev=65567&r1=65566&r2=65567&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.h Thu Feb 26 13:54:52 2009
@@ -36,7 +36,6 @@
class FunctionTypeProto;
class ObjCInterfaceDecl;
class ObjCIvarDecl;
- class PointerLikeType;
class PointerType;
class QualType;
class RecordDecl;
More information about the cfe-commits
mailing list