diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-08-12 06:49:56 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-08-12 06:49:56 +0000 |
commit | 772eeaefef2c883aabe35caf4543e7e32d290183 (patch) | |
tree | 299f422e4a3d88e33e9ad8392a60534dd1ef6b4c /lib/Sema/Sema.cpp | |
parent | b9326ec09d7cf5fcc62c9485469c9375b87507de (diff) |
Switch the __int128_t and __uint128_t types over to predefined types
in the AST format, which are built lazily by the ASTContext when
requested.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137437 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/Sema.cpp')
-rw-r--r-- | lib/Sema/Sema.cpp | 56 |
1 files changed, 24 insertions, 32 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index a4abae42ac..657f2d92e3 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -60,39 +60,17 @@ void Sema::ActOnTranslationUnitScope(Scope *S) { VAListTagName = PP.getIdentifierInfo("__va_list_tag"); - if (!Context.isInt128Installed() && // May be set by ASTReader. - PP.getTargetInfo().getPointerWidth(0) >= 64) { - TypeSourceInfo *TInfo; - - // Install [u]int128_t for 64-bit targets. - TInfo = Context.getTrivialTypeSourceInfo(Context.Int128Ty); - PushOnScopeChains(TypedefDecl::Create(Context, CurContext, - SourceLocation(), - SourceLocation(), - &Context.Idents.get("__int128_t"), - TInfo), TUScope); - - TInfo = Context.getTrivialTypeSourceInfo(Context.UnsignedInt128Ty); - PushOnScopeChains(TypedefDecl::Create(Context, CurContext, - SourceLocation(), - SourceLocation(), - &Context.Idents.get("__uint128_t"), - TInfo), TUScope); - Context.setInt128Installed(); + if (PP.getLangOptions().ObjC1) { + // Synthesize "@class Protocol; + if (Context.getObjCProtoType().isNull()) { + ObjCInterfaceDecl *ProtocolDecl = + ObjCInterfaceDecl::Create(Context, CurContext, SourceLocation(), + &Context.Idents.get("Protocol"), + SourceLocation(), true); + Context.setObjCProtoType(Context.getObjCInterfaceType(ProtocolDecl)); + PushOnScopeChains(ProtocolDecl, TUScope, false); + } } - - - if (!PP.getLangOptions().ObjC1) return; - - // Synthesize "@class Protocol; - if (Context.getObjCProtoType().isNull()) { - ObjCInterfaceDecl *ProtocolDecl = - ObjCInterfaceDecl::Create(Context, CurContext, SourceLocation(), - &Context.Idents.get("Protocol"), - SourceLocation(), true); - Context.setObjCProtoType(Context.getObjCInterfaceType(ProtocolDecl)); - PushOnScopeChains(ProtocolDecl, TUScope, false); - } } Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, @@ -142,6 +120,20 @@ void Sema::Initialize() { = dyn_cast_or_null<ExternalSemaSource>(Context.getExternalSource())) ExternalSema->InitializeSema(*this); + // Initialize predefined 128-bit integer types, if needed. + if (PP.getTargetInfo().getPointerWidth(0) >= 64) { + // If either of the 128-bit integer types are unavailable to name lookup, + // define them now. + DeclarationName Int128 = &Context.Idents.get("__int128_t"); + if (IdentifierResolver::begin(Int128) == IdentifierResolver::end()) + PushOnScopeChains(Context.getInt128Decl(), TUScope); + + DeclarationName UInt128 = &Context.Idents.get("__uint128_t"); + if (IdentifierResolver::begin(UInt128) == IdentifierResolver::end()) + PushOnScopeChains(Context.getUInt128Decl(), TUScope); + } + + // Initialize predefined Objective-C types: if (PP.getLangOptions().ObjC1) { // If 'SEL' does not yet refer to any declarations, make it refer to the |