aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2008-09-09 14:32:20 +0000
committerSteve Naroff <snaroff@apple.com>2008-09-09 14:32:20 +0000
commit2b255c4dabe6a04314e3659a0f8b61e1382ec287 (patch)
treee70c6d4d8621f4684aa98b5c36591d6c6fb5b7c8 /lib/Sema/SemaDecl.cpp
parent3c1b91223908f1848622c3da21beced6d42371d4 (diff)
Tweak implementation for allowing ObjC builtin type redefinitions.
- Replace string comparisons with pre-defined idents. - Avoid calling isBuiltinObjCType() to avoid two checks. - Remove isBuiltinObjCType(), since it was only used in Sema::MergeTypeDefDecl(). - Have Sema::MergeTypeDefDecl() set the new type. This is a moidified version of an patch by David Chisnall. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55990 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index cf84bcc5e1..40008579a9 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -230,6 +230,25 @@ ScopedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid,
/// situation, merging decls or emitting diagnostics as appropriate.
///
TypedefDecl *Sema::MergeTypeDefDecl(TypedefDecl *New, Decl *OldD) {
+ // Allow multiple definitions for ObjC built-in typedefs.
+ // FIXME: Verify the underlying types are equivalent!
+ if (getLangOptions().ObjC1) {
+ const IdentifierInfo *typeIdent = New->getIdentifier();
+ if (typeIdent == Ident_id) {
+ Context.setObjCIdType(New);
+ return New;
+ } else if (typeIdent == Ident_Class) {
+ Context.setObjCClassType(New);
+ return New;
+ } else if (typeIdent == Ident_SEL) {
+ Context.setObjCSelType(New);
+ return New;
+ } else if (typeIdent == Ident_Protocol) {
+ Context.setObjCProtoType(New->getUnderlyingType());
+ return New;
+ }
+ // Fall through - the typedef name was not a builtin type.
+ }
// Verify the old decl was also a typedef.
TypedefDecl *Old = dyn_cast<TypedefDecl>(OldD);
if (!Old) {
@@ -251,11 +270,6 @@ TypedefDecl *Sema::MergeTypeDefDecl(TypedefDecl *New, Decl *OldD) {
return Old;
}
- // Allow multiple definitions for ObjC built-in typedefs.
- // FIXME: Verify the underlying types are equivalent!
- if (getLangOptions().ObjC1 && isBuiltinObjCType(New))
- return Old;
-
if (getLangOptions().Microsoft) return New;
// Redeclaration of a type is a constraint violation (6.7.2.3p1).