diff options
author | dim <dim@FreeBSD.org> | 2012-12-02 13:20:44 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2012-12-02 13:20:44 +0000 |
commit | 056abd2059c65a3e908193aeae16fad98017437c (patch) | |
tree | 2732d02d7d51218d6eed98ac7fcfc5b8794896b5 /lib/CodeGen/CGExprConstant.cpp | |
parent | cc73504950eb7b5dff2dded9bedd67bc36d64641 (diff) | |
download | FreeBSD-src-056abd2059c65a3e908193aeae16fad98017437c.zip FreeBSD-src-056abd2059c65a3e908193aeae16fad98017437c.tar.gz |
Vendor import of clang release_32 branch r168974 (effectively, 3.2 RC2):
http://llvm.org/svn/llvm-project/cfe/branches/release_32@168974
Diffstat (limited to 'lib/CodeGen/CGExprConstant.cpp')
-rw-r--r-- | lib/CodeGen/CGExprConstant.cpp | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index a17a436..206f74a 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -24,7 +24,7 @@ #include "llvm/Constants.h" #include "llvm/Function.h" #include "llvm/GlobalVariable.h" -#include "llvm/Target/TargetData.h" +#include "llvm/DataLayout.h" using namespace clang; using namespace CodeGen; @@ -79,12 +79,12 @@ private: CharUnits getAlignment(const llvm::Constant *C) const { if (Packed) return CharUnits::One(); return CharUnits::fromQuantity( - CGM.getTargetData().getABITypeAlignment(C->getType())); + CGM.getDataLayout().getABITypeAlignment(C->getType())); } CharUnits getSizeInChars(const llvm::Constant *C) const { return CharUnits::fromQuantity( - CGM.getTargetData().getTypeAllocSize(C->getType())); + CGM.getDataLayout().getTypeAllocSize(C->getType())); } }; @@ -204,7 +204,7 @@ void ConstStructBuilder::AppendBitField(const FieldDecl *Field, if (!FitsCompletelyInPreviousByte) { unsigned NewFieldWidth = FieldSize - BitsInPreviousByte; - if (CGM.getTargetData().isBigEndian()) { + if (CGM.getDataLayout().isBigEndian()) { Tmp = Tmp.lshr(NewFieldWidth); Tmp = Tmp.trunc(BitsInPreviousByte); @@ -220,7 +220,7 @@ void ConstStructBuilder::AppendBitField(const FieldDecl *Field, } Tmp = Tmp.zext(CharWidth); - if (CGM.getTargetData().isBigEndian()) { + if (CGM.getDataLayout().isBigEndian()) { if (FitsCompletelyInPreviousByte) Tmp = Tmp.shl(BitsInPreviousByte - FieldValue.getBitWidth()); } else { @@ -269,7 +269,7 @@ void ConstStructBuilder::AppendBitField(const FieldDecl *Field, while (FieldValue.getBitWidth() > CharWidth) { llvm::APInt Tmp; - if (CGM.getTargetData().isBigEndian()) { + if (CGM.getDataLayout().isBigEndian()) { // We want the high bits. Tmp = FieldValue.lshr(FieldValue.getBitWidth() - CharWidth).trunc(CharWidth); @@ -292,7 +292,7 @@ void ConstStructBuilder::AppendBitField(const FieldDecl *Field, "Should not have more than a byte left!"); if (FieldValue.getBitWidth() < CharWidth) { - if (CGM.getTargetData().isBigEndian()) { + if (CGM.getDataLayout().isBigEndian()) { unsigned BitWidth = FieldValue.getBitWidth(); FieldValue = FieldValue.zext(CharWidth) << (CharWidth - BitWidth); @@ -337,7 +337,7 @@ void ConstStructBuilder::ConvertStructToPacked() { llvm::Constant *C = Elements[i]; CharUnits ElementAlign = CharUnits::fromQuantity( - CGM.getTargetData().getABITypeAlignment(C->getType())); + CGM.getDataLayout().getABITypeAlignment(C->getType())); CharUnits AlignedElementOffsetInChars = ElementOffsetInChars.RoundUpToAlignment(ElementAlign); @@ -379,7 +379,7 @@ bool ConstStructBuilder::Build(InitListExpr *ILE) { unsigned FieldNo = 0; unsigned ElementNo = 0; const FieldDecl *LastFD = 0; - bool IsMsStruct = RD->hasAttr<MsStructAttr>(); + bool IsMsStruct = RD->isMsStruct(CGM.getContext()); for (RecordDecl::field_iterator Field = RD->field_begin(), FieldEnd = RD->field_end(); Field != FieldEnd; ++Field, ++FieldNo) { @@ -478,7 +478,7 @@ void ConstStructBuilder::Build(const APValue &Val, const RecordDecl *RD, unsigned FieldNo = 0; const FieldDecl *LastFD = 0; - bool IsMsStruct = RD->hasAttr<MsStructAttr>(); + bool IsMsStruct = RD->isMsStruct(CGM.getContext()); uint64_t OffsetBits = CGM.getContext().toBits(Offset); for (RecordDecl::field_iterator Field = RD->field_begin(), @@ -665,8 +665,8 @@ public: SmallVector<llvm::Type*, 2> Types; Elts.push_back(C); Types.push_back(C->getType()); - unsigned CurSize = CGM.getTargetData().getTypeAllocSize(C->getType()); - unsigned TotalSize = CGM.getTargetData().getTypeAllocSize(destType); + unsigned CurSize = CGM.getDataLayout().getTypeAllocSize(C->getType()); + unsigned TotalSize = CGM.getDataLayout().getTypeAllocSize(destType); assert(CurSize <= TotalSize && "Union size mismatch!"); if (unsigned NumPadBytes = TotalSize - CurSize) { @@ -691,6 +691,9 @@ public: case CK_Dependent: llvm_unreachable("saw dependent cast!"); + case CK_BuiltinFnToFnPtr: + llvm_unreachable("builtin functions are handled elsewhere"); + case CK_ReinterpretMemberPointer: case CK_DerivedToBaseMemberPointer: case CK_BaseToDerivedMemberPointer: @@ -811,11 +814,7 @@ public: return llvm::ConstantArray::get(AType, Elts); } - llvm::Constant *EmitStructInitialization(InitListExpr *ILE) { - return ConstStructBuilder::BuildStruct(CGM, CGF, ILE); - } - - llvm::Constant *EmitUnionInitialization(InitListExpr *ILE) { + llvm::Constant *EmitRecordInitialization(InitListExpr *ILE) { return ConstStructBuilder::BuildStruct(CGM, CGF, ILE); } @@ -828,10 +827,7 @@ public: return EmitArrayInitialization(ILE); if (ILE->getType()->isRecordType()) - return EmitStructInitialization(ILE); - - if (ILE->getType()->isUnionType()) - return EmitUnionInitialization(ILE); + return EmitRecordInitialization(ILE); return 0; } @@ -999,6 +995,9 @@ public: T = Typeid->getExprOperand()->getType(); return CGM.GetAddrOfRTTIDescriptor(T); } + case Expr::CXXUuidofExprClass: { + return CGM.GetAddrOfUuidDescriptor(cast<CXXUuidofExpr>(E)); + } } return 0; |