Chris Lattner | ddc135e | 2006-11-10 06:34:16 +0000 | [diff] [blame] | 1 | //===--- ASTContext.cpp - Context to hold long-lived AST nodes ------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by Chris Lattner and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the ASTContext interface. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "clang/AST/ASTContext.h" |
Chris Lattner | d0342e5 | 2006-11-20 04:02:15 +0000 | [diff] [blame] | 15 | #include "clang/AST/Decl.h" |
Chris Lattner | ddc135e | 2006-11-10 06:34:16 +0000 | [diff] [blame] | 16 | #include "clang/Lex/Preprocessor.h" |
Chris Lattner | c6ad813 | 2006-12-02 07:52:18 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/SmallVector.h" |
Steve Naroff | 6fbf0dc | 2007-03-16 00:33:25 +0000 | [diff] [blame] | 18 | |
Chris Lattner | ddc135e | 2006-11-10 06:34:16 +0000 | [diff] [blame] | 19 | using namespace llvm; |
| 20 | using namespace clang; |
| 21 | |
Chris Lattner | d5973eb | 2006-11-12 00:53:46 +0000 | [diff] [blame] | 22 | ASTContext::~ASTContext() { |
| 23 | // Deallocate all the types. |
| 24 | while (!Types.empty()) { |
Chris Lattner | c6ad813 | 2006-12-02 07:52:18 +0000 | [diff] [blame] | 25 | if (FunctionTypeProto *FT = dyn_cast<FunctionTypeProto>(Types.back())) { |
| 26 | // Destroy the object, but don't call delete. These are malloc'd. |
| 27 | FT->~FunctionTypeProto(); |
| 28 | free(FT); |
| 29 | } else { |
| 30 | delete Types.back(); |
| 31 | } |
Chris Lattner | d5973eb | 2006-11-12 00:53:46 +0000 | [diff] [blame] | 32 | Types.pop_back(); |
| 33 | } |
| 34 | } |
| 35 | |
Chris Lattner | 4eb445d | 2007-01-26 01:27:23 +0000 | [diff] [blame] | 36 | void ASTContext::PrintStats() const { |
| 37 | fprintf(stderr, "*** AST Context Stats:\n"); |
| 38 | fprintf(stderr, " %d types total.\n", (int)Types.size()); |
| 39 | unsigned NumBuiltin = 0, NumPointer = 0, NumArray = 0, NumFunctionP = 0; |
| 40 | unsigned NumFunctionNP = 0, NumTypeName = 0, NumTagged = 0; |
| 41 | |
| 42 | unsigned NumTagStruct = 0, NumTagUnion = 0, NumTagEnum = 0, NumTagClass = 0; |
| 43 | |
| 44 | for (unsigned i = 0, e = Types.size(); i != e; ++i) { |
| 45 | Type *T = Types[i]; |
| 46 | if (isa<BuiltinType>(T)) |
| 47 | ++NumBuiltin; |
| 48 | else if (isa<PointerType>(T)) |
| 49 | ++NumPointer; |
| 50 | else if (isa<ArrayType>(T)) |
| 51 | ++NumArray; |
| 52 | else if (isa<FunctionTypeNoProto>(T)) |
| 53 | ++NumFunctionNP; |
| 54 | else if (isa<FunctionTypeProto>(T)) |
| 55 | ++NumFunctionP; |
Chris Lattner | 32d920b | 2007-01-26 02:01:53 +0000 | [diff] [blame] | 56 | else if (isa<TypedefType>(T)) |
Chris Lattner | 4eb445d | 2007-01-26 01:27:23 +0000 | [diff] [blame] | 57 | ++NumTypeName; |
Steve Naroff | f1e5369 | 2007-03-23 22:27:02 +0000 | [diff] [blame] | 58 | else if (TagType *TT = dyn_cast<TagType>(T)) { |
Chris Lattner | 4eb445d | 2007-01-26 01:27:23 +0000 | [diff] [blame] | 59 | ++NumTagged; |
| 60 | switch (TT->getDecl()->getKind()) { |
| 61 | default: assert(0 && "Unknown tagged type!"); |
| 62 | case Decl::Struct: ++NumTagStruct; break; |
| 63 | case Decl::Union: ++NumTagUnion; break; |
| 64 | case Decl::Class: ++NumTagClass; break; |
| 65 | case Decl::Enum: ++NumTagEnum; break; |
| 66 | } |
| 67 | } else { |
| 68 | assert(0 && "Unknown type!"); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | fprintf(stderr, " %d builtin types\n", NumBuiltin); |
| 73 | fprintf(stderr, " %d pointer types\n", NumPointer); |
| 74 | fprintf(stderr, " %d array types\n", NumArray); |
| 75 | fprintf(stderr, " %d function types with proto\n", NumFunctionP); |
| 76 | fprintf(stderr, " %d function types with no proto\n", NumFunctionNP); |
| 77 | fprintf(stderr, " %d typename (typedef) types\n", NumTypeName); |
| 78 | fprintf(stderr, " %d tagged types\n", NumTagged); |
| 79 | fprintf(stderr, " %d struct types\n", NumTagStruct); |
| 80 | fprintf(stderr, " %d union types\n", NumTagUnion); |
| 81 | fprintf(stderr, " %d class types\n", NumTagClass); |
| 82 | fprintf(stderr, " %d enum types\n", NumTagEnum); |
Chris Lattner | 4eb445d | 2007-01-26 01:27:23 +0000 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | |
Chris Lattner | 726f97b | 2006-12-03 02:57:32 +0000 | [diff] [blame] | 86 | void ASTContext::InitBuiltinType(TypeRef &R, BuiltinType::Kind K) { |
| 87 | Types.push_back((R = new BuiltinType(K)).getTypePtr()); |
Chris Lattner | d5973eb | 2006-11-12 00:53:46 +0000 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | |
Chris Lattner | 970e54e | 2006-11-12 00:37:36 +0000 | [diff] [blame] | 91 | void ASTContext::InitBuiltinTypes() { |
| 92 | assert(VoidTy.isNull() && "Context reinitialized?"); |
| 93 | |
| 94 | // C99 6.2.5p19. |
Chris Lattner | 726f97b | 2006-12-03 02:57:32 +0000 | [diff] [blame] | 95 | InitBuiltinType(VoidTy, BuiltinType::Void); |
Chris Lattner | 970e54e | 2006-11-12 00:37:36 +0000 | [diff] [blame] | 96 | |
| 97 | // C99 6.2.5p2. |
Chris Lattner | 726f97b | 2006-12-03 02:57:32 +0000 | [diff] [blame] | 98 | InitBuiltinType(BoolTy, BuiltinType::Bool); |
Chris Lattner | 970e54e | 2006-11-12 00:37:36 +0000 | [diff] [blame] | 99 | // C99 6.2.5p3. |
Chris Lattner | 726f97b | 2006-12-03 02:57:32 +0000 | [diff] [blame] | 100 | InitBuiltinType(CharTy, BuiltinType::Char); |
Chris Lattner | 970e54e | 2006-11-12 00:37:36 +0000 | [diff] [blame] | 101 | // C99 6.2.5p4. |
Chris Lattner | 726f97b | 2006-12-03 02:57:32 +0000 | [diff] [blame] | 102 | InitBuiltinType(SignedCharTy, BuiltinType::SChar); |
| 103 | InitBuiltinType(ShortTy, BuiltinType::Short); |
| 104 | InitBuiltinType(IntTy, BuiltinType::Int); |
| 105 | InitBuiltinType(LongTy, BuiltinType::Long); |
| 106 | InitBuiltinType(LongLongTy, BuiltinType::LongLong); |
Chris Lattner | 970e54e | 2006-11-12 00:37:36 +0000 | [diff] [blame] | 107 | |
| 108 | // C99 6.2.5p6. |
Chris Lattner | 726f97b | 2006-12-03 02:57:32 +0000 | [diff] [blame] | 109 | InitBuiltinType(UnsignedCharTy, BuiltinType::UChar); |
| 110 | InitBuiltinType(UnsignedShortTy, BuiltinType::UShort); |
| 111 | InitBuiltinType(UnsignedIntTy, BuiltinType::UInt); |
| 112 | InitBuiltinType(UnsignedLongTy, BuiltinType::ULong); |
| 113 | InitBuiltinType(UnsignedLongLongTy, BuiltinType::ULongLong); |
Chris Lattner | 970e54e | 2006-11-12 00:37:36 +0000 | [diff] [blame] | 114 | |
| 115 | // C99 6.2.5p10. |
Chris Lattner | 726f97b | 2006-12-03 02:57:32 +0000 | [diff] [blame] | 116 | InitBuiltinType(FloatTy, BuiltinType::Float); |
| 117 | InitBuiltinType(DoubleTy, BuiltinType::Double); |
| 118 | InitBuiltinType(LongDoubleTy, BuiltinType::LongDouble); |
Chris Lattner | 970e54e | 2006-11-12 00:37:36 +0000 | [diff] [blame] | 119 | |
| 120 | // C99 6.2.5p11. |
Chris Lattner | 726f97b | 2006-12-03 02:57:32 +0000 | [diff] [blame] | 121 | InitBuiltinType(FloatComplexTy, BuiltinType::FloatComplex); |
| 122 | InitBuiltinType(DoubleComplexTy, BuiltinType::DoubleComplex); |
| 123 | InitBuiltinType(LongDoubleComplexTy, BuiltinType::LongDoubleComplex); |
Chris Lattner | 970e54e | 2006-11-12 00:37:36 +0000 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | /// getPointerType - Return the uniqued reference to the type for a pointer to |
| 127 | /// the specified type. |
Chris Lattner | 7ccecb9 | 2006-11-12 08:50:50 +0000 | [diff] [blame] | 128 | TypeRef ASTContext::getPointerType(TypeRef T) { |
Chris Lattner | d5973eb | 2006-11-12 00:53:46 +0000 | [diff] [blame] | 129 | // Unique pointers, to guarantee there is only one pointer of a particular |
| 130 | // structure. |
Chris Lattner | 67521df | 2007-01-27 01:29:36 +0000 | [diff] [blame] | 131 | FoldingSetNodeID ID; |
| 132 | PointerType::Profile(ID, T); |
| 133 | |
| 134 | void *InsertPos = 0; |
| 135 | if (PointerType *PT = PointerTypes.FindNodeOrInsertPos(ID, InsertPos)) |
| 136 | return PT; |
Chris Lattner | 970e54e | 2006-11-12 00:37:36 +0000 | [diff] [blame] | 137 | |
Chris Lattner | 7ccecb9 | 2006-11-12 08:50:50 +0000 | [diff] [blame] | 138 | // If the pointee type isn't canonical, this won't be a canonical type either, |
| 139 | // so fill in the canonical type field. |
Chris Lattner | 970e54e | 2006-11-12 00:37:36 +0000 | [diff] [blame] | 140 | Type *Canonical = 0; |
Chris Lattner | 67521df | 2007-01-27 01:29:36 +0000 | [diff] [blame] | 141 | if (!T->isCanonical()) { |
Chris Lattner | 970e54e | 2006-11-12 00:37:36 +0000 | [diff] [blame] | 142 | Canonical = getPointerType(T.getCanonicalType()).getTypePtr(); |
Chris Lattner | 67521df | 2007-01-27 01:29:36 +0000 | [diff] [blame] | 143 | |
| 144 | // Get the new insert position for the node we care about. |
| 145 | PointerType *NewIP = PointerTypes.FindNodeOrInsertPos(ID, InsertPos); |
| 146 | assert(NewIP == 0 && "Shouldn't be in the map!"); |
| 147 | } |
Chris Lattner | d5973eb | 2006-11-12 00:53:46 +0000 | [diff] [blame] | 148 | |
Chris Lattner | 67521df | 2007-01-27 01:29:36 +0000 | [diff] [blame] | 149 | PointerType *New = new PointerType(T, Canonical); |
| 150 | Types.push_back(New); |
| 151 | PointerTypes.InsertNode(New, InsertPos); |
| 152 | return New; |
Chris Lattner | ddc135e | 2006-11-10 06:34:16 +0000 | [diff] [blame] | 153 | } |
| 154 | |
Chris Lattner | 7ccecb9 | 2006-11-12 08:50:50 +0000 | [diff] [blame] | 155 | /// getArrayType - Return the unique reference to the type for an array of the |
| 156 | /// specified element type. |
| 157 | TypeRef ASTContext::getArrayType(TypeRef EltTy,ArrayType::ArraySizeModifier ASM, |
Steve Naroff | 408451b | 2007-02-26 22:17:12 +0000 | [diff] [blame] | 158 | unsigned EltTypeQuals, Expr *NumElts) { |
Chris Lattner | 36f8e65 | 2007-01-27 08:31:04 +0000 | [diff] [blame] | 159 | // Unique array types, to guarantee there is only one array of a particular |
Chris Lattner | 7ccecb9 | 2006-11-12 08:50:50 +0000 | [diff] [blame] | 160 | // structure. |
Chris Lattner | 36f8e65 | 2007-01-27 08:31:04 +0000 | [diff] [blame] | 161 | FoldingSetNodeID ID; |
Steve Naroff | b7d4924 | 2007-03-14 19:55:17 +0000 | [diff] [blame] | 162 | ArrayType::Profile(ID, ASM, EltTypeQuals, EltTy, NumElts); |
Steve Naroff | 408451b | 2007-02-26 22:17:12 +0000 | [diff] [blame] | 163 | |
Chris Lattner | 36f8e65 | 2007-01-27 08:31:04 +0000 | [diff] [blame] | 164 | void *InsertPos = 0; |
| 165 | if (ArrayType *ATP = ArrayTypes.FindNodeOrInsertPos(ID, InsertPos)) |
| 166 | return ATP; |
Chris Lattner | 7ccecb9 | 2006-11-12 08:50:50 +0000 | [diff] [blame] | 167 | |
| 168 | // If the element type isn't canonical, this won't be a canonical type either, |
| 169 | // so fill in the canonical type field. |
| 170 | Type *Canonical = 0; |
Chris Lattner | 36f8e65 | 2007-01-27 08:31:04 +0000 | [diff] [blame] | 171 | if (!EltTy->isCanonical()) { |
Chris Lattner | 7ccecb9 | 2006-11-12 08:50:50 +0000 | [diff] [blame] | 172 | Canonical = getArrayType(EltTy.getCanonicalType(), ASM, EltTypeQuals, |
| 173 | NumElts).getTypePtr(); |
Chris Lattner | 36f8e65 | 2007-01-27 08:31:04 +0000 | [diff] [blame] | 174 | |
| 175 | // Get the new insert position for the node we care about. |
| 176 | ArrayType *NewIP = ArrayTypes.FindNodeOrInsertPos(ID, InsertPos); |
| 177 | assert(NewIP == 0 && "Shouldn't be in the map!"); |
| 178 | } |
Chris Lattner | 7ccecb9 | 2006-11-12 08:50:50 +0000 | [diff] [blame] | 179 | |
Steve Naroff | b7d4924 | 2007-03-14 19:55:17 +0000 | [diff] [blame] | 180 | ArrayType *New = new ArrayType(EltTy, ASM, EltTypeQuals, Canonical, NumElts); |
Chris Lattner | 36f8e65 | 2007-01-27 08:31:04 +0000 | [diff] [blame] | 181 | ArrayTypes.InsertNode(New, InsertPos); |
| 182 | Types.push_back(New); |
| 183 | return New; |
Chris Lattner | 7ccecb9 | 2006-11-12 08:50:50 +0000 | [diff] [blame] | 184 | } |
| 185 | |
Chris Lattner | c6ad813 | 2006-12-02 07:52:18 +0000 | [diff] [blame] | 186 | /// getFunctionTypeNoProto - Return a K&R style C function type like 'int()'. |
| 187 | /// |
| 188 | TypeRef ASTContext::getFunctionTypeNoProto(TypeRef ResultTy) { |
Chris Lattner | c6ad813 | 2006-12-02 07:52:18 +0000 | [diff] [blame] | 189 | // Unique functions, to guarantee there is only one function of a particular |
| 190 | // structure. |
Chris Lattner | 47955de | 2007-01-27 08:37:20 +0000 | [diff] [blame] | 191 | FoldingSetNodeID ID; |
| 192 | FunctionTypeNoProto::Profile(ID, ResultTy); |
Chris Lattner | c6ad813 | 2006-12-02 07:52:18 +0000 | [diff] [blame] | 193 | |
Chris Lattner | 47955de | 2007-01-27 08:37:20 +0000 | [diff] [blame] | 194 | void *InsertPos = 0; |
| 195 | if (FunctionTypeNoProto *FT = |
| 196 | FunctionTypeNoProtos.FindNodeOrInsertPos(ID, InsertPos)) |
| 197 | return FT; |
| 198 | |
| 199 | Type *Canonical = 0; |
| 200 | if (!ResultTy->isCanonical()) { |
| 201 | Canonical =getFunctionTypeNoProto(ResultTy.getCanonicalType()).getTypePtr(); |
| 202 | |
| 203 | // Get the new insert position for the node we care about. |
| 204 | FunctionTypeNoProto *NewIP = |
| 205 | FunctionTypeNoProtos.FindNodeOrInsertPos(ID, InsertPos); |
| 206 | assert(NewIP == 0 && "Shouldn't be in the map!"); |
| 207 | } |
| 208 | |
| 209 | FunctionTypeNoProto *New = new FunctionTypeNoProto(ResultTy, Canonical); |
| 210 | Types.push_back(New); |
| 211 | FunctionTypeProtos.InsertNode(New, InsertPos); |
| 212 | return New; |
Chris Lattner | c6ad813 | 2006-12-02 07:52:18 +0000 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | /// getFunctionType - Return a normal function type with a typed argument |
| 216 | /// list. isVariadic indicates whether the argument list includes '...'. |
| 217 | TypeRef ASTContext::getFunctionType(TypeRef ResultTy, TypeRef *ArgArray, |
| 218 | unsigned NumArgs, bool isVariadic) { |
Chris Lattner | c6ad813 | 2006-12-02 07:52:18 +0000 | [diff] [blame] | 219 | // Unique functions, to guarantee there is only one function of a particular |
| 220 | // structure. |
Chris Lattner | fd4de79 | 2007-01-27 01:15:32 +0000 | [diff] [blame] | 221 | FoldingSetNodeID ID; |
| 222 | FunctionTypeProto::Profile(ID, ResultTy, ArgArray, NumArgs, isVariadic); |
| 223 | |
| 224 | void *InsertPos = 0; |
| 225 | if (FunctionTypeProto *FTP = |
| 226 | FunctionTypeProtos.FindNodeOrInsertPos(ID, InsertPos)) |
| 227 | return FTP; |
| 228 | |
Chris Lattner | c6ad813 | 2006-12-02 07:52:18 +0000 | [diff] [blame] | 229 | // Determine whether the type being created is already canonical or not. |
| 230 | bool isCanonical = ResultTy->isCanonical(); |
| 231 | for (unsigned i = 0; i != NumArgs && isCanonical; ++i) |
| 232 | if (!ArgArray[i]->isCanonical()) |
| 233 | isCanonical = false; |
| 234 | |
| 235 | // If this type isn't canonical, get the canonical version of it. |
| 236 | Type *Canonical = 0; |
| 237 | if (!isCanonical) { |
| 238 | SmallVector<TypeRef, 16> CanonicalArgs; |
| 239 | CanonicalArgs.reserve(NumArgs); |
| 240 | for (unsigned i = 0; i != NumArgs; ++i) |
| 241 | CanonicalArgs.push_back(ArgArray[i].getCanonicalType()); |
| 242 | |
| 243 | Canonical = getFunctionType(ResultTy.getCanonicalType(), |
| 244 | &CanonicalArgs[0], NumArgs, |
| 245 | isVariadic).getTypePtr(); |
Chris Lattner | fd4de79 | 2007-01-27 01:15:32 +0000 | [diff] [blame] | 246 | |
| 247 | // Get the new insert position for the node we care about. |
| 248 | FunctionTypeProto *NewIP = |
| 249 | FunctionTypeProtos.FindNodeOrInsertPos(ID, InsertPos); |
| 250 | assert(NewIP == 0 && "Shouldn't be in the map!"); |
Chris Lattner | c6ad813 | 2006-12-02 07:52:18 +0000 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | // FunctionTypeProto objects are not allocated with new because they have a |
| 254 | // variable size array (for parameter types) at the end of them. |
| 255 | FunctionTypeProto *FTP = |
| 256 | (FunctionTypeProto*)malloc(sizeof(FunctionTypeProto) + |
| 257 | (NumArgs-1)*sizeof(TypeRef)); |
| 258 | new (FTP) FunctionTypeProto(ResultTy, ArgArray, NumArgs, isVariadic, |
| 259 | Canonical); |
| 260 | |
| 261 | Types.push_back(FTP); |
Chris Lattner | fd4de79 | 2007-01-27 01:15:32 +0000 | [diff] [blame] | 262 | FunctionTypeProtos.InsertNode(FTP, InsertPos); |
Chris Lattner | c6ad813 | 2006-12-02 07:52:18 +0000 | [diff] [blame] | 263 | return FTP; |
| 264 | } |
Chris Lattner | ef51c20 | 2006-11-10 07:17:23 +0000 | [diff] [blame] | 265 | |
Chris Lattner | 32d920b | 2007-01-26 02:01:53 +0000 | [diff] [blame] | 266 | /// getTypedefType - Return the unique reference to the type for the |
Chris Lattner | d0342e5 | 2006-11-20 04:02:15 +0000 | [diff] [blame] | 267 | /// specified typename decl. |
Chris Lattner | 32d920b | 2007-01-26 02:01:53 +0000 | [diff] [blame] | 268 | TypeRef ASTContext::getTypedefType(TypedefDecl *Decl) { |
Chris Lattner | 6668fc6 | 2007-01-26 02:07:07 +0000 | [diff] [blame] | 269 | if (Decl->TypeForDecl) return Decl->TypeForDecl; |
Chris Lattner | d0342e5 | 2006-11-20 04:02:15 +0000 | [diff] [blame] | 270 | |
Chris Lattner | 6668fc6 | 2007-01-26 02:07:07 +0000 | [diff] [blame] | 271 | // FIXME: does this lose qualifiers from the typedef?? |
Steve Naroff | 6fbf0dc | 2007-03-16 00:33:25 +0000 | [diff] [blame] | 272 | Type *Canonical = Decl->getUnderlyingType().getCanonicalType().getTypePtr(); |
Chris Lattner | cceab1a | 2007-03-26 20:16:44 +0000 | [diff] [blame] | 273 | Decl->TypeForDecl = new TypedefType(Decl, Canonical); |
| 274 | Types.push_back(Decl->TypeForDecl); |
| 275 | return Decl->TypeForDecl; |
Chris Lattner | d0342e5 | 2006-11-20 04:02:15 +0000 | [diff] [blame] | 276 | } |
| 277 | |
Chris Lattner | fb07246 | 2007-01-23 05:45:31 +0000 | [diff] [blame] | 278 | /// getTagDeclType - Return the unique reference to the type for the |
| 279 | /// specified TagDecl (struct/union/class/enum) decl. |
| 280 | TypeRef ASTContext::getTagDeclType(TagDecl *Decl) { |
Chris Lattner | 733067d | 2007-01-26 01:42:24 +0000 | [diff] [blame] | 281 | // The decl stores the type cache. |
| 282 | if (Decl->TypeForDecl) return Decl->TypeForDecl; |
Chris Lattner | fb07246 | 2007-01-23 05:45:31 +0000 | [diff] [blame] | 283 | |
Chris Lattner | cceab1a | 2007-03-26 20:16:44 +0000 | [diff] [blame] | 284 | Decl->TypeForDecl = new TagType(Decl, 0); |
| 285 | Types.push_back(Decl->TypeForDecl); |
| 286 | return Decl->TypeForDecl; |
Chris Lattner | fb07246 | 2007-01-23 05:45:31 +0000 | [diff] [blame] | 287 | } |
| 288 | |
Steve Naroff | 92e30f8 | 2007-04-02 22:35:25 +0000 | [diff] [blame] | 289 | /// getSizeType - Return the unique type for "size_t" (C99 7.17), the result |
Steve Naroff | 0f6256d | 2007-04-02 23:01:44 +0000 | [diff] [blame^] | 290 | /// of the sizeof operator (C99 6.5.3.4p4). The value is target dependent and |
Steve Naroff | 92e30f8 | 2007-04-02 22:35:25 +0000 | [diff] [blame] | 291 | /// needs to agree with the definition in <stddef.h>. |
Steve Naroff | 0f6256d | 2007-04-02 23:01:44 +0000 | [diff] [blame^] | 292 | TypeRef ASTContext::getSizeType() const { |
Steve Naroff | 92e30f8 | 2007-04-02 22:35:25 +0000 | [diff] [blame] | 293 | // On Darwin, size_t is defined as a "long unsigned int". |
| 294 | // FIXME: should derive from "Target". |
| 295 | return UnsignedLongTy; |
| 296 | } |
Chris Lattner | fb07246 | 2007-01-23 05:45:31 +0000 | [diff] [blame] | 297 | |