diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-09-02 00:18:52 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-09-02 00:18:52 +0000 |
commit | bcfd1f55bfbb3e5944cd5e03d07b343e280838c4 (patch) | |
tree | 838fe1b34f86ca6cbebba50b771d5f6556988440 | |
parent | 998b3d3e8528ebd9d2c5d78d3a82edd90a8953a4 (diff) |
Extend the ASTContext constructor to delay the initialization of
builtin types (When requested). This is another step toward making
ASTUnit build the ASTContext as needed when loading an AST file,
rather than doing so after the fact. No actual functionality change (yet).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138985 91177308-0d34-0410-b5e6-96231b3b80d8
42 files changed, 258 insertions, 227 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index 7d034478f3..e46cc6dc1f 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -332,14 +332,14 @@ class ASTContext : public llvm::RefCountedBase<ASTContext> { CXXABI *createCXXABI(const TargetInfo &T); /// \brief The logical -> physical address space map. - const LangAS::Map &AddrSpaceMap; + const LangAS::Map *AddrSpaceMap; friend class ASTDeclReader; friend class ASTReader; friend class ASTWriter; + const TargetInfo *Target; public: - const TargetInfo &Target; IdentifierTable &Idents; SelectorTable &Selectors; Builtin::Context &BuiltinInfo; @@ -367,6 +367,8 @@ public: return DiagAllocator; } + const TargetInfo &getTargetInfo() const { return *Target; } + const LangOptions& getLangOptions() const { return LangOpts; } Diagnostic &getDiagnostics() const; @@ -478,10 +480,11 @@ public: mutable QualType AutoDeductTy; // Deduction against 'auto'. mutable QualType AutoRRefDeductTy; // Deduction against 'auto &&'. - ASTContext(LangOptions& LOpts, SourceManager &SM, const TargetInfo &t, + ASTContext(LangOptions& LOpts, SourceManager &SM, const TargetInfo *t, IdentifierTable &idents, SelectorTable &sels, Builtin::Context &builtins, - unsigned size_reserve); + unsigned size_reserve, + bool DelayInitialization = false); ~ASTContext(); @@ -1425,7 +1428,7 @@ public: if (AS < LangAS::Offset || AS >= LangAS::Offset + LangAS::Count) return AS; else - return AddrSpaceMap[AS - LangAS::Offset]; + return (*AddrSpaceMap)[AS - LangAS::Offset]; } private: @@ -1645,7 +1648,18 @@ private: ASTContext(const ASTContext&); // DO NOT IMPLEMENT void operator=(const ASTContext&); // DO NOT IMPLEMENT - void InitBuiltinTypes(); +public: + /// \brief Initialize built-in types. + /// + /// This routine may only be invoked once for a given ASTContext object. + /// It is normally invoked by the ASTContext constructor. However, the + /// constructor can be asked to delay initialization, which places the burden + /// of calling this function on the user of that object. + /// + /// \param Target The target + void InitBuiltinTypes(const TargetInfo &Target); + +private: void InitBuiltinType(CanQualType &R, BuiltinType::Kind K); // Return the ObjC type encoding for a given type. diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 3406be552c..c300894456 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -196,7 +196,7 @@ CXXABI *ASTContext::createCXXABI(const TargetInfo &T) { return 0; } -static const LangAS::Map &getAddressSpaceMap(const TargetInfo &T, +static const LangAS::Map *getAddressSpaceMap(const TargetInfo &T, const LangOptions &LOpts) { if (LOpts.FakeAddressSpaceMap) { // The fake address space map must have a distinct entry for each @@ -206,40 +206,46 @@ static const LangAS::Map &getAddressSpaceMap(const TargetInfo &T, 2, // opencl_local 3 // opencl_constant }; - return FakeAddrSpaceMap; + return &FakeAddrSpaceMap; } else { - return T.getAddressSpaceMap(); + return &T.getAddressSpaceMap(); } } ASTContext::ASTContext(LangOptions& LOpts, SourceManager &SM, - const TargetInfo &t, + const TargetInfo *t, IdentifierTable &idents, SelectorTable &sels, Builtin::Context &builtins, - unsigned size_reserve) : - FunctionProtoTypes(this_()), - TemplateSpecializationTypes(this_()), - DependentTemplateSpecializationTypes(this_()), - SubstTemplateTemplateParmPacks(this_()), - GlobalNestedNameSpecifier(0), - Int128Decl(0), UInt128Decl(0), - ObjCIdDecl(0), ObjCSelDecl(0), ObjCClassDecl(0), - CFConstantStringTypeDecl(0), - FILEDecl(0), - jmp_bufDecl(0), sigjmp_bufDecl(0), BlockDescriptorType(0), - BlockDescriptorExtendedType(0), cudaConfigureCallDecl(0), - NullTypeSourceInfo(QualType()), - SourceMgr(SM), LangOpts(LOpts), ABI(createCXXABI(t)), - AddrSpaceMap(getAddressSpaceMap(t, LOpts)), Target(t), - Idents(idents), Selectors(sels), - BuiltinInfo(builtins), - DeclarationNames(*this), - ExternalSource(0), Listener(0), PrintingPolicy(LOpts), - LastSDM(0, 0), - UniqueBlockByRefTypeID(0) { + unsigned size_reserve, + bool DelayInitialization) + : FunctionProtoTypes(this_()), + TemplateSpecializationTypes(this_()), + DependentTemplateSpecializationTypes(this_()), + SubstTemplateTemplateParmPacks(this_()), + GlobalNestedNameSpecifier(0), + Int128Decl(0), UInt128Decl(0), + ObjCIdDecl(0), ObjCSelDecl(0), ObjCClassDecl(0), + CFConstantStringTypeDecl(0), + FILEDecl(0), + jmp_bufDecl(0), sigjmp_bufDecl(0), BlockDescriptorType(0), + BlockDescriptorExtendedType(0), cudaConfigureCallDecl(0), + NullTypeSourceInfo(QualType()), + SourceMgr(SM), LangOpts(LOpts), + AddrSpaceMap(0), Target(t), + Idents(idents), Selectors(sels), + BuiltinInfo(builtins), + DeclarationNames(*this), + ExternalSource(0), Listener(0), PrintingPolicy(LOpts), + LastSDM(0, 0), + UniqueBlockByRefTypeID(0) +{ if (size_reserve > 0) Types.reserve(size_reserve); TUDecl = TranslationUnitDecl::Create(*this); - InitBuiltinTypes(); + + if (!DelayInitialization) { + assert(t && "No target supplied for ASTContext initialization"); + InitBuiltinTypes(*t); + } } ASTContext::~ASTContext() { @@ -381,9 +387,16 @@ void ASTContext::InitBuiltinType(CanQualType &R, BuiltinType::Kind K) { Types.push_back(Ty); } -void ASTContext::InitBuiltinTypes() { +void ASTContext::InitBuiltinTypes(const TargetInfo &Target) { + assert((!this->Target || this->Target == &Target) && + "Incorrect target reinitialization"); assert(VoidTy.isNull() && "Context reinitialized?"); + this->Target = &Target; + + ABI.reset(createCXXABI(Target)); + AddrSpaceMap = getAddressSpaceMap(Target, LangOpts); + // C99 6.2.5p19. InitBuiltinType(VoidTy, BuiltinType::Void); @@ -670,9 +683,9 @@ const llvm::fltSemantics &ASTContext::getFloatTypeSemantics(QualType T) const { assert(BT && "Not a floating point type!"); switch (BT->getKind()) { default: assert(0 && "Not a floating point type!"); - case BuiltinType::Float: return Target.getFloatFormat(); - case BuiltinType::Double: return Target.getDoubleFormat(); - case BuiltinType::LongDouble: return Target.getLongDoubleFormat(); + case BuiltinType::Float: return Target->getFloatFormat(); + case BuiltinType::Double: return Target->getDoubleFormat(); + case BuiltinType::LongDouble: return Target->getLongDoubleFormat(); } } @@ -682,7 +695,7 @@ const llvm::fltSemantics &ASTContext::getFloatTypeSemantics(QualType T) const { /// If @p RefAsPointee, references are treated like their underlying type /// (for alignof), else they're treated like pointers (for CodeGen). CharUnits ASTContext::getDeclAlign(const Decl *D, bool RefAsPointee) const { - unsigned Align = Target.getCharWidth(); + unsigned Align = Target->getCharWidth(); bool UseAlignAttrOnly = false; if (unsigned AlignFromAttr = D->getMaxAlignment()) { @@ -722,14 +735,14 @@ CharUnits ASTContext::getDeclAlign(const Decl *D, bool RefAsPointee) const { if (!T->isIncompleteType() && !T->isFunctionType()) { // Adjust alignments of declarations with array type by the // large-array alignment on the target. - unsigned MinWidth = Target.getLargeArrayMinWidth(); + unsigned MinWidth = Target->getLargeArrayMinWidth(); const ArrayType *arrayType; if (MinWidth && (arrayType = getAsArrayType(T))) { if (isa<VariableArrayType>(arrayType)) - Align = std::max(Align, Target.getLargeArrayAlign()); + Align = std::max(Align, Target->getLargeArrayAlign()); else if (isa<ConstantArrayType>(arrayType) && MinWidth <= getTypeSize(cast<ConstantArrayType>(arrayType))) - Align = std::max(Align, Target.getLargeArrayAlign()); + Align = std::max(Align, Target->getLargeArrayAlign()); // Walk through any array types while we're at it. T = getBaseElementType(arrayType); @@ -844,48 +857,48 @@ ASTContext::getTypeInfo(const Type *T) const { break; case BuiltinType::Bool: - Width = Target.getBoolWidth(); - Align = Target.getBoolAlign(); + Width = Target->getBoolWidth(); + Align = Target->getBoolAlign(); break; case BuiltinType::Char_S: case BuiltinType::Char_U: case BuiltinType::UChar: case BuiltinType::SChar: - Width = Target.getCharWidth(); - Align = Target.getCharAlign(); + Width = Target->getCharWidth(); + Align = Target->getCharAlign(); break; case BuiltinType::WChar_S: case BuiltinType::WChar_U: - Width = Target.getWCharWidth(); - Align = Target.getWCharAlign(); + Width = Target->getWCharWidth(); + Align = Target->getWCharAlign(); break; case BuiltinType::Char16: - Width = Target.getChar16Width(); - Align = Target.getChar16Align(); + Width = Target->getChar16Width(); + Align = Target->getChar16Align(); break; case BuiltinType::Char32: - Width = Target.getChar32Width(); - Align = Target.getChar32Align(); + Width = Target->getChar32Width(); + Align = Target->getChar32Align(); break; case BuiltinType::UShort: case BuiltinType::Short: - Width = Target.getShortWidth(); - Align = Target.getShortAlign(); + Width = Target->getShortWidth(); + Align = Target->getShortAlign(); break; case BuiltinType::UInt: case BuiltinType::Int: - Width = Target.getIntWidth(); - Align = Target.getIntAlign(); + Width = Target->getIntWidth(); + Align = Target->getIntAlign(); break; case BuiltinType::ULong: case BuiltinType::Long: - Width = Target.getLongWidth(); - Align = Target.getLongAlign(); + Width = Target->getLongWidth(); + Align = Target->getLongAlign(); break; case BuiltinType::ULongLong: case BuiltinType::LongLong: - Width = Target.getLongLongWidth(); - Align = Target.getLongLongAlign(); + Width = Target->getLongLongWidth(); + Align = Target->getLongLongAlign(); break; case BuiltinType::Int128: case BuiltinType::UInt128: @@ -893,38 +906,38 @@ ASTContext::getTypeInfo(const Type *T) const { Align = 128; // int128_t is 128-bit aligned on all targets. break; case BuiltinType::Float: - Width = Target.getFloatWidth(); - Align = Target.getFloatAlign(); + Width = Target->getFloatWidth(); + Align = Target->getFloatAlign(); break; case BuiltinType::Double: - Width = Target.getDoubleWidth(); - Align = Target.getDoubleAlign(); + Width = Target->getDoubleWidth(); + Align = Target->getDoubleAlign(); break; case BuiltinType::LongDouble: - Width = Target.getLongDoubleWidth(); - Align = Target.getLongDoubleAlign(); + Width = Target->getLongDoubleWidth(); + Align = Target->getLongDoubleAlign(); break; case BuiltinType::NullPtr: - Width = Target.getPointerWidth(0); // C++ 3.9.1p11: sizeof(nullptr_t) - Align = Target.getPointerAlign(0); // == sizeof(void*) + Width = Target->getPointerWidth(0); // C++ 3.9.1p11: sizeof(nullptr_t) + Align = Target->getPointerAlign(0); // == sizeof(void*) break; case BuiltinType::ObjCId: case BuiltinType::ObjCClass: case BuiltinType::ObjCSel: - Width = Target.getPointerWidth(0); - Align = Target.getPointerAlign(0); + Width = Target->getPointerWidth(0); + Align = Target->getPointerAlign(0); break; } break; case Type::ObjCObjectPointer: - Width = Target.getPointerWidth(0); - Align = Target.getPointerAlign(0); + Width = Target->getPointerWidth(0); + Align = Target->getPointerAlign(0); break; case Type::BlockPointer: { unsigned AS = getTargetAddressSpace( cast<BlockPointerType>(T)->getPointeeType()); - Width = Target.getPointerWidth(AS); - Align = Target.getPointerAlign(AS); + Width = Target->getPointerWidth(AS); + Align = Target->getPointerAlign(AS); break; } case Type::LValueReference: @@ -933,14 +946,14 @@ ASTContext::getTypeInfo(const Type *T) const { // the pointer route. unsigned AS = getTargetAddressSpace( cast<ReferenceType>(T)->getPointeeType()); - Width = Target.getPointerWidth(AS); - Align = Target.getPointerAlign(AS); + Width = Target->getPointerWidth(AS); + Align = Target->getPointerAlign(AS); break; } case Type::Pointer: { unsigned AS = getTargetAddressSpace(cast<PointerType>(T)->getPointeeType()); - Width = Target.getPointerWidth(AS); - Align = Target.getPointerAlign(AS); + Width = Target->getPointerWidth(AS); + Align = Target->getPointerAlign(AS); break; } case Type::MemberPointer: { @@ -1586,7 +1599,7 @@ QualType ASTContext::getConstantArrayType(QualType EltTy, // the target. llvm::APInt ArySize(ArySizeIn); ArySize = - ArySize.zextOrTrunc(Target.getPointerWidth(getTargetAddressSpace(EltTy))); + ArySize.zextOrTrunc(Target->getPointerWidth(getTargetAddressSpace(EltTy))); llvm::FoldingSetNodeID ID; ConstantArrayType::Profile(ID, EltTy, ArySize, ASM, IndexTypeQuals); @@ -2920,7 +2933,7 @@ QualType ASTContext::getTagDeclType(const TagDecl *Decl) const { /// of the sizeof operator (C99 6.5.3.4p4). The value is target dependent and /// needs to agree with the definition in <stddef.h>. CanQualType ASTContext::getSizeType() const { - return getFromTargetType(Target.getSizeType()); + return getFromTargetType(Target->getSizeType()); } /// getSignedWCharType - Return the type of "signed wchar_t". @@ -2940,7 +2953,7 @@ QualType ASTContext::getUnsignedWCharType() const { /// getPointerDiffType - Return the unique type for "ptrdiff_t" (ref?) /// defined in <stddef.h>. Pointer - pointer requires this (C99 6.5.6p9). QualType ASTContext::getPointerDiffType() const { - return getFromTargetType(Target.getPtrDiffType(0)); + return getFromTargetType(Target->getPtrDiffType(0)); } //===----------------------------------------------------------------------===// @@ -3476,13 +3489,13 @@ unsigned ASTContext::getIntegerRank(const Type *T) const { if (T->isSpecificBuiltinType(BuiltinType::WChar_S) || T->isSpecificBuiltinType(BuiltinType::WChar_U)) - T = getFromTargetType(Target.getWCharType()).getTypePtr(); + T = getFromTargetType(Target->getWCharType()).getTypePtr(); if (T->isSpecificBuiltinType(BuiltinType::Char16)) - T = getFromTargetType(Target.getChar16Type()).getTypePtr(); + T = getFromTargetType(Target->getChar16Type()).getTypePtr(); if (T->isSpecificBuiltinType(BuiltinType::Char32)) - T = getFromTargetType(Target.getChar32Type()).getTypePtr(); + T = getFromTargetType(Target->getChar32Type()).getTypePtr(); switch (cast<BuiltinType>(T)->getKind()) { default: assert(0 && "getIntegerRank(): not a built-in integer"); @@ -6433,7 +6446,7 @@ bool ASTContext::isNearlyEmpty(const CXXRecordDecl *RD) const { } MangleContext *ASTContext::createMangleContext() { - switch (Target.getCXXABI()) { + switch (Target->getCXXABI()) { case CXXABI_ARM: case CXXABI_Itanium: return createItaniumMangleContext(*this, getDiagnostics()); diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index b76d67bd81..252131c95d 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -51,7 +51,7 @@ static llvm::Optional<Visibility> getVisibilityOf(const Decl *D) { // If we're on Mac OS X, an 'availability' for Mac OS X attribute // implies visibility(default). - if (D->getASTContext().Target.getTriple().isOSDarwin()) { + if (D->getASTContext().getTargetInfo().getTriple().isOSDarwin()) { for (specific_attr_iterator<AvailabilityAttr> A = D->specific_attr_begin<AvailabilityAttr>(), AEnd = D->specific_attr_end<AvailabilityAttr>(); diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 27e437c4a3..1dec71c384 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -265,13 +265,13 @@ bool Decl::isReferenced() const { static AvailabilityResult CheckAvailability(ASTContext &Context, const AvailabilityAttr *A, std::string *Message) { - StringRef TargetPlatform = Context.Target.getPlatformName(); + StringRef TargetPlatform = Context.getTargetInfo().getPlatformName(); StringRef PrettyPlatformName = AvailabilityAttr::getPrettyPlatformName(TargetPlatform); if (PrettyPlatformName.empty()) PrettyPlatformName = TargetPlatform; - VersionTuple TargetMinVersion = Context.Target.getPlatformMinVersion(); + VersionTuple TargetMinVersion = Context.getTargetInfo().getPlatformMinVersion(); if (TargetMinVersion.empty()) return AR_Available; diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 2cd85a104a..ce7aca9337 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -1292,7 +1292,7 @@ bool IntExprEvaluator::VisitCallExpr(const CallExpr *E) { case Builtin::BI__builtin_eh_return_data_regno: { int Operand = E->getArg(0)->EvaluateAsInt(Info.Ctx).getZExtValue(); - Operand = Info.Ctx.Target.getEHDataRegisterNumber(Operand); + Operand = Info.Ctx.getTargetInfo().getEHDataRegisterNumber(Operand); return Success(Operand, E); } diff --git a/lib/AST/ItaniumCXXABI.cpp b/lib/AST/ItaniumCXXABI.cpp index 30aece3ee7..0027dbf191 100644 --- a/lib/AST/ItaniumCXXABI.cpp +++ b/lib/AST/ItaniumCXXABI.cpp @@ -53,7 +53,7 @@ public: const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD); CharUnits PointerSize = - Context.toCharUnitsFromBits(Context.Target.getPointerWidth(0)); + Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerWidth(0)); return Layout.getNonVirtualSize() == PointerSize; } }; diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp index 2bfd0a12be..330a78844e 100644 --- a/lib/AST/ItaniumMangle.cpp +++ b/lib/AST/ItaniumMangle.cpp @@ -398,7 +398,7 @@ void CXXNameMangler::mangle(const NamedDecl *D, StringRef Prefix) { // marker. We also avoid adding the marker if this is an alias for an // LLVM intrinsic. StringRef UserLabelPrefix = - getASTContext().Target.getUserLabelPrefix(); + getASTContext().getTargetInfo().getUserLabelPrefix(); if (!UserLabelPrefix.empty() && !ALA->getLabel().startswith("llvm.")) Out << '\01'; // LLVM IR Marker for __asm("foo") diff --git a/lib/AST/MicrosoftCXXABI.cpp b/lib/AST/MicrosoftCXXABI.cpp index 206f6dd0c9..f33d6fe1f5 100644 --- a/lib/AST/MicrosoftCXXABI.cpp +++ b/lib/AST/MicrosoftCXXABI.cpp @@ -30,7 +30,7 @@ public: unsigned getMemberPointerSize(const MemberPointerType *MPT) const; CallingConv getDefaultMethodCallConv() const { - if (Context.Target.getTriple().getArch() == llvm::Triple::x86) + if (Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86) return CC_X86ThisCall; else return CC_C; @@ -45,7 +45,7 @@ public: // In the Microsoft ABI, classes can have one or two vtable pointers. CharUnits PointerSize = - Context.toCharUnitsFromBits(Context.Target.getPointerWidth(0)); + Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerWidth(0)); return Layout.getNonVirtualSize() == PointerSize || Layout.getNonVirtualSize() == PointerSize * 2; } diff --git a/lib/AST/RecordLayoutBuilder.cpp b/lib/AST/RecordLayoutBuilder.cpp index 6d149fe146..eff1daea46 100644 --- a/lib/AST/RecordLayoutBuilder.cpp +++ b/lib/AST/RecordLayoutBuilder.cpp @@ -765,7 +765,7 @@ RecordLayoutBuilder::SelectPrimaryVBase(const CXXRecordDecl *RD) { CharUnits RecordLayoutBuilder::GetVirtualPointersSize(const CXXRecordDecl *RD) const { - return Context.toCharUnitsFromBits(Context.Target.getPointerWidth(0)); + return Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerWidth(0)); } /// DeterminePrimaryBase - Determine the primary base of the given class. @@ -825,7 +825,7 @@ void RecordLayoutBuilder::DeterminePrimaryBase(const CXXRecordDecl *RD) { setDataSize(getSize()); CharUnits UnpackedBaseAlign = - Context.toCharUnitsFromBits(Context.Target.getPointerAlign(0)); + Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerAlign(0)); CharUnits BaseAlign = (Packed) ? CharUnits::One() : UnpackedBaseAlign; // The maximum field alignment overrides base align. @@ -1193,7 +1193,7 @@ void RecordLayoutBuilder::Layout(const CXXRecordDecl *RD) { NonVirtualSize = Context.toCharUnitsFromBits( llvm::RoundUpToAlignment(getSizeInBits(), - Context.Target.getCharAlign())); + Context.getTargetInfo().getCharAlign())); NonVirtualAlignment = Alignment; // Lay out the virtual bases and add the primary virtual base offsets. @@ -1305,7 +1305,7 @@ void RecordLayoutBuilder::LayoutFields(const RecordDecl *D) { getDataSizeInBits() - UnfilledBitsInLastByte; uint64_t NewSizeInBits = RemainingInAlignment + FieldOffset; setDataSize(llvm::RoundUpToAlignment(NewSizeInBits, - Context.Target.getCharAlign())); + Context.getTargetInfo().getCharAlign())); setSize(std::max(getSizeInBits(), getDataSizeInBits())); RemainingInAlignment = 0; } @@ -1324,7 +1324,7 @@ void RecordLayoutBuilder::LayoutFields(const RecordDecl *D) { uint64_t NewSizeInBits = llvm::RoundUpToAlignment(UnpaddedFieldOffset, FieldAlign); setDataSize(llvm::RoundUpToAlignment(NewSizeInBits, - Context.Target.getCharAlign())); + Context.getTargetInfo().getCharAlign())); UnfilledBitsInLastByte = getDataSizeInBits() - NewSizeInBits; setSize(std::max(getSizeInBits(), getDataSizeInBits())); } @@ -1348,8 +1348,8 @@ void RecordLayoutBuilder::LayoutFields(const RecordDecl *D) { } LastFD = FD; } - else if (!Context.Target.useBitFieldTypeAlignment() && - Context.Target.useZeroLengthBitfieldAlignment()) { + else if (!Context.getTargetInfo().useBitFieldTypeAlignment() && + Context.getTargetInfo().useZeroLengthBitfieldAlignment()) { FieldDecl *FD = (*Field); if (FD->isBitField() && FD->getBitWidth()->EvaluateAsInt(Context).getZExtValue() == 0) @@ -1366,7 +1366,7 @@ void RecordLayoutBuilder::LayoutFields(const RecordDecl *D) { getDataSizeInBits() - UnfilledBitsInLastByte; uint64_t NewSizeInBits = RemainingInAlignment + FieldOffset; setDataSize(llvm::RoundUpToAlignment(NewSizeInBits, - Context.Target.getCharAlign())); + Context.getTargetInfo().getCharAlign())); setSize(std::max(getSizeInBits(), getDataSizeInBits())); } } @@ -1419,7 +1419,7 @@ void RecordLayoutBuilder::LayoutWideBitField(uint64_t FieldSize, uint64_t NewSizeInBits = FieldOffset + FieldSize; setDataSize(llvm::RoundUpToAlignment(NewSizeInBits, - Context.Target.getCharAlign())); + Context.getTargetInfo().getCharAlign())); UnfilledBitsInLastByte = getDataSizeInBits() - NewSizeInBits; } @@ -1472,7 +1472,7 @@ void RecordLayoutBuilder::LayoutBitField(const FieldDecl *D) { // of the next member. The alignment is the max of the zero // length bitfield's alignment and a target specific fixed value. unsigned ZeroLengthBitfieldBoundary = - Context.Target.getZeroLengthBitfieldBoundary(); + Context.getTargetInfo().getZeroLengthBitfieldBoundary(); if (ZeroLengthBitfieldBoundary > FieldAlign) FieldAlign = ZeroLengthBitfieldBoundary; } @@ -1487,11 +1487,11 @@ void RecordLayoutBuilder::LayoutBitField(const FieldDecl *D) { // was unnecessary (-Wpacked). unsigned UnpackedFieldAlign = FieldAlign; uint64_t UnpackedFieldOffset = FieldOffset; - if (!Context.Target.useBitFieldTypeAlignment() && !ZeroLengthBitfield) + if (!Context.getTargetInfo().useBitFieldTypeAlignment() && !ZeroLengthBitfield) UnpackedFieldAlign = 1; if (FieldPacked || - (!Context.Target.useBitFieldTypeAlignment() && !ZeroLengthBitfield)) + (!Context.getTargetInfo().useBitFieldTypeAlignment() &a |