[cfe-commits] r55572 - in /cfe/trunk: include/clang/AST/ASTContext.h lib/AST/ASTContext.cpp
Anders Carlsson
andersca at mac.com
Sat Aug 30 12:34:46 PDT 2008
Author: andersca
Date: Sat Aug 30 14:34:46 2008
New Revision: 55572
URL: http://llvm.org/viewvc/llvm-project?rev=55572&view=rev
Log:
Add code to create the fast enumeration state type
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp
Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=55572&r1=55571&r2=55572&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Sat Aug 30 14:34:46 2008
@@ -94,6 +94,8 @@
QualType ObjCConstantStringType;
RecordDecl *CFConstantStringTypeDecl;
+ RecordDecl *ObjCFastEnumerationStateTypeDecl;
+
TranslationUnitDecl *TUDecl;
/// SourceMgr - The associated SourceManager object.
@@ -268,6 +270,9 @@
return ObjCConstantStringType;
}
+ //// This gets the struct used to keep track of fast enumerations.
+ QualType getObjCFastEnumerationStateType();
+
// Return the ObjC type encoding for a given type.
void getObjCEncodingForType(QualType t, std::string &S,
llvm::SmallVector<const RecordType*,8> &RT) const;
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=55572&r1=55571&r2=55572&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sat Aug 30 14:34:46 2008
@@ -30,7 +30,8 @@
ASTContext::ASTContext(const LangOptions& LOpts, SourceManager &SM, TargetInfo &t,
IdentifierTable &idents, SelectorTable &sels,
unsigned size_reserve) :
- CFConstantStringTypeDecl(0), SourceMgr(SM), LangOpts(LOpts), Target(t),
+ CFConstantStringTypeDecl(0), ObjCFastEnumerationStateTypeDecl(0),
+ SourceMgr(SM), LangOpts(LOpts), Target(t),
Idents(idents), Selectors(sels)
{
if (size_reserve > 0) Types.reserve(size_reserve);
@@ -1371,6 +1372,32 @@
return getTagDeclType(CFConstantStringTypeDecl);
}
+QualType ASTContext::getObjCFastEnumerationStateType()
+{
+ if (!ObjCFastEnumerationStateTypeDecl) {
+ QualType FieldTypes[] = {
+ UnsignedLongTy,
+ getPointerType(ObjCIdType),
+ getPointerType(UnsignedLongTy),
+ getConstantArrayType(UnsignedLongTy,
+ llvm::APInt(32, 5), ArrayType::Normal, 0)
+ };
+
+ FieldDecl *FieldDecls[4];
+ for (size_t i = 0; i < 4; ++i)
+ FieldDecls[i] = FieldDecl::Create(*this, SourceLocation(), 0,
+ FieldTypes[i]);
+
+ ObjCFastEnumerationStateTypeDecl =
+ RecordDecl::Create(*this, TagDecl::TK_struct, TUDecl, SourceLocation(),
+ &Idents.get("__objcFastEnumerationState"), 0);
+
+ ObjCFastEnumerationStateTypeDecl->defineBody(FieldDecls, 4);
+ }
+
+ return getTagDeclType(ObjCFastEnumerationStateTypeDecl);
+}
+
// This returns true if a type has been typedefed to BOOL:
// typedef <type> BOOL;
static bool isTypeTypedefedAsBOOL(QualType T) {
More information about the cfe-commits
mailing list