diff options
Diffstat (limited to 'clang/include')
| -rw-r--r-- | clang/include/clang/AST/ASTContext.h | 7 | ||||
| -rw-r--r-- | clang/include/clang/AST/Decl.h | 8 | ||||
| -rw-r--r-- | clang/include/clang/AST/DeclTemplate.h | 30 | ||||
| -rw-r--r-- | clang/include/clang/AST/Type.h | 40 |
4 files changed, 54 insertions, 31 deletions
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index bf6fa99f2c5..616b5482690 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -68,6 +68,7 @@ class ASTContext { llvm::FoldingSet<VectorType> VectorTypes; llvm::FoldingSet<FunctionTypeNoProto> FunctionTypeNoProtos; llvm::FoldingSet<FunctionTypeProto> FunctionTypeProtos; + llvm::FoldingSet<TemplateTypeParmType> TemplateTypeParmTypes; llvm::FoldingSet<ObjCQualifiedInterfaceType> ObjCQualifiedInterfaceTypes; llvm::FoldingSet<ObjCQualifiedIdType> ObjCQualifiedIdTypes; /// ASTRecordLayouts - A cache mapping from RecordDecls to ASTRecordLayouts. @@ -256,9 +257,11 @@ public: /// getTypedefType - Return the unique reference to the type for the /// specified typename decl. QualType getTypedefType(TypedefDecl *Decl); - QualType getTemplateTypeParmType(TemplateTypeParmDecl *Decl); QualType getObjCInterfaceType(ObjCInterfaceDecl *Decl); - + + QualType getTemplateTypeParmType(unsigned Depth, unsigned Index, + IdentifierInfo *Name = 0); + /// getObjCQualifiedInterfaceType - Return a /// ObjCQualifiedInterfaceType type for the given interface decl and /// the conforming protocol list. diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index b3ec04936d7..15945affce4 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -762,13 +762,15 @@ protected: /// TypeDecl - Represents a declaration of a type. /// class TypeDecl : public NamedDecl { - /// TypeForDecl - This indicates the Type object that represents this - /// TypeDecl. It is a cache maintained by ASTContext::getTypedefType, - /// ASTContext::getTagDeclType, and ASTContext::getTemplateTypeParmType. + /// TypeForDecl - This indicates the Type object that represents + /// this TypeDecl. It is a cache maintained by + /// ASTContext::getTypedefType, ASTContext::getTagDeclType, and + /// ASTContext::getTemplateTypeParmType, and TemplateTypeParmDecl. Type *TypeForDecl; friend class ASTContext; friend class DeclContext; friend class TagDecl; + friend class TemplateTypeParmDecl; protected: TypeDecl(Kind DK, DeclContext *DC, SourceLocation L, diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index 98fd42df434..64e4ea95b5d 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -201,30 +201,28 @@ public: /// @code /// template<typename T> class vector; /// @endcode -class TemplateTypeParmDecl - : public TypeDecl, protected TemplateParmPosition { - /// Typename - Whether this template type parameter was declaration - /// with the 'typename' keyword. If false, it was declared with the +class TemplateTypeParmDecl : public TypeDecl { + /// \brief Whether this template type parameter was declaration with + /// the 'typename' keyword. If false, it was declared with the /// 'class' keyword. bool Typename : 1; - TemplateTypeParmDecl(DeclContext *DC, SourceLocation L, unsigned D, - unsigned P, IdentifierInfo *Id, bool Typename) - : TypeDecl(TemplateTypeParm, DC, L, Id), TemplateParmPosition(D, P), - Typename(Typename) { } + TemplateTypeParmDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, + bool Typename, QualType Type) + : TypeDecl(TemplateTypeParm, DC, L, Id), Typename(Typename) { + TypeForDecl = Type.getTypePtr(); + } + public: static TemplateTypeParmDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename); - /// wasDeclarationWithTypename - Whether this template type - /// parameter was declared with the 'typename' keyword. If not, it - /// was declared with the 'class' keyword. + /// \brief Whether this template type parameter was declared with + /// the 'typename' keyword. If not, it was declared with the 'class' + /// keyword. bool wasDeclaredWithTypename() const { return Typename; } - using TemplateParmPosition::getDepth; - using TemplateParmPosition::getPosition; - // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() == TemplateTypeParm; @@ -232,10 +230,10 @@ public: static bool classof(const TemplateTypeParmDecl *D) { return true; } protected: - /// EmitImpl - Serialize this TemplateTypeParmDecl. Called by Decl::Emit. + /// Serialize this TemplateTypeParmDecl. Called by Decl::Emit. virtual void EmitImpl(llvm::Serializer& S) const; - /// CreateImpl - Deserialize a TemplateTypeParmDecl. Called by Decl::Create. + /// Deserialize a TemplateTypeParmDecl. Called by Decl::Create. static TemplateTypeParmDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C); friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C); diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 6b2797307f8..666d952645e 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -1188,7 +1188,7 @@ public: TypedefDecl *getDecl() const { return Decl; } /// LookThroughTypedefs - Return the ultimate type this typedef corresponds to - /// potentially looking through *all* consequtive typedefs. This returns the + /// potentially looking through *all* consecutive typedefs. This returns the /// sum of the type qualifiers, so if you have: /// typedef const int A; /// typedef volatile A B; @@ -1350,20 +1350,40 @@ public: static bool classof(const EnumType *) { return true; } }; -class TemplateTypeParmType : public Type { - TemplateTypeParmDecl *Decl; +class TemplateTypeParmType : public Type, public llvm::FoldingSetNode { + unsigned Depth : 16; + unsigned Index : 16; + IdentifierInfo *Name; -protected: - TemplateTypeParmType(TemplateTypeParmDecl *D) - : Type(TemplateTypeParm, QualType(this, 0), /*Dependent=*/true), Decl(D) { } + TemplateTypeParmType(unsigned D, unsigned I, IdentifierInfo *N, + QualType Canon) + : Type(TemplateTypeParm, Canon, /*Dependent=*/true), + Depth(D), Index(I), Name(N) { } - friend class ASTContext; // ASTContext creates these + TemplateTypeParmType(unsigned D, unsigned I) + : Type(TemplateTypeParm, QualType(this, 0), /*Dependent=*/true), + Depth(D), Index(I), Name(0) { } -public: - TemplateTypeParmDecl *getDecl() const { return Decl; } + friend class ASTContext; // ASTContext creates these +public: + unsigned getDepth() const { return Depth; } + unsigned getIndex() const { return Index; } + IdentifierInfo *getName() const { return Name; } + virtual void getAsStringInternal(std::string &InnerString) const; + void Profile(llvm::FoldingSetNodeID &ID) { + Profile(ID, Depth, Index, Name); + } + + static void Profile(llvm::FoldingSetNodeID &ID, unsigned Depth, + unsigned Index, IdentifierInfo *Name) { + ID.AddInteger(Depth); + ID.AddInteger(Index); + ID.AddPointer(Name); + } + static bool classof(const Type *T) { return T->getTypeClass() == TemplateTypeParm; } @@ -1374,7 +1394,7 @@ protected: static Type* CreateImpl(ASTContext& Context, llvm::Deserializer& D); friend class Type; }; - + /// ObjCInterfaceType - Interfaces are the core concept in Objective-C for /// object oriented design. They basically correspond to C++ classes. There /// are two kinds of interface types, normal interfaces like "NSString" and |

