aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/Sema.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-08-12 06:17:30 +0000
committerDouglas Gregor <dgregor@apple.com>2011-08-12 06:17:30 +0000
commit7a27ea52b7bd635c89bec5a9c521a3bf7d204238 (patch)
treee89f1ae41b586aebd3ce40519a07f055d8b670e4 /lib/Sema/Sema.cpp
parent79d6726921897811232554ed94c5d77b5b7b3fc0 (diff)
Switch the Objective-C 'SEL' type over to a predefined type in the
AST file format, lazily generating the actual declaration in ASTContext as needed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137434 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/Sema.cpp')
-rw-r--r--lib/Sema/Sema.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index 2377d186ef..a4abae42ac 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -84,19 +84,6 @@ void Sema::ActOnTranslationUnitScope(Scope *S) {
if (!PP.getLangOptions().ObjC1) return;
- // Built-in ObjC types may already be set by ASTReader (hence isNull checks).
- if (Context.getObjCSelType().isNull()) {
- // Create the built-in typedef for 'SEL'.
- QualType SelT = Context.getPointerType(Context.ObjCBuiltinSelTy);
- TypeSourceInfo *SelInfo = Context.getTrivialTypeSourceInfo(SelT);
- TypedefDecl *SelTypedef
- = TypedefDecl::Create(Context, CurContext,
- SourceLocation(), SourceLocation(),
- &Context.Idents.get("SEL"), SelInfo);
- PushOnScopeChains(SelTypedef, TUScope);
- Context.setObjCSelType(Context.getTypeDeclType(SelTypedef));
- }
-
// Synthesize "@class Protocol;
if (Context.getObjCProtoType().isNull()) {
ObjCInterfaceDecl *ProtocolDecl =
@@ -157,6 +144,12 @@ void Sema::Initialize() {
// Initialize predefined Objective-C types:
if (PP.getLangOptions().ObjC1) {
+ // If 'SEL' does not yet refer to any declarations, make it refer to the
+ // predefined 'SEL'.
+ DeclarationName SEL = &Context.Idents.get("SEL");
+ if (IdentifierResolver::begin(SEL) == IdentifierResolver::end())
+ PushOnScopeChains(Context.getObjCSelDecl(), TUScope);
+
// If 'id' does not yet refer to any declarations, make it refer to the
// predefined 'id'.
DeclarationName Id = &Context.Idents.get("id");