Add initial support for constant CFStrings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41136 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp
index 899f9c6..7293d45 100644
--- a/AST/ASTContext.cpp
+++ b/AST/ASTContext.cpp
@@ -740,3 +740,32 @@
return signedType;
}
}
+
+// getCFConstantStringType - Return the type used for constant CFStrings.
+QualType ASTContext::getCFConstantStringType() {
+ if (!CFConstantStringTypeDecl) {
+ CFConstantStringTypeDecl = new RecordDecl(Decl::Struct, SourceLocation(),
+ &Idents.get("__builtin_CFString"),
+ 0);
+
+ QualType FieldTypes[4];
+
+ // const int *isa;
+ FieldTypes[0] = getPointerType(IntTy.getQualifiedType(QualType::Const));
+ // int flags;
+ FieldTypes[1] = IntTy;
+ // const char *str;
+ FieldTypes[2] = getPointerType(CharTy.getQualifiedType(QualType::Const));
+ // long length;
+ FieldTypes[3] = LongTy;
+ // Create fields
+ FieldDecl *FieldDecls[4];
+
+ for (unsigned i = 0; i < 4; ++i)
+ FieldDecls[i] = new FieldDecl(SourceLocation(), 0, FieldTypes[i], 0);
+
+ CFConstantStringTypeDecl->defineBody(FieldDecls, 4);
+ }
+
+ return getTagDeclType(CFConstantStringTypeDecl);
+}