TemplateTemplateParmDecl *
getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const;
- /// \brief Whether __[u]int128_t identifier is installed.
- bool IsInt128Installed;
+ /// \brief The typedef for the __int128_t type.
+ mutable TypedefDecl *Int128Decl;
+ /// \brief The typedef for the __uint128_t type.
+ mutable TypedefDecl *UInt128Decl;
+
/// BuiltinVaListType - built-in va list type.
/// This is initially null and set by Sema::LazilyCreateBuiltin when
/// a builtin that takes a valist is encountered.
void PrintStats() const;
const std::vector<Type*>& getTypes() const { return Types; }
+ /// \brief Retrieve the declaration for the 128-bit signed integer type.
+ TypedefDecl *getInt128Decl() const;
+
+ /// \brief Retrieve the declaration for the 128-bit unsigned integer type.
+ TypedefDecl *getUInt128Decl() const;
+
//===--------------------------------------------------------------------===//
// Type Constructors
//===--------------------------------------------------------------------===//
/// purpose in characters.
CharUnits getObjCEncodingTypeSize(QualType t) const;
- /// \brief Whether __[u]int128_t identifier is installed.
- bool isInt128Installed() const { return IsInt128Installed; }
- void setInt128Installed() { IsInt128Installed = true; }
-
/// \brief Retrieve the typedef corresponding to the predefined 'id' type
/// in Objective-C.
TypedefDecl *getObjCIdDecl() const;
/// \brief Objective-C "Class" redefinition type
SPECIAL_TYPE_OBJC_CLASS_REDEFINITION = 7,
/// \brief Objective-C "SEL" redefinition type
- SPECIAL_TYPE_OBJC_SEL_REDEFINITION = 8,
- /// \brief Whether __[u]int128_t identifier is installed.
- SPECIAL_TYPE_INT128_INSTALLED = 9
+ SPECIAL_TYPE_OBJC_SEL_REDEFINITION = 8
};
/// \brief Predefined declaration IDs.
PREDEF_DECL_OBJC_SEL_ID = 3,
/// \brief The Objective-C 'Class' type.
- PREDEF_DECL_OBJC_CLASS_ID = 4
+ PREDEF_DECL_OBJC_CLASS_ID = 4,
+
+ /// \brief The signed 128-bit integer type.
+ PREDEF_DECL_INT_128_ID = 5,
+
+ /// \brief The unsigned 128-bit integer type.
+ PREDEF_DECL_UNSIGNED_INT_128_ID = 6
};
/// \brief The number of declaration IDs that are predefined.
///
/// For more information about predefined declarations, see the
/// \c PredefinedDeclIDs type and the PREDEF_DECL_*_ID constants.
- const unsigned int NUM_PREDEF_DECL_IDS = 5;
+ const unsigned int NUM_PREDEF_DECL_IDS = 7;
/// \brief Record codes for each kind of declaration.
///
TemplateSpecializationTypes(this_()),
DependentTemplateSpecializationTypes(this_()),
SubstTemplateTemplateParmPacks(this_()),
- GlobalNestedNameSpecifier(0), IsInt128Installed(false),
+ GlobalNestedNameSpecifier(0),
+ Int128Decl(0), UInt128Decl(0),
ObjCIdDecl(0), ObjCSelDecl(0), ObjCClassDecl(0),
CFConstantStringTypeDecl(0),
FILEDecl(0),
BumpAlloc.PrintStats();
}
+TypedefDecl *ASTContext::getInt128Decl() const {
+ if (!Int128Decl) {
+ TypeSourceInfo *TInfo = getTrivialTypeSourceInfo(Int128Ty);
+ Int128Decl = TypedefDecl::Create(const_cast<ASTContext &>(*this),
+ getTranslationUnitDecl(),
+ SourceLocation(),
+ SourceLocation(),
+ &Idents.get("__int128_t"),
+ TInfo);
+ }
+
+ return Int128Decl;
+}
+
+TypedefDecl *ASTContext::getUInt128Decl() const {
+ if (!UInt128Decl) {
+ TypeSourceInfo *TInfo = getTrivialTypeSourceInfo(UnsignedInt128Ty);
+ UInt128Decl = TypedefDecl::Create(const_cast<ASTContext &>(*this),
+ getTranslationUnitDecl(),
+ SourceLocation(),
+ SourceLocation(),
+ &Idents.get("__uint128_t"),
+ TInfo);
+ }
+
+ return UInt128Decl;
+}
void ASTContext::InitBuiltinType(CanQualType &R, BuiltinType::Kind K) {
BuiltinType *Ty = new (*this, TypeAlignment) BuiltinType(K);
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,
= 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
Context->ObjCSelRedefinitionType = GetType(ObjCSelRedef);
}
- if (SpecialTypes[SPECIAL_TYPE_INT128_INSTALLED])
- Context->setInt128Installed();
-
ReadPragmaDiagnosticMappings(Context->getDiagnostics());
// If there were any CUDA special declarations, deserialize them.
case PREDEF_DECL_OBJC_CLASS_ID:
assert(Context && "No context available?");
return Context->getObjCClassDecl();
+
+ case PREDEF_DECL_INT_128_ID:
+ assert(Context && "No context available?");
+ return Context->getInt128Decl();
+
+ case PREDEF_DECL_UNSIGNED_INT_128_ID:
+ assert(Context && "No context available?");
+ return Context->getUInt128Decl();
}
return 0;
DeclIDs[Context.ObjCSelDecl] = PREDEF_DECL_OBJC_SEL_ID;
if (Context.ObjCClassDecl)
DeclIDs[Context.ObjCClassDecl] = PREDEF_DECL_OBJC_CLASS_ID;
+ if (Context.Int128Decl)
+ DeclIDs[Context.Int128Decl] = PREDEF_DECL_INT_128_ID;
+ if (Context.UInt128Decl)
+ DeclIDs[Context.UInt128Decl] = PREDEF_DECL_UNSIGNED_INT_128_ID;
if (!Chain) {
// Make sure that we emit IdentifierInfos (and any attached
AddTypeRef(Context.ObjCIdRedefinitionType, SpecialTypes);
AddTypeRef(Context.ObjCClassRedefinitionType, SpecialTypes);
AddTypeRef(Context.ObjCSelRedefinitionType, SpecialTypes);
- SpecialTypes.push_back(Context.isInt128Installed());
// Keep writing types and declarations until all types and
// declarations have been written.