Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 1 | //===-- DeclBase.h - Base Classes for representing declarations *- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 10 | // This file defines the Decl and DeclContext interfaces. |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_CLANG_AST_DECLBASE_H |
| 15 | #define LLVM_CLANG_AST_DECLBASE_H |
| 16 | |
| 17 | #include "clang/AST/Attr.h" |
| 18 | #include "clang/AST/Type.h" |
| 19 | #include "clang/Basic/SourceLocation.h" |
| 20 | |
| 21 | namespace clang { |
Argyrios Kyrtzidis | ef17782 | 2008-04-17 14:40:12 +0000 | [diff] [blame] | 22 | class TranslationUnitDecl; |
Argyrios Kyrtzidis | 2d1c5d3 | 2008-04-27 13:50:30 +0000 | [diff] [blame^] | 23 | class NamespaceDecl; |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 24 | class FunctionDecl; |
| 25 | class ObjCMethodDecl; |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 26 | class EnumDecl; |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 27 | class ObjCInterfaceDecl; |
| 28 | |
| 29 | /// Decl - This represents one declaration (or definition), e.g. a variable, |
| 30 | /// typedef, function, struct, etc. |
| 31 | /// |
| 32 | class Decl { |
| 33 | public: |
| 34 | enum Kind { |
| 35 | // This lists the concrete classes of Decl in order of the inheritance |
| 36 | // hierarchy. This allows us to do efficient classof tests based on the |
| 37 | // enums below. The commented out names are abstract class names. |
| 38 | |
| 39 | // Decl |
Argyrios Kyrtzidis | ef17782 | 2008-04-17 14:40:12 +0000 | [diff] [blame] | 40 | TranslationUnit, |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 41 | // NamedDecl |
| 42 | Field, |
| 43 | ObjCIvar, |
| 44 | ObjCCategory, |
| 45 | ObjCCategoryImpl, |
| 46 | ObjCImplementation, |
| 47 | ObjCProtocol, |
Sam Bishop | 670aa9d | 2008-04-08 20:49:25 +0000 | [diff] [blame] | 48 | ObjCProperty, |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 49 | // ScopedDecl |
Argyrios Kyrtzidis | 2d1c5d3 | 2008-04-27 13:50:30 +0000 | [diff] [blame^] | 50 | Namespace, |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 51 | // TypeDecl |
| 52 | Typedef, |
| 53 | // TagDecl |
| 54 | Enum, |
| 55 | // RecordDecl |
| 56 | Struct, |
| 57 | Union, |
| 58 | Class, |
| 59 | // ValueDecl |
| 60 | EnumConstant, |
| 61 | Function, |
Steve Naroff | 248a753 | 2008-04-15 22:42:06 +0000 | [diff] [blame] | 62 | Var, |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 63 | ParmVar, |
| 64 | ObjCInterface, |
| 65 | ObjCCompatibleAlias, |
| 66 | ObjCMethod, |
| 67 | ObjCClass, |
| 68 | ObjCForwardProtocol, |
Fariborz Jahanian | 61d4615 | 2008-04-16 22:00:24 +0000 | [diff] [blame] | 69 | ObjCPropertyImpl, |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 70 | LinkageSpec, |
| 71 | FileScopeAsm, |
| 72 | |
| 73 | // For each non-leaf class, we now define a mapping to the first/last member |
| 74 | // of the class, to allow efficient classof. |
| 75 | NamedFirst = Field, NamedLast = ParmVar, |
| 76 | FieldFirst = Field, FieldLast = ObjCIvar, |
Argyrios Kyrtzidis | 2d1c5d3 | 2008-04-27 13:50:30 +0000 | [diff] [blame^] | 77 | ScopedFirst = Namespace, ScopedLast = ParmVar, |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 78 | TypeFirst = Typedef, TypeLast = Class, |
| 79 | TagFirst = Enum , TagLast = Class, |
| 80 | RecordFirst = Struct , RecordLast = Class, |
| 81 | ValueFirst = EnumConstant , ValueLast = ParmVar, |
Steve Naroff | 248a753 | 2008-04-15 22:42:06 +0000 | [diff] [blame] | 82 | VarFirst = Var , VarLast = ParmVar |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | /// IdentifierNamespace - According to C99 6.2.3, there are four namespaces, |
Douglas Gregor | 2ce52f3 | 2008-04-13 21:07:44 +0000 | [diff] [blame] | 86 | /// labels, tags, members and ordinary identifiers. These are meant |
| 87 | /// as bitmasks, so that searches in C++ can look into the "tag" namespace |
| 88 | /// during ordinary lookup. |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 89 | enum IdentifierNamespace { |
Douglas Gregor | 2ce52f3 | 2008-04-13 21:07:44 +0000 | [diff] [blame] | 90 | IDNS_Label = 0x1, |
| 91 | IDNS_Tag = 0x2, |
| 92 | IDNS_Member = 0x4, |
| 93 | IDNS_Ordinary = 0x8 |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 94 | }; |
| 95 | |
| 96 | /// ObjCDeclQualifier - Qualifier used on types in method declarations |
| 97 | /// for remote messaging. They are meant for the arguments though and |
| 98 | /// applied to the Decls (ObjCMethodDecl and ParmVarDecl). |
| 99 | enum ObjCDeclQualifier { |
| 100 | OBJC_TQ_None = 0x0, |
| 101 | OBJC_TQ_In = 0x1, |
| 102 | OBJC_TQ_Inout = 0x2, |
| 103 | OBJC_TQ_Out = 0x4, |
| 104 | OBJC_TQ_Bycopy = 0x8, |
| 105 | OBJC_TQ_Byref = 0x10, |
| 106 | OBJC_TQ_Oneway = 0x20 |
| 107 | }; |
| 108 | |
| 109 | private: |
| 110 | /// Loc - The location that this decl. |
| 111 | SourceLocation Loc; |
| 112 | |
| 113 | /// DeclKind - This indicates which class this is. |
| 114 | Kind DeclKind : 8; |
| 115 | |
| 116 | /// InvalidDecl - This indicates a semantic error occurred. |
| 117 | unsigned int InvalidDecl : 1; |
| 118 | |
| 119 | /// HasAttrs - This indicates whether the decl has attributes or not. |
| 120 | unsigned int HasAttrs : 1; |
| 121 | protected: |
| 122 | Decl(Kind DK, SourceLocation L) : Loc(L), DeclKind(DK), InvalidDecl(0), |
| 123 | HasAttrs(false) { |
| 124 | if (Decl::CollectingStats()) addDeclKind(DK); |
| 125 | } |
Sam Bishop | 1bb1963 | 2008-04-11 18:04:39 +0000 | [diff] [blame] | 126 | |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 127 | virtual ~Decl(); |
Sam Bishop | 1bb1963 | 2008-04-11 18:04:39 +0000 | [diff] [blame] | 128 | |
| 129 | public: |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 130 | SourceLocation getLocation() const { return Loc; } |
| 131 | void setLocation(SourceLocation L) { Loc = L; } |
| 132 | |
| 133 | Kind getKind() const { return DeclKind; } |
| 134 | const char *getDeclKindName() const; |
| 135 | |
| 136 | void addAttr(Attr *attr); |
| 137 | const Attr *getAttrs() const; |
| 138 | |
| 139 | template<typename T> const T *getAttr() const { |
| 140 | for (const Attr *attr = getAttrs(); attr; attr = attr->getNext()) |
| 141 | if (const T *V = dyn_cast<T>(attr)) |
| 142 | return V; |
| 143 | |
| 144 | return 0; |
| 145 | } |
| 146 | |
| 147 | /// setInvalidDecl - Indicates the Decl had a semantic error. This |
| 148 | /// allows for graceful error recovery. |
| 149 | void setInvalidDecl() { InvalidDecl = 1; } |
| 150 | bool isInvalidDecl() const { return (bool) InvalidDecl; } |
| 151 | |
| 152 | IdentifierNamespace getIdentifierNamespace() const { |
| 153 | switch (DeclKind) { |
| 154 | default: assert(0 && "Unknown decl kind!"); |
| 155 | case Typedef: |
| 156 | case Function: |
Steve Naroff | 248a753 | 2008-04-15 22:42:06 +0000 | [diff] [blame] | 157 | case Var: |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 158 | case ParmVar: |
| 159 | case EnumConstant: |
| 160 | case ObjCInterface: |
| 161 | case ObjCCompatibleAlias: |
| 162 | return IDNS_Ordinary; |
| 163 | case Struct: |
| 164 | case Union: |
| 165 | case Class: |
| 166 | case Enum: |
| 167 | return IDNS_Tag; |
Argyrios Kyrtzidis | 2d1c5d3 | 2008-04-27 13:50:30 +0000 | [diff] [blame^] | 168 | case Namespace: |
| 169 | return IdentifierNamespace(IDNS_Tag | IDNS_Ordinary); |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 170 | } |
| 171 | } |
| 172 | // global temp stats (until we have a per-module visitor) |
| 173 | static void addDeclKind(Kind k); |
| 174 | static bool CollectingStats(bool Enable = false); |
| 175 | static void PrintStats(); |
| 176 | |
| 177 | // Implement isa/cast/dyncast/etc. |
| 178 | static bool classof(const Decl *) { return true; } |
| 179 | |
| 180 | /// Emit - Serialize this Decl to Bitcode. |
| 181 | void Emit(llvm::Serializer& S) const; |
| 182 | |
| 183 | /// Create - Deserialize a Decl from Bitcode. |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 184 | static Decl* Create(llvm::Deserializer& D, ASTContext& C); |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 185 | |
Sam Bishop | bb45c51 | 2008-04-11 15:01:25 +0000 | [diff] [blame] | 186 | /// Destroy - Call destructors and release memory. |
| 187 | void Destroy(ASTContext& C) const; |
| 188 | |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 189 | protected: |
| 190 | /// EmitImpl - Provides the subclass-specific serialization logic for |
| 191 | /// serializing out a decl. |
| 192 | virtual void EmitImpl(llvm::Serializer& S) const { |
| 193 | // FIXME: This will eventually be a pure virtual function. |
| 194 | assert (false && "Not implemented."); |
| 195 | } |
| 196 | |
| 197 | void EmitInRec(llvm::Serializer& S) const; |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 198 | void ReadInRec(llvm::Deserializer& D, ASTContext& C); |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 199 | }; |
| 200 | |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 201 | /// DeclContext - This is used only as base class of specific decl types that |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 202 | /// can act as declaration contexts. These decls are: |
| 203 | /// |
Argyrios Kyrtzidis | ef17782 | 2008-04-17 14:40:12 +0000 | [diff] [blame] | 204 | /// TranslationUnitDecl |
Argyrios Kyrtzidis | 2d1c5d3 | 2008-04-27 13:50:30 +0000 | [diff] [blame^] | 205 | /// NamespaceDecl |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 206 | /// FunctionDecl |
| 207 | /// ObjCMethodDecl |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 208 | /// EnumDecl |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 209 | /// ObjCInterfaceDecl |
| 210 | /// |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 211 | class DeclContext { |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 212 | /// DeclKind - This indicates which class this is. |
| 213 | Decl::Kind DeclKind : 8; |
| 214 | |
| 215 | // Used in the CastTo template to get the DeclKind |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 216 | // from a Decl or a DeclContext. DeclContext doesn't have a getKind() method |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 217 | // to avoid 'ambiguous access' compiler errors. |
| 218 | template<typename T> struct KindTrait { |
| 219 | static Decl::Kind getKind(const T *D) { return D->getKind(); } |
| 220 | }; |
| 221 | |
| 222 | // Used only by the ToDecl and FromDecl methods |
| 223 | template<typename To, typename From> |
| 224 | static To *CastTo(const From *D) { |
| 225 | Decl::Kind DK = KindTrait<From>::getKind(D); |
| 226 | switch(DK) { |
Argyrios Kyrtzidis | ef17782 | 2008-04-17 14:40:12 +0000 | [diff] [blame] | 227 | case Decl::TranslationUnit: |
| 228 | return static_cast<TranslationUnitDecl*>(const_cast<From*>(D)); |
Argyrios Kyrtzidis | 2d1c5d3 | 2008-04-27 13:50:30 +0000 | [diff] [blame^] | 229 | case Decl::Namespace: |
| 230 | return static_cast<NamespaceDecl*>(const_cast<From*>(D)); |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 231 | case Decl::Function: |
| 232 | return static_cast<FunctionDecl*>(const_cast<From*>(D)); |
| 233 | case Decl::ObjCMethod: |
| 234 | return static_cast<ObjCMethodDecl*>(const_cast<From*>(D)); |
| 235 | case Decl::ObjCInterface: |
| 236 | return static_cast<ObjCInterfaceDecl*>(const_cast<From*>(D)); |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 237 | case Decl::Enum: |
| 238 | return static_cast<EnumDecl*>(const_cast<From*>(D)); |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 239 | default: |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 240 | assert(false && "a decl that inherits DeclContext isn't handled"); |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 241 | return 0; |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | protected: |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 246 | DeclContext(Decl::Kind K) : DeclKind(K) {} |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 247 | |
| 248 | public: |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 249 | /// getParent - Returns the containing DeclContext if this is a ScopedDecl, |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 250 | /// else returns NULL. |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 251 | DeclContext *getParent() const; |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 252 | |
| 253 | bool isFunctionOrMethod() const { |
| 254 | switch (DeclKind) { |
| 255 | case Decl::Function: |
| 256 | case Decl::ObjCMethod: |
| 257 | return true; |
| 258 | default: |
| 259 | return false; |
| 260 | } |
| 261 | } |
| 262 | |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 263 | /// ToDecl and FromDecl make Decl <-> DeclContext castings. |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 264 | /// They are intended to be used by the simplify_type and cast_convert_val |
| 265 | /// templates. |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 266 | static Decl *ToDecl (const DeclContext *D); |
| 267 | static DeclContext *FromDecl (const Decl *D); |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 268 | |
| 269 | static bool classof(const Decl *D) { |
| 270 | switch (D->getKind()) { |
Argyrios Kyrtzidis | ef17782 | 2008-04-17 14:40:12 +0000 | [diff] [blame] | 271 | case Decl::TranslationUnit: |
Argyrios Kyrtzidis | 2d1c5d3 | 2008-04-27 13:50:30 +0000 | [diff] [blame^] | 272 | case Decl::Namespace: |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 273 | case Decl::Function: |
| 274 | case Decl::ObjCMethod: |
| 275 | case Decl::ObjCInterface: |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 276 | case Decl::Enum: |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 277 | return true; |
| 278 | default: |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 279 | return false; |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 280 | } |
| 281 | } |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 282 | static bool classof(const DeclContext *D) { return true; } |
Argyrios Kyrtzidis | ef17782 | 2008-04-17 14:40:12 +0000 | [diff] [blame] | 283 | static bool classof(const TranslationUnitDecl *D) { return true; } |
Argyrios Kyrtzidis | 2d1c5d3 | 2008-04-27 13:50:30 +0000 | [diff] [blame^] | 284 | static bool classof(const NamespaceDecl *D) { return true; } |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 285 | static bool classof(const FunctionDecl *D) { return true; } |
| 286 | static bool classof(const ObjCMethodDecl *D) { return true; } |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 287 | static bool classof(const EnumDecl *D) { return true; } |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 288 | static bool classof(const ObjCInterfaceDecl *D) { return true; } |
| 289 | }; |
| 290 | |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 291 | template<> struct DeclContext::KindTrait<DeclContext> { |
| 292 | static Decl::Kind getKind(const DeclContext *D) { return D->DeclKind; } |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 293 | }; |
| 294 | |
| 295 | } // end clang. |
| 296 | |
| 297 | namespace llvm { |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 298 | /// Implement simplify_type for DeclContext, so that we can dyn_cast from |
| 299 | /// DeclContext to a specific Decl class. |
| 300 | template<> struct simplify_type<const ::clang::DeclContext*> { |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 301 | typedef ::clang::Decl* SimpleType; |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 302 | static SimpleType getSimplifiedValue(const ::clang::DeclContext *Val) { |
| 303 | return ::clang::DeclContext::ToDecl(Val); |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 304 | } |
| 305 | }; |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 306 | template<> struct simplify_type< ::clang::DeclContext*> |
| 307 | : public simplify_type<const ::clang::DeclContext*> {}; |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 308 | |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 309 | template<> struct simplify_type<const ::clang::DeclContext> { |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 310 | typedef ::clang::Decl SimpleType; |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 311 | static SimpleType &getSimplifiedValue(const ::clang::DeclContext &Val) { |
| 312 | return *::clang::DeclContext::ToDecl(&Val); |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 313 | } |
| 314 | }; |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 315 | template<> struct simplify_type< ::clang::DeclContext> |
| 316 | : public simplify_type<const ::clang::DeclContext> {}; |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 317 | |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 318 | /// Implement cast_convert_val for DeclContext, so that we can dyn_cast from |
| 319 | /// a Decl class to DeclContext. |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 320 | template<class FromTy> |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 321 | struct cast_convert_val< ::clang::DeclContext,const FromTy,const FromTy> { |
| 322 | static ::clang::DeclContext &doit(const FromTy &Val) { |
| 323 | return *::clang::DeclContext::FromDecl(&Val); |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 324 | } |
| 325 | }; |
| 326 | template<class FromTy> |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 327 | struct cast_convert_val< ::clang::DeclContext,FromTy,FromTy> |
| 328 | : public cast_convert_val< ::clang::DeclContext,const FromTy,const FromTy> |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 329 | {}; |
| 330 | |
| 331 | template<class FromTy> |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 332 | struct cast_convert_val< ::clang::DeclContext,const FromTy*,const FromTy*> { |
| 333 | static ::clang::DeclContext *doit(const FromTy *Val) { |
| 334 | return ::clang::DeclContext::FromDecl(Val); |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 335 | } |
| 336 | }; |
| 337 | template<class FromTy> |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 338 | struct cast_convert_val< ::clang::DeclContext,FromTy*,FromTy*> |
| 339 | : public cast_convert_val< ::clang::DeclContext,const FromTy*,const FromTy*> |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 340 | {}; |
| 341 | |
| 342 | } // end namespace llvm |
| 343 | |
| 344 | #endif |