[cfe-commits] r39175 - in /cfe/cfe/trunk: AST/ASTContext.cpp include/clang/AST/Type.h
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:40:35 PDT 2007
Author: sabre
Date: Wed Jul 11 11:40:34 2007
New Revision: 39175
URL: http://llvm.org/viewvc/llvm-project?rev=39175&view=rev
Log:
Implement and use isa/dyncast/cast etc for Type classes.
Modified:
cfe/cfe/trunk/AST/ASTContext.cpp
cfe/cfe/trunk/include/clang/AST/Type.h
Modified: cfe/cfe/trunk/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/ASTContext.cpp?rev=39175&r1=39174&r2=39175&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/ASTContext.cpp (original)
+++ cfe/cfe/trunk/AST/ASTContext.cpp Wed Jul 11 11:40:34 2007
@@ -77,8 +77,8 @@
// Unique pointers, to guarantee there is only one pointer of a particular
// structure.
for (unsigned i = 0, e = Types.size(); i != e; ++i)
- if (Types[i]->getTypeClass() == Type::Pointer)
- if (((PointerType*)Types[i])->getPointee() == T)
+ if (PointerType *PTy = dyn_cast<PointerType>(Types[i]))
+ if (PTy->getPointee() == T)
return Types[i];
Modified: cfe/cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/AST/Type.h?rev=39175&r1=39174&r2=39175&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/cfe/trunk/include/clang/AST/Type.h Wed Jul 11 11:40:34 2007
@@ -14,6 +14,7 @@
#ifndef LLVM_CLANG_AST_TYPE_H
#define LLVM_CLANG_AST_TYPE_H
+#include "llvm/Support/Casting.h"
#include "llvm/Support/DataTypes.h"
#include <cassert>
#include <iosfwd>
@@ -157,6 +158,8 @@
Type *getCanonicalType() const { return CanonicalType; }
virtual void print(std::ostream &OS) const = 0;
+
+ static bool classof(const Type *) { return true; }
};
/// BuiltinType - This class is used for builtin types like 'int'. Builtin
@@ -167,6 +170,10 @@
BuiltinType(const char *name) : Type(Builtin, 0), Name(name) {}
virtual void print(std::ostream &OS) const;
+
+
+ static bool classof(const Type *T) { return T->getTypeClass() == Builtin; }
+ static bool classof(const BuiltinType *) { return true; }
};
class PointerType : public Type {
@@ -178,12 +185,18 @@
TypeRef getPointee() const { return PointeeType; }
virtual void print(std::ostream &OS) const;
+
+ static bool classof(const Type *T) { return T->getTypeClass() == Pointer; }
+ static bool classof(const PointerType *) { return true; }
};
class TypedefType : public Type {
// Decl * here.
public:
+
+ static bool classof(const Type *T) { return T->getTypeClass() == Typedef; }
+ static bool classof(const TypedefType *) { return true; }
};
More information about the cfe-commits
mailing list