summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2008-08-23 22:20:38 +0000
committerAnders Carlsson <andersca@mac.com>2008-08-23 22:20:38 +0000
commitfbcd85137b1a930aa4dbb5d862e9a699ba6740a5 (patch)
treeae8a741f73e1db6847d801f852b11c85868a1e59
parenteacf1d2c0f0a0ee14b810528f35ec8944acf34c0 (diff)
downloadbcm5719-llvm-fbcd85137b1a930aa4dbb5d862e9a699ba6740a5.tar.gz
bcm5719-llvm-fbcd85137b1a930aa4dbb5d862e9a699ba6740a5.zip
Make sure to create CXX record decls for the implicit Obj-C type declarations. This lets us compile Cocoa.h as Objective-C++
llvm-svn: 55261
-rw-r--r--clang/lib/Sema/Sema.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index a73743fef69..fa8ba5953cf 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -27,17 +27,25 @@ bool Sema::isBuiltinObjCType(TypedefDecl *TD) {
strcmp(typeName, "SEL") == 0 || strcmp(typeName, "Protocol") == 0;
}
+static inline RecordDecl *CreateStructDecl(ASTContext &C, const char *Name)
+{
+ if (C.getLangOptions().CPlusPlus)
+ return CXXRecordDecl::Create(C, TagDecl::TK_struct,
+ C.getTranslationUnitDecl(),
+ SourceLocation(), &C.Idents.get(Name), 0);
+ else
+ return RecordDecl::Create(C, TagDecl::TK_struct,
+ C.getTranslationUnitDecl(),
+ SourceLocation(), &C.Idents.get(Name), 0);
+}
+
void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
TUScope = S;
CurContext = Context.getTranslationUnitDecl();
if (!PP.getLangOptions().ObjC1) return;
// Synthesize "typedef struct objc_selector *SEL;"
- RecordDecl *SelTag = RecordDecl::Create(Context, TagDecl::TK_struct,
- CurContext,
- SourceLocation(),
- &Context.Idents.get("objc_selector"),
- 0);
+ RecordDecl *SelTag = CreateStructDecl(Context, "objc_selector");
PushOnScopeChains(SelTag, TUScope);
QualType SelT = Context.getPointerType(Context.getTagDeclType(SelTag));
@@ -49,11 +57,7 @@ void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
Context.setObjCSelType(SelTypedef);
// FIXME: Make sure these don't leak!
- RecordDecl *ClassTag = RecordDecl::Create(Context, TagDecl::TK_struct,
- CurContext,
- SourceLocation(),
- &Context.Idents.get("objc_class"),
- 0);
+ RecordDecl *ClassTag = CreateStructDecl(Context, "objc_class");
QualType ClassT = Context.getPointerType(Context.getTagDeclType(ClassTag));
TypedefDecl *ClassTypedef =
TypedefDecl::Create(Context, CurContext, SourceLocation(),
@@ -70,10 +74,8 @@ void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
PushOnScopeChains(ProtocolDecl, TUScope);
// Synthesize "typedef struct objc_object { Class isa; } *id;"
- RecordDecl *ObjectTag =
- RecordDecl::Create(Context, TagDecl::TK_struct, CurContext,
- SourceLocation(),
- &Context.Idents.get("objc_object"), 0);
+ RecordDecl *ObjectTag = CreateStructDecl(Context, "objc_object");
+
QualType ObjT = Context.getPointerType(Context.getTagDeclType(ObjectTag));
PushOnScopeChains(ObjectTag, TUScope);
TypedefDecl *IdTypedef = TypedefDecl::Create(Context, CurContext,
OpenPOWER on IntegriCloud