summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-08-09 17:23:49 +0000
committerDouglas Gregor <dgregor@apple.com>2011-08-09 17:23:49 +0000
commit636e200675277d09c4a09b31552cca9341b515e2 (patch)
treee639d488918199b7c2439a66ac60b2c6abc228b7 /clang/lib/CodeGen/CodeGenModule.cpp
parentda96006975eaf438ecec4c245a0b521c08ea594d (diff)
downloadbcm5719-llvm-636e200675277d09c4a09b31552cca9341b515e2.tar.gz
bcm5719-llvm-636e200675277d09c4a09b31552cca9341b515e2.zip
Move the creation of the record type for the state of Objective-C fast
enumerations from the ASTContext into CodeGen, so that we don't need to serialize it to AST files. This appears to be the last of the low-hanging fruit for SpecialTypes. llvm-svn: 137124
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 13c8f6080ff..d5d34634dbc 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1925,6 +1925,41 @@ CodeGenModule::GetAddrOfConstantString(const StringLiteral *Literal) {
return GV;
}
+QualType CodeGenModule::getObjCFastEnumerationStateType() {
+ if (ObjCFastEnumerationStateType.isNull()) {
+ RecordDecl *D = CreateRecordDecl(Context, TTK_Struct,
+ Context.getTranslationUnitDecl(),
+ &Context.Idents.get("__objcFastEnumerationState"));
+ D->startDefinition();
+
+ QualType FieldTypes[] = {
+ Context.UnsignedLongTy,
+ Context.getPointerType(Context.getObjCIdType()),
+ Context.getPointerType(Context.UnsignedLongTy),
+ Context.getConstantArrayType(Context.UnsignedLongTy,
+ llvm::APInt(32, 5), ArrayType::Normal, 0)
+ };
+
+ for (size_t i = 0; i < 4; ++i) {
+ FieldDecl *Field = FieldDecl::Create(Context,
+ D,
+ SourceLocation(),
+ SourceLocation(), 0,
+ FieldTypes[i], /*TInfo=*/0,
+ /*BitWidth=*/0,
+ /*Mutable=*/false,
+ /*HasInit=*/false);
+ Field->setAccess(AS_public);
+ D->addDecl(Field);
+ }
+
+ D->completeDefinition();
+ ObjCFastEnumerationStateType = Context.getTagDeclType(D);
+ }
+
+ return ObjCFastEnumerationStateType;
+}
+
/// GetStringForStringLiteral - Return the appropriate bytes for a
/// string literal, properly padded to match the literal type.
std::string CodeGenModule::GetStringForStringLiteral(const StringLiteral *E) {
OpenPOWER on IntegriCloud