]> granicus.if.org Git - clang/commitdiff
implement the PointerLikeTypeInfo trait for QualType, allowing
authorChris Lattner <sabre@nondot.org>
Sun, 29 Mar 2009 00:03:08 +0000 (00:03 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 29 Mar 2009 00:03:08 +0000 (00:03 +0000)
it to be stuck into a SmallPtrSet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67967 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Type.h

index 0b455aed29f3a90b416e92ab1392949c68d9f9c1..7400fe9ed3d8d23149a94bac62b3320c64d1cbcd 100644 (file)
@@ -27,6 +27,11 @@ using llvm::cast_or_null;
 using llvm::dyn_cast;
 using llvm::dyn_cast_or_null;
 
+namespace llvm {
+  template <typename T>
+  class PointerLikeTypeInfo;
+}
+
 namespace clang {
   class ASTContext;
   class Type;
@@ -218,6 +223,17 @@ template<> struct simplify_type<const ::clang::QualType> {
 template<> struct simplify_type< ::clang::QualType>
   : public simplify_type<const ::clang::QualType> {};
   
+// Teach SmallPtrSet that QualType is "basically a pointer".
+template<>
+class PointerLikeTypeInfo<clang::QualType> {
+public:
+  static inline void *getAsVoidPointer(clang::QualType P) {
+    return P.getAsOpaquePtr();
+  }
+  static inline clang::QualType getFromVoidPointer(void *P) {
+    return clang::QualType::getFromOpaquePtr(P);
+  }
+};
 } // end namespace llvm
 
 namespace clang {