24 #include "llvm/IR/Constants.h"
25 #include "llvm/IR/DataLayout.h"
26 #include "llvm/IR/Function.h"
27 #include "llvm/IR/GlobalVariable.h"
28 using namespace clang;
29 using namespace CodeGen;
36 class ConstExprEmitter;
37 class ConstStructBuilder {
47 ConstExprEmitter *Emitter,
48 llvm::ConstantStruct *
Base,
57 : CGM(CGM), CGF(CGF), Packed(
false),
58 NextFieldOffsetInChars(
CharUnits::Zero()),
61 void AppendField(
const FieldDecl *Field, uint64_t FieldOffset,
62 llvm::Constant *InitExpr);
64 void AppendBytes(
CharUnits FieldOffsetInChars, llvm::Constant *InitCst);
66 void AppendBitField(
const FieldDecl *Field, uint64_t FieldOffset,
67 llvm::ConstantInt *InitExpr);
71 void AppendTailPadding(
CharUnits RecordSize);
73 void ConvertStructToPacked();
76 bool Build(ConstExprEmitter *Emitter, llvm::ConstantStruct *
Base,
80 llvm::Constant *Finalize(
QualType Ty);
82 CharUnits getAlignment(
const llvm::Constant *
C)
const {
85 CGM.getDataLayout().getABITypeAlignment(C->getType()));
88 CharUnits getSizeInChars(
const llvm::Constant *C)
const {
90 CGM.getDataLayout().getTypeAllocSize(C->getType()));
94 void ConstStructBuilder::
95 AppendField(
const FieldDecl *Field, uint64_t FieldOffset,
96 llvm::Constant *InitCst) {
101 AppendBytes(FieldOffsetInChars, InitCst);
104 void ConstStructBuilder::
105 AppendBytes(
CharUnits FieldOffsetInChars, llvm::Constant *InitCst) {
107 assert(NextFieldOffsetInChars <= FieldOffsetInChars
108 &&
"Field offset mismatch!");
110 CharUnits FieldAlignment = getAlignment(InitCst);
113 CharUnits AlignedNextFieldOffsetInChars =
116 if (AlignedNextFieldOffsetInChars < FieldOffsetInChars) {
118 AppendPadding(FieldOffsetInChars - NextFieldOffsetInChars);
120 assert(NextFieldOffsetInChars == FieldOffsetInChars &&
121 "Did not add enough padding!");
123 AlignedNextFieldOffsetInChars =
127 if (AlignedNextFieldOffsetInChars > FieldOffsetInChars) {
128 assert(!Packed &&
"Alignment is wrong even with a packed struct!");
131 ConvertStructToPacked();
134 if (NextFieldOffsetInChars < FieldOffsetInChars) {
136 AppendPadding(FieldOffsetInChars - NextFieldOffsetInChars);
138 assert(NextFieldOffsetInChars == FieldOffsetInChars &&
139 "Did not add enough padding!");
141 AlignedNextFieldOffsetInChars = NextFieldOffsetInChars;
145 Elements.push_back(InitCst);
146 NextFieldOffsetInChars = AlignedNextFieldOffsetInChars +
147 getSizeInChars(InitCst);
151 "Packed struct not byte-aligned!");
153 LLVMStructAlignment = std::max(LLVMStructAlignment, FieldAlignment);
156 void ConstStructBuilder::AppendBitField(
const FieldDecl *Field,
157 uint64_t FieldOffset,
158 llvm::ConstantInt *CI) {
161 uint64_t NextFieldOffsetInBits = Context.
toBits(NextFieldOffsetInChars);
162 if (FieldOffset > NextFieldOffsetInBits) {
165 llvm::RoundUpToAlignment(FieldOffset - NextFieldOffsetInBits,
168 AppendPadding(PadSize);
173 llvm::APInt FieldValue = CI->getValue();
179 if (FieldSize > FieldValue.getBitWidth())
180 FieldValue = FieldValue.zext(FieldSize);
183 if (FieldSize < FieldValue.getBitWidth())
184 FieldValue = FieldValue.trunc(FieldSize);
186 NextFieldOffsetInBits = Context.
toBits(NextFieldOffsetInChars);
187 if (FieldOffset < NextFieldOffsetInBits) {
190 assert(!Elements.empty() &&
"Elements can't be empty!");
192 unsigned BitsInPreviousByte = NextFieldOffsetInBits - FieldOffset;
194 bool FitsCompletelyInPreviousByte =
195 BitsInPreviousByte >= FieldValue.getBitWidth();
197 llvm::APInt Tmp = FieldValue;
199 if (!FitsCompletelyInPreviousByte) {
200 unsigned NewFieldWidth = FieldSize - BitsInPreviousByte;
202 if (CGM.getDataLayout().isBigEndian()) {
203 Tmp = Tmp.lshr(NewFieldWidth);
204 Tmp = Tmp.trunc(BitsInPreviousByte);
207 FieldValue = FieldValue.trunc(NewFieldWidth);
209 Tmp = Tmp.trunc(BitsInPreviousByte);
212 FieldValue = FieldValue.lshr(BitsInPreviousByte);
213 FieldValue = FieldValue.trunc(NewFieldWidth);
217 Tmp = Tmp.zext(CharWidth);
218 if (CGM.getDataLayout().isBigEndian()) {
219 if (FitsCompletelyInPreviousByte)
220 Tmp = Tmp.shl(BitsInPreviousByte - FieldValue.getBitWidth());
222 Tmp = Tmp.shl(CharWidth - BitsInPreviousByte);
227 if (llvm::ConstantInt *Val = dyn_cast<llvm::ConstantInt>(LastElt))
228 Tmp |= Val->getValue();
230 assert(isa<llvm::UndefValue>(LastElt));
235 if (!isa<llvm::IntegerType>(LastElt->getType())) {
238 assert(isa<llvm::ArrayType>(LastElt->getType()) &&
239 "Expected array padding of undefs");
240 llvm::ArrayType *AT = cast<llvm::ArrayType>(LastElt->getType());
241 assert(AT->getElementType()->isIntegerTy(CharWidth) &&
242 AT->getNumElements() != 0 &&
243 "Expected non-empty array padding of undefs");
252 assert(isa<llvm::UndefValue>(Elements.back()) &&
253 Elements.back()->getType()->isIntegerTy(CharWidth) &&
254 "Padding addition didn't work right");
258 Elements.back() = llvm::ConstantInt::get(CGM.getLLVMContext(), Tmp);
260 if (FitsCompletelyInPreviousByte)
264 while (FieldValue.getBitWidth() > CharWidth) {
267 if (CGM.getDataLayout().isBigEndian()) {
270 FieldValue.lshr(FieldValue.getBitWidth() - CharWidth).
trunc(CharWidth);
273 Tmp = FieldValue.trunc(CharWidth);
275 FieldValue = FieldValue.lshr(CharWidth);
278 Elements.push_back(llvm::ConstantInt::get(CGM.getLLVMContext(), Tmp));
279 ++NextFieldOffsetInChars;
281 FieldValue = FieldValue.trunc(FieldValue.getBitWidth() - CharWidth);
284 assert(FieldValue.getBitWidth() > 0 &&
285 "Should have at least one bit left!");
286 assert(FieldValue.getBitWidth() <= CharWidth &&
287 "Should not have more than a byte left!");
289 if (FieldValue.getBitWidth() < CharWidth) {
290 if (CGM.getDataLayout().isBigEndian()) {
291 unsigned BitWidth = FieldValue.getBitWidth();
293 FieldValue = FieldValue.zext(CharWidth) << (CharWidth - BitWidth);
295 FieldValue = FieldValue.zext(CharWidth);
299 Elements.push_back(llvm::ConstantInt::get(CGM.getLLVMContext(),
301 ++NextFieldOffsetInChars;
304 void ConstStructBuilder::AppendPadding(
CharUnits PadSize) {
310 Ty = llvm::ArrayType::get(Ty, PadSize.
getQuantity());
312 llvm::Constant *C = llvm::UndefValue::get(Ty);
313 Elements.push_back(C);
315 "Padding must have 1 byte alignment!");
317 NextFieldOffsetInChars += getSizeInChars(C);
320 void ConstStructBuilder::AppendTailPadding(
CharUnits RecordSize) {
321 assert(NextFieldOffsetInChars <= RecordSize &&
324 AppendPadding(RecordSize - NextFieldOffsetInChars);
327 void ConstStructBuilder::ConvertStructToPacked() {
331 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
332 llvm::Constant *C = Elements[i];
335 CGM.getDataLayout().getABITypeAlignment(C->getType()));
339 if (AlignedElementOffsetInChars > ElementOffsetInChars) {
342 AlignedElementOffsetInChars - ElementOffsetInChars;
346 Ty = llvm::ArrayType::get(Ty, NumChars.
getQuantity());
348 llvm::Constant *Padding = llvm::UndefValue::get(Ty);
349 PackedElements.push_back(Padding);
350 ElementOffsetInChars += getSizeInChars(Padding);
353 PackedElements.push_back(C);
354 ElementOffsetInChars += getSizeInChars(C);
357 assert(ElementOffsetInChars == NextFieldOffsetInChars &&
358 "Packing the struct changed its size!");
360 Elements.swap(PackedElements);
367 const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(RD);
369 unsigned FieldNo = 0;
370 unsigned ElementNo = 0;
373 FieldEnd = RD->
field_end(); Field != FieldEnd; ++Field, ++FieldNo) {
384 llvm::Constant *EltInit;
385 if (ElementNo < ILE->getNumInits())
386 EltInit = CGM.EmitConstantExpr(ILE->
getInit(ElementNo++),
389 EltInit = CGM.EmitNullConstant(Field->
getType());
399 if (
auto *CI = dyn_cast<llvm::ConstantInt>(EltInit)) {
415 : Decl(Decl), Offset(Offset), Index(Index) {
430 const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(RD);
434 if (CD->isDynamicClass() && !IsPrimaryBase) {
435 llvm::Constant *VTableAddressPoint =
436 CGM.getCXXABI().getVTableAddressPointForConstExpr(
438 AppendBytes(Offset, VTableAddressPoint);
444 Bases.reserve(CD->getNumBases());
447 BaseEnd = CD->bases_end();
Base != BaseEnd; ++
Base, ++BaseNo) {
448 assert(!
Base->isVirtual() &&
"should not have virtual bases here");
451 Bases.push_back(BaseInfo(BD, BaseOffset, BaseNo));
453 std::stable_sort(Bases.begin(), Bases.end());
455 for (
unsigned I = 0, N = Bases.size();
I != N; ++
I) {
456 BaseInfo &
Base = Bases[
I];
459 Build(Val.
getStructBase(Base.Index), Base.Decl, IsPrimaryBase,
460 VTableClass, Offset + Base.Offset);
464 unsigned FieldNo = 0;
465 uint64_t OffsetBits = CGM.getContext().toBits(Offset);
468 FieldEnd = RD->
field_end(); Field != FieldEnd; ++Field, ++FieldNo) {
480 llvm::Constant *EltInit =
481 CGM.EmitConstantValueForMemory(FieldValue, Field->
getType(), CGF);
482 assert(EltInit &&
"EmitConstantValue can't fail");
486 AppendField(*Field, Layout.
getFieldOffset(FieldNo) + OffsetBits, EltInit);
489 AppendBitField(*Field, Layout.
getFieldOffset(FieldNo) + OffsetBits,
490 cast<llvm::ConstantInt>(EltInit));
495 llvm::Constant *ConstStructBuilder::Finalize(
QualType Ty) {
497 const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(RD);
501 if (NextFieldOffsetInChars > LayoutSizeInChars) {
505 "Must have flexible array member if struct is bigger than type!");
513 if (LLVMSizeInChars != LayoutSizeInChars)
514 AppendTailPadding(LayoutSizeInChars);
520 if (NextFieldOffsetInChars <= LayoutSizeInChars &&
521 LLVMSizeInChars > LayoutSizeInChars) {
522 assert(!Packed &&
"Size mismatch!");
524 ConvertStructToPacked();
525 assert(NextFieldOffsetInChars <= LayoutSizeInChars &&
526 "Converting to packed did not help!");
532 assert(LayoutSizeInChars == LLVMSizeInChars &&
533 "Tail padding mismatch!");
538 llvm::StructType *STy =
539 llvm::ConstantStruct::getTypeForElements(CGM.getLLVMContext(),
541 llvm::Type *ValTy = CGM.getTypes().ConvertType(Ty);
542 if (llvm::StructType *ValSTy = dyn_cast<llvm::StructType>(ValTy)) {
543 if (ValSTy->isLayoutIdentical(STy))
547 llvm::Constant *
Result = llvm::ConstantStruct::get(STy, Elements);
549 assert(NextFieldOffsetInChars.RoundUpToAlignment(getAlignment(Result)) ==
550 getSizeInChars(Result) &&
"Size mismatch!");
555 llvm::Constant *ConstStructBuilder::BuildStruct(
CodeGenModule &CGM,
557 ConstExprEmitter *Emitter,
558 llvm::ConstantStruct *Base,
560 ConstStructBuilder
Builder(CGM, CGF);
561 if (!
Builder.Build(Emitter, Base, Updater))
566 llvm::Constant *ConstStructBuilder::BuildStruct(
CodeGenModule &CGM,
569 ConstStructBuilder
Builder(CGM, CGF);
577 llvm::Constant *ConstStructBuilder::BuildStruct(
CodeGenModule &CGM,
581 ConstStructBuilder
Builder(CGM, CGF);
587 return Builder.Finalize(ValTy);
599 class ConstExprEmitter :
600 public StmtVisitor<ConstExprEmitter, llvm::Constant*> {
603 llvm::LLVMContext &VMContext;
606 : CGM(cgm), CGF(cgf), VMContext(cgm.getLLVMContext()) {
613 llvm::Constant *VisitStmt(
Stmt *
S) {
617 llvm::Constant *VisitParenExpr(
ParenExpr *PE) {
630 llvm::Constant *VisitChooseExpr(
ChooseExpr *CE) {
638 llvm::Constant *VisitCastExpr(
CastExpr* E) {
639 if (
const auto *ECE = dyn_cast<ExplicitCastExpr>(E))
643 if (!C)
return nullptr;
651 "Destination type is not union type!");
658 Types.push_back(C->getType());
659 unsigned CurSize = CGM.
getDataLayout().getTypeAllocSize(C->getType());
660 unsigned TotalSize = CGM.
getDataLayout().getTypeAllocSize(destType);
662 assert(CurSize <= TotalSize &&
"Union size mismatch!");
663 if (
unsigned NumPadBytes = TotalSize - CurSize) {
666 Ty = llvm::ArrayType::get(Ty, NumPadBytes);
668 Elts.push_back(llvm::UndefValue::get(Ty));
672 llvm::StructType* STy =
673 llvm::StructType::get(C->getType()->getContext(), Types,
false);
674 return llvm::ConstantStruct::get(STy, Elts);
678 return llvm::ConstantExpr::getAddrSpaceCast(C, destType);
687 case CK_Dependent: llvm_unreachable(
"saw dependent cast!");
690 llvm_unreachable(
"builtin functions are handled elsewhere");
748 llvm_unreachable(
"Invalid CastKind");
765 llvm::Constant *EmitArrayInitialization(
InitListExpr *ILE) {
769 llvm::ArrayType *AType =
770 cast<llvm::ArrayType>(ConvertType(ILE->
getType()));
773 unsigned NumElements = AType->getNumElements();
777 unsigned NumInitableElts = std::min(NumInitElements, NumElements);
781 llvm::Constant *fillC;
785 fillC = llvm::Constant::getNullValue(ElemTy);
790 if (fillC->isNullValue() && !NumInitableElts)
791 return llvm::ConstantAggregateZero::get(AType);
794 std::vector<llvm::Constant*> Elts;
795 Elts.reserve(NumInitableElts + NumElements);
797 bool RewriteType =
false;
798 for (
unsigned i = 0; i < NumInitableElts; ++i) {
803 RewriteType |= (C->getType() != ElemTy);
807 RewriteType |= (fillC->getType() != ElemTy);
808 Elts.resize(NumElements, fillC);
812 std::vector<llvm::Type*> Types;
813 Types.reserve(NumInitableElts + NumElements);
814 for (
unsigned i = 0, e = Elts.size(); i < e; ++i)
815 Types.push_back(Elts[i]->getType());
816 llvm::StructType *SType = llvm::StructType::get(AType->getContext(),
818 return llvm::ConstantStruct::get(SType, Elts);
821 return llvm::ConstantArray::get(AType, Elts);
824 llvm::Constant *EmitRecordInitialization(
InitListExpr *ILE) {
825 return ConstStructBuilder::BuildStruct(CGM, CGF, ILE);
834 return EmitArrayInitialization(ILE);
837 return EmitRecordInitialization(ILE);
842 llvm::Constant *EmitDesignatedInitUpdater(llvm::Constant *Base,
847 llvm::ArrayType *AType = cast<llvm::ArrayType>(ConvertType(ExprType));
848 llvm::Type *ElemType = AType->getElementType();
851 unsigned NumElements = AType->getNumElements();
853 std::vector<llvm::Constant *> Elts;
854 Elts.reserve(NumElements);
856 if (llvm::ConstantDataArray *DataArray =
857 dyn_cast<llvm::ConstantDataArray>(Base))
858 for (
unsigned i = 0; i != NumElements; ++i)
859 Elts.push_back(DataArray->getElementAsConstant(i));
860 else if (llvm::ConstantArray *Array =
861 dyn_cast<llvm::ConstantArray>(Base))
862 for (
unsigned i = 0; i != NumElements; ++i)
863 Elts.push_back(Array->getOperand(i));
867 llvm::Constant *fillC =
nullptr;
869 if (!isa<NoInitExpr>(filler))
871 bool RewriteType = (fillC && fillC->getType() != ElemType);
873 for (
unsigned i = 0; i != NumElements; ++i) {
874 Expr *Init =
nullptr;
875 if (i < NumInitElements)
880 else if (!Init || isa<NoInitExpr>(Init))
882 else if (
InitListExpr *ChildILE = dyn_cast<InitListExpr>(Init))
883 Elts[i] = EmitDesignatedInitUpdater(Elts[i], ChildILE);
889 RewriteType |= (Elts[i]->getType() != ElemType);
893 std::vector<llvm::Type *> Types;
894 Types.reserve(NumElements);
895 for (
unsigned i = 0; i != NumElements; ++i)
896 Types.push_back(Elts[i]->getType());
897 llvm::StructType *SType = llvm::StructType::get(AType->getContext(),
899 return llvm::ConstantStruct::get(SType, Elts);
902 return llvm::ConstantArray::get(AType, Elts);
906 return ConstStructBuilder::BuildStruct(CGM, CGF,
this,
907 dyn_cast<llvm::ConstantStruct>(Base), Updater);
913 return EmitDesignatedInitUpdater(
931 if (!RD->hasTrivialDestructor())
938 assert(E->
getNumArgs() == 1 &&
"trivial ctor with > 1 argument");
940 "trivial ctor has argument but isn't a copy/move ctor");
944 "argument to copy ctor is of wrong type");
964 T = cast<TypeOfExprType>(T)->getUnderlyingExpr()->getType();
969 Str.resize(CAT->
getSize().getZExtValue(),
'\0');
970 return llvm::ConstantDataArray::getString(VMContext, Str,
false);
973 llvm::Constant *VisitUnaryExtension(
const UnaryOperator *E) {
991 if (!VD->hasLocalStorage()) {
993 if (VD->isFileVarDecl() || VD->hasExternalStorage())
995 else if (VD->isLocalVarDecl()) {
1005 Expr *E =
const_cast<Expr*
>(LVBase.get<
const Expr*>());
1006 switch (E->getStmtClass()) {
1008 case Expr::CompoundLiteralExprClass: {
1019 auto GV =
new llvm::GlobalVariable(CGM.
getModule(), C->getType(),
1022 C,
".compoundliteral",
nullptr,
1023 llvm::GlobalVariable::NotThreadLocal,
1028 case Expr::StringLiteralClass:
1030 case Expr::ObjCEncodeExprClass:
1032 case Expr::ObjCStringLiteralClass: {
1038 case Expr::PredefinedExprClass: {
1039 unsigned Type = cast<PredefinedExpr>(
E)->getIdentType();
1042 return cast<ConstantAddress>(Res.
getAddress());
1049 case Expr::AddrLabelExprClass: {
1050 assert(CGF &&
"Invalid address of label expression outside function.");
1051 llvm::Constant *Ptr =
1053 Ptr = llvm::ConstantExpr::getBitCast(Ptr, ConvertType(E->
getType()));
1056 case Expr::CallExprClass: {
1060 Builtin::BI__builtin___CFStringMakeConstantString &&
1062 Builtin::BI__builtin___NSStringMakeConstantString)
1067 Builtin::BI__builtin___NSStringMakeConstantString) {
1073 case Expr::BlockExprClass: {
1074 std::string FunctionName;
1076 FunctionName = CGF->
CurFn->getName();
1078 FunctionName =
"global";
1081 llvm::Constant *Ptr =
1085 case Expr::CXXTypeidExprClass: {
1095 case Expr::CXXUuidofExprClass: {
1098 case Expr::MaterializeTemporaryExprClass: {
1115 bool ConstStructBuilder::Build(ConstExprEmitter *Emitter,
1116 llvm::ConstantStruct *Base,
1118 assert(Base &&
"base expression should not be empty");
1123 const llvm::StructLayout *BaseLayout = CGM.
getDataLayout().getStructLayout(
1125 unsigned FieldNo = -1;
1126 unsigned ElementNo = 0;
1138 llvm::Constant *EltInit = Base->getOperand(ElementNo);
1144 BaseLayout->getElementOffsetInBits(ElementNo))
1149 Expr *Init =
nullptr;
1150 if (ElementNo < Updater->getNumInits())
1151 Init = Updater->
getInit(ElementNo);
1153 if (!Init || isa<NoInitExpr>(Init))
1155 else if (
InitListExpr *ChildILE = dyn_cast<InitListExpr>(Init))
1156 EltInit = Emitter->EmitDesignatedInitUpdater(EltInit, ChildILE);
1167 else if (llvm::ConstantInt *CI = dyn_cast<llvm::ConstantInt>(EltInit))
1188 dyn_cast_or_null<CXXConstructExpr>(D.
getInit())) {
1208 assert(E &&
"No initializer to emit");
1210 llvm::Constant* C = ConstExprEmitter(*
this, CGF).Visit(const_cast<Expr*>(E));
1211 if (C && C->getType()->isIntegerTy(1)) {
1213 C = llvm::ConstantExpr::getZExt(C, BoolTy);
1223 bool Success =
false;
1230 llvm::Constant *C =
nullptr;
1234 C = ConstExprEmitter(*
this, CGF).Visit(const_cast<Expr*>(E));
1236 if (C && C->getType()->isIntegerTy(1)) {
1238 C = llvm::ConstantExpr::getZExt(C, BoolTy);
1248 QualType InnerType = AT->getValueType();
1251 uint64_t InnerSize = Context.
getTypeSize(InnerType);
1252 uint64_t OuterSize = Context.
getTypeSize(DestType);
1253 if (InnerSize == OuterSize)
1256 assert(InnerSize < OuterSize &&
"emitted over-large constant for atomic");
1257 llvm::Constant *Elts[] = {
1259 llvm::ConstantAggregateZero::get(
1260 llvm::ArrayType::get(
Int8Ty, (OuterSize - InnerSize) / 8))
1262 return llvm::ConstantStruct::getAnon(Elts);
1267 llvm_unreachable(
"Constant expressions should be initialized.");
1270 llvm::Constant *Offset =
1273 llvm::Constant *C =
nullptr;
1276 if (isa<llvm::ArrayType>(DestTy)) {
1277 assert(Offset->isNullValue() &&
"offset on array initializer");
1278 return ConstExprEmitter(*
this, CGF).Visit(
1279 const_cast<Expr*>(LVBase.get<
const Expr*>()));
1282 C = ConstExprEmitter(*
this, CGF).EmitLValue(LVBase).getPointer();
1285 if (!Offset->isNullValue()) {
1286 unsigned AS = C->getType()->getPointerAddressSpace();
1288 llvm::Constant *Casted = llvm::ConstantExpr::getBitCast(C, CharPtrTy);
1289 Casted = llvm::ConstantExpr::getGetElementPtr(
Int8Ty, Casted, Offset);
1290 C = llvm::ConstantExpr::getPointerCast(Casted, C->getType());
1295 if (isa<llvm::PointerType>(DestTy))
1296 return llvm::ConstantExpr::getPointerCast(C, DestTy);
1298 return llvm::ConstantExpr::getPtrToInt(C, DestTy);
1304 if (isa<llvm::PointerType>(DestTy))
1305 return llvm::ConstantExpr::getIntToPtr(C, DestTy);
1308 if (C->getType() != DestTy)
1309 return llvm::ConstantExpr::getTrunc(C, DestTy);
1315 return llvm::ConstantInt::get(VMContext, Value.
getInt());
1317 llvm::Constant *Complex[2];
1319 Complex[0] = llvm::ConstantInt::get(VMContext,
1321 Complex[1] = llvm::ConstantInt::get(VMContext,
1325 llvm::StructType *STy = llvm::StructType::get(Complex[0]->getType(),
1326 Complex[1]->getType(),
1328 return llvm::ConstantStruct::get(STy, Complex);
1331 const llvm::APFloat &Init = Value.
getFloat();
1332 if (&Init.getSemantics() == &llvm::APFloat::IEEEhalf &&
1335 return llvm::ConstantInt::get(VMContext, Init.bitcastToAPInt());
1337 return llvm::ConstantFP::get(VMContext, Init);
1340 llvm::Constant *Complex[2];
1342 Complex[0] = llvm::ConstantFP::get(VMContext,
1344 Complex[1] = llvm::ConstantFP::get(VMContext,
1348 llvm::StructType *STy = llvm::StructType::get(Complex[0]->getType(),
1349 Complex[1]->getType(),
1351 return llvm::ConstantStruct::get(STy, Complex);
1357 for (
unsigned I = 0;
I != NumElts; ++
I) {
1360 Inits[
I] = llvm::ConstantInt::get(VMContext, Elt.
getInt());
1362 Inits[
I] = llvm::ConstantFP::get(VMContext, Elt.
getFloat());
1364 llvm_unreachable(
"unsupported vector element type");
1366 return llvm::ConstantVector::get(Inits);
1376 LHS = llvm::ConstantExpr::getPtrToInt(LHS,
IntPtrTy);
1377 RHS = llvm::ConstantExpr::getPtrToInt(RHS,
IntPtrTy);
1378 llvm::Constant *AddrLabelDiff = llvm::ConstantExpr::getSub(LHS, RHS);
1383 return llvm::ConstantExpr::getTruncOrBitCast(AddrLabelDiff, ResultType);
1387 return ConstStructBuilder::BuildStruct(*
this, CGF, Value, DestType);
1394 llvm::Constant *Filler =
nullptr;
1404 if (Filler && Filler->isNullValue() && !NumInitElts) {
1405 llvm::ArrayType *AType =
1406 llvm::ArrayType::get(CommonElementType, NumElements);
1407 return llvm::ConstantAggregateZero::get(AType);
1410 std::vector<llvm::Constant*> Elts;
1411 Elts.reserve(NumElements);
1412 for (
unsigned I = 0;
I < NumElements; ++
I) {
1413 llvm::Constant *C = Filler;
1414 if (
I < NumInitElts)
1418 assert(Filler &&
"Missing filler for implicit elements of initializer");
1420 CommonElementType = C->getType();
1421 else if (C->getType() != CommonElementType)
1422 CommonElementType =
nullptr;
1426 if (!CommonElementType) {
1428 std::vector<llvm::Type*> Types;
1429 Types.reserve(NumElements);
1430 for (
unsigned i = 0, e = Elts.size(); i < e; ++i)
1431 Types.push_back(Elts[i]->getType());
1432 llvm::StructType *SType = llvm::StructType::get(VMContext, Types,
true);
1433 return llvm::ConstantStruct::get(SType, Elts);
1436 llvm::ArrayType *AType =
1437 llvm::ArrayType::get(CommonElementType, NumElements);
1438 return llvm::ConstantArray::get(AType, Elts);
1443 llvm_unreachable(
"Unknown APValue kind");
1451 if (C->getType()->isIntegerTy(1)) {
1453 C = llvm::ConstantExpr::getZExt(C, BoolTy);
1460 assert(E->
isFileScope() &&
"not a file-scope compound literal expr");
1461 return ConstExprEmitter(*
this,
nullptr).EmitLValue(E);
1471 if (
const CXXMethodDecl *method = dyn_cast<CXXMethodDecl>(decl))
1486 bool asCompleteObject) {
1488 llvm::StructType *structure =
1492 unsigned numElements = structure->getNumElements();
1493 std::vector<llvm::Constant *> elements(numElements);
1496 for (
const auto &
I : record->
bases()) {
1497 if (
I.isVirtual()) {
1504 cast<CXXRecordDecl>(
I.getType()->castAs<
RecordType>()->getDecl());
1511 llvm::Type *baseType = structure->getElementType(fieldIndex);
1516 for (
const auto *Field : record->
fields()) {
1528 if (
const auto *FieldRD =
1530 if (FieldRD->findFirstNamedDataMember())
1536 if (asCompleteObject) {
1537 for (
const auto &
I : record->
vbases()) {
1539 cast<CXXRecordDecl>(
I.getType()->castAs<
RecordType>()->getDecl());
1548 if (elements[fieldIndex])
continue;
1550 llvm::Type *baseType = structure->getElementType(fieldIndex);
1556 for (
unsigned i = 0; i != numElements; ++i) {
1558 elements[i] = llvm::Constant::getNullValue(structure->getElementType(i));
1561 return llvm::ConstantStruct::get(structure, elements);
1572 return llvm::Constant::getNullValue(baseType);
1579 if (
getTypes().isZeroInitializable(T))
1580 return llvm::Constant::getNullValue(
getTypes().ConvertTypeForMem(T));
1583 llvm::ArrayType *ATy =
1589 unsigned NumElements = CAT->
getSize().getZExtValue();
1591 return llvm::ConstantArray::get(ATy, Array);
1600 "Should only see pointers to data members here!");
Defines the clang::ASTContext interface.
unsigned getNumInits() const
CastKind getCastKind() const
virtual llvm::Constant * EmitMemberPointer(const APValue &MP, QualType MPT)
Create a member pointer for the given member pointer constant.
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
CK_LValueToRValue - A conversion which causes the extraction of an r-value from the operand gl-value...
const FieldDecl * getUnionField() const
APValue * evaluateValue() const
Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...
A (possibly-)qualified type.
CodeGenTypes & getTypes()
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
bool isBitField() const
Determines whether this field is a bitfield.
llvm::Module & getModule() const
CGRecordLayout - This class handles struct and union layout info while lowering AST types to LLVM typ...
llvm::Constant * getMemberPointerConstant(const UnaryOperator *e)
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
ConstantAddress GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *)
Return a pointer to a constant array for the given ObjCEncodeExpr node.
Expr * GetTemporaryExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue...
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
bool isRecordType() const
CK_ToUnion - The GCC cast-to-union extension.
Decl - This represents one declaration (or definition), e.g.
Address getAddress() const
bool hasFlexibleArrayMember() const
ParenExpr - This represents a parethesized expression, e.g.
const llvm::DataLayout & getDataLayout() const
The base class of the type hierarchy.
CK_BaseToDerivedMemberPointer - Member pointer in base class to member pointer in derived class...
Represents an array type, per C99 6.7.5.2 - Array Declarators.
const Expr * getResultExpr() const
The generic selection's result expression.
const Expr * getInit() const
Represents a call to a C++ constructor.
CK_FloatingToIntegral - Floating point to integral.
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
[ARC] Consumes a retainable object pointer that has just been produced, e.g.
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
Represents a C++ constructor within a class.
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
llvm::Constant * EmitConstantValue(const APValue &Value, QualType DestType, CodeGenFunction *CGF=nullptr)
Emit the given constant value as a constant, in the type's scalar representation. ...
const llvm::APInt & getSize() const
unsigned getLLVMFieldNo(const FieldDecl *FD) const
Return llvm::StructType element number that corresponds to the field FD.
CK_IntegralToFloating - Integral to floating point.
llvm::StructType * getLLVMType() const
Return the "complete object" LLVM type associated with this record.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
CK_IntegralCast - A cast between integral types (other than to boolean).
CompoundLiteralExpr - [C99 6.5.2.5].
APFloat & getComplexFloatReal()
field_iterator field_begin() const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
llvm::Constant * GetAddrOfGlobalVar(const VarDecl *D, llvm::Type *Ty=nullptr)
Return the llvm::Constant for the address of the given global variable.
CK_Dynamic - A C++ dynamic_cast.
bool isCopyOrMoveConstructor(unsigned &TypeQuals) const
Determine whether this is a copy or move constructor.
CK_Dependent - A conversion which cannot yet be analyzed because either the expression or target type...
bool isMemberDataPointerType() const
llvm::Type * ConvertTypeForMem(QualType T)
ConvertTypeForMem - Convert type T into a llvm::Type.
llvm::Constant * EmitConstantValueForMemory(const APValue &Value, QualType DestType, CodeGenFunction *CGF=nullptr)
Emit the given constant value as a constant, in the type's memory representation. ...
RecordDecl - Represents a struct/union/class.
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
TagDecl * getAsTagDecl() const
Retrieves the TagDecl that this type refers to, either because the type is a TagType or because it is...
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
llvm::Type * ConvertType(QualType T)
ConvertType - Convert type T into a llvm::Type.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Converts between different integral complex types.
llvm::IntegerType * Int64Ty
bool isReferenceType() const
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
StringLiteral * getString()
Converting between two Objective-C object types, which can occur when performing reference binding to...
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
CK_FloatingCast - Casting between floating types of different size.
[ARC] Causes a value of block type to be copied to the heap, if it is not already there...
CK_VectorSplat - A conversion from an arithmetic type to a vector of that element type...
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
CK_NullToPointer - Null pointer constant to pointer, ObjC pointer, or block pointer.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
CK_PointerToIntegral - Pointer to integral.
CK_IntegralToPointer - Integral to pointer.
llvm::Constant * GetConstantArrayFromStringLiteral(const StringLiteral *E)
Return a constant array for the given string.
Converts a floating point complex to bool by comparing against 0+0i.
unsigned getVirtualBaseIndex(const CXXRecordDecl *base) const
Return the LLVM field index corresponding to the given virtual base.
Describes an C or C++ initializer list.
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
CK_IntegralToBoolean - Integral to boolean.
Expr * getChosenSubExpr() const
getChosenSubExpr - Return the subexpression chosen according to the condition.
const TargetInfo & getTargetInfo() const
const LangOptions & getLangOpts() const
CharUnits - This is an opaque type for sizes expressed in character units.
APValue Val
Val - This is the value the expression can be folded to.
bool isZeroInitializableAsBase() const
Check whether this struct can be C++ zero-initialized with a zeroinitializer when considered as a bas...
Expr * getExprOperand() const
field_range fields() const
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
const Expr * skipRValueSubobjectAdjustments(SmallVectorImpl< const Expr * > &CommaLHS, SmallVectorImpl< SubobjectAdjustment > &Adjustments) const
Walk outwards from an expression we want to bind a reference to and find the expression whose lifetim...
RecordDecl * getDecl() const
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
ObjCStringLiteral, used for Objective-C string literals i.e.
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D...
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
TypeClass getTypeClass() const
unsigned getBuiltinCallee() const
getBuiltinCallee - If this is a call to a builtin, return the builtin ID of the callee.
detail::InMemoryDirectory::const_iterator I
APSInt & getComplexIntReal()
A default argument (C++ [dcl.fct.default]).
bool isUnnamedBitfield() const
Determines whether this is an unnamed bitfield.
field_iterator field_end() const
APValue & getVectorElt(unsigned I)
CK_AnyPointerToBlockPointerCast - Casting any non-block pointer to a block pointer.
static CharUnits One()
One - Construct a CharUnits quantity of one.
Causes a block literal to by copied to the heap and then autoreleased.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
APValue & getArrayFiller()
void getObjCEncodingForType(QualType T, std::string &S, const FieldDecl *Field=nullptr, QualType *NotEncodedT=nullptr) const
Emit the Objective-CC type encoding for the given type T into S.
const Expr * getExpr() const
Get the initialization expression that will be used.
CK_FunctionToPointerDecay - Function to pointer decay.
unsigned getCharAlign() const
Converts between different floating point complex types.
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
unsigned getArrayInitializedElts() const
CGObjCRuntime & getObjCRuntime()
Return a reference to the configured Objective-C runtime.
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
CK_PointerToBoolean - Pointer to boolean conversion.
Converts an integral complex to an integral real of the source's element type by discarding the imagi...
CK_BitCast - A conversion which causes a bit pattern of one type to be reinterpreted as a bit pattern...
CFG - Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt...
CGCXXABI & getCXXABI() const
StorageDuration getStorageDuration() const
Retrieve the storage duration for the materialized temporary.
ASTContext & getContext() const
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
llvm::GlobalValue::LinkageTypes getLLVMLinkageVarDefinition(const VarDecl *VD, bool IsConstant)
Returns LLVM linkage for a declarator.
Expr * getSubExpr() const
CK_ConstructorConversion - Conversion by constructor.
APValue & getStructField(unsigned i)
virtual llvm::Constant * EmitMemberFunctionPointer(const CXXMethodDecl *MD)
Create a member pointer for the given method.
ConstantAddress GetAddrOfUuidDescriptor(const CXXUuidofExpr *E)
Get the address of a uuid descriptor .
Converts from an integral complex to a floating complex.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Represents a reference to a non-type template parameter that has been substituted with a template arg...
APSInt & getComplexIntImag()
The result type of a method or function.
CK_ArrayToPointerDecay - Array to pointer decay.
InitListExpr * getUpdater() const
ConstantAddress GetAddrOfGlobalTemporary(const MaterializeTemporaryExpr *E, const Expr *Inner)
Returns a pointer to a global variable representing a temporary with static or thread storage duratio...
The l-value was considered opaque, so the alignment was determined from a type.
uint64_t getFieldOffset(const ValueDecl *FD) const
Get the offset of a FieldDecl or IndirectFieldDecl, in bits.
APValue & getStructBase(unsigned i)
CK_CPointerToObjCPointerCast - Casting a C pointer kind to an Objective-C pointer.
llvm::Constant * getOrCreateStaticVarDecl(const VarDecl &D, llvm::GlobalValue::LinkageTypes Linkage)
APValue & getArrayInitializedElt(unsigned I)
virtual llvm::Value * EmitMemberPointerConversion(CodeGenFunction &CGF, const CastExpr *E, llvm::Value *Src)
Perform a derived-to-base, base-to-derived, or bitcast member pointer conversion. ...
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
CK_UserDefinedConversion - Conversion using a user defined type conversion function.
llvm::Constant * EmitConstantExpr(const Expr *E, QualType DestType, CodeGenFunction *CGF=nullptr)
Try to emit the given expression as a constant; returns 0 if the expression cannot be emitted as a co...
CharUnits getPointerAlign() const
CharUnits getSize() const
getSize - Get the record size in characters.
virtual ConstantAddress GenerateConstantString(const StringLiteral *)=0
Generate a constant string object.
unsigned getBitWidthValue(const ASTContext &Ctx) const
const CXXRecordDecl * getPrimaryBase() const
getPrimaryBase - Get the primary base for this record.
ConstantAddress GetAddrOfConstantCFString(const StringLiteral *Literal)
Return a pointer to a constant CFString object for the given string.
const AddrLabelExpr * getAddrLabelDiffLHS() const
APValue & getUnionValue()
bool isConstant(ASTContext &Ctx) const
CK_NullToMemberPointer - Null pointer constant to member pointer.
ValueKind getKind() const
ConstantAddress getElementBitCast(llvm::Type *ty) const
Represents a static or instance method of a struct/union/class.
ConstantAddress GetAddrOfConstantStringFromLiteral(const StringLiteral *S, StringRef Name=".str")
Return a pointer to a constant array for the given string literal.
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
CK_ReinterpretMemberPointer - Reinterpret a member pointer as a different kind of member pointer...
CK_DerivedToBase - A conversion from a C++ class pointer to a base class pointer. ...
llvm::Constant * EmitNullConstantForBase(const CXXRecordDecl *Record)
Return a null constant appropriate for zero-initializing a base class with the given type...
const ConstantArrayType * getAsConstantArrayType(QualType T) const
llvm::Constant * GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH=false)
Get the address of the RTTI descriptor for the given type.
ConstantAddress GetWeakRefReference(const ValueDecl *VD)
Get a reference to the target of VD.
Converts from an integral real to an integral complex whose element type matches the source...
const T * castAs() const
Member-template castAs<specific type>.
const AddrLabelExpr * getAddrLabelDiffRHS() const
bool operator<(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
virtual llvm::Constant * EmitNullMemberPointer(const MemberPointerType *MPT)
Create a null member pointer of the given type.
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
ConstantAddress GetAddrOfConstantCString(const std::string &Str, const char *GlobalName=nullptr)
Returns a pointer to a character array containing the literal and a terminating '\0' character...
Represents a C11 generic selection.
AddrLabelExpr - The GNU address of label extension, representing &&label.
Converts a floating point complex to floating point real of the source's element type.
Expr * getReplacement() const
This class organizes the cross-function state that is used while generating LLVM code.
const Expr * getExpr() const
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this typeid() expression after various required adjustments (removing r...
EvalResult is a struct with detailed info about an evaluated expression.
Converts an integral complex to bool by comparing against 0+0i.
bool isZero() const
isZero - Test whether the quantity equals zero.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
unsigned getNonVirtualBaseLLVMFieldNo(const CXXRecordDecl *RD) const
CK_BaseToDerived - A conversion from a C++ class pointer/reference to a derived class pointer/referen...
static llvm::Constant * EmitNullConstantForBase(CodeGenModule &CGM, llvm::Type *baseType, const CXXRecordDecl *base)
Emit the null constant for a base subobject.
llvm::IntegerType * IntPtrTy
llvm::Constant * EmitNullConstant(QualType T)
Return the result of value-initializing the given type, i.e.
CK_BlockPointerToObjCPointerCast - Casting a block pointer to an ObjC pointer.
detail::InMemoryDirectory::const_iterator E
A pointer to member type per C++ 8.3.3 - Pointers to members.
A conversion of a floating point real to a floating point complex of the original type...
CK_MemberPointerToBoolean - Member pointer to boolean.
unsigned getNumArgs() const
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
[ARC] Reclaim a retainable object pointer object that may have been produced and autoreleased as part...
void EmitExplicitCastExprType(const ExplicitCastExpr *E, CodeGenFunction *CGF=nullptr)
Emit type info if type of an expression is a variably modified type.
bool HasSideEffects
Whether the evaluated expression has side effects.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
const T * getAs() const
Member-template getAs<specific type>'.
llvm::PointerUnion< const ValueDecl *, const Expr * > LValueBase
ObjCEncodeExpr, used for @encode in Objective-C.
[ARC] Produces a retainable object pointer so that it may be consumed, e.g.
virtual llvm::Constant * EmitMemberDataPointer(const MemberPointerType *MPT, CharUnits offset)
Create a member pointer for the given field.
CK_LValueBitCast - A conversion which reinterprets the address of an l-value as an l-value of a diffe...
Converts from T to _Atomic(T).
Expr * getArg(unsigned Arg)
Return the specified argument.
CXXConstructorDecl * getConstructor() const
llvm::Constant * GetAddrOfGlobalBlock(const BlockExpr *BE, const char *)
Gets the address of a block which requires no captures.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
Converts from a floating complex to an integral complex.
uint64_t getCharWidth() const
Return the size of the character type, in bits.
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
ConstantAddress GetAddrOfConstantCompoundLiteral(const CompoundLiteralExpr *E)
Returns a pointer to a constant global variable for the given file-scope compound literal expression...
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
Represents a base class of a C++ class.
const Expr * getInitializer() const
CK_UncheckedDerivedToBase - A conversion from a C++ class pointer/reference to a base class that can ...
llvm::Constant * EmitConstantInit(const VarDecl &D, CodeGenFunction *CGF=nullptr)
Try to emit the initializer for the given declaration as a constant; returns 0 if the expression cann...
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
A use of a default initializer in a constructor or in aggregate initialization.
const Expr * getSubExpr() const
APFloat & getComplexFloatImag()
const LValueBase getLValueBase() const
Represents a C++ struct/union/class.
BoundNodesTreeBuilder *const Builder
QualType getEncodedType() const
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
A specialization of Address that requires the address to be an LLVM Constant.
Converts from _Atomic(T) to T.
LValue EmitPredefinedLValue(const PredefinedExpr *E)
StringLiteral - This represents a string literal expression, e.g.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
static ConstantAddress invalid()
bool isStringLiteralInit() const
unsigned getTargetAddressSpace(QualType T) const
CK_NoOp - A conversion which does not affect the type other than (possibly) adding qualifiers...
CK_DerivedToBaseMemberPointer - Member pointer in derived class to member pointer in base class...
QualType getElementType() const
const Expr * getInit(unsigned Init) const
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
int64_t toBits(CharUnits CharSize) const
Convert a size in characters to a size in bits.
static llvm::Constant * EmitNullConstant(CodeGenModule &CGM, const CXXRecordDecl *record, bool asCompleteObject)
LValue - This represents an lvalue references.
llvm::BlockAddress * GetAddrOfLabel(const LabelDecl *L)
unsigned getArraySize() const
bool EvaluateAsLValue(EvalResult &Result, const ASTContext &Ctx) const
EvaluateAsLValue - Evaluate an expression to see if we can fold it to an lvalue with link time known ...
bool isTypeOperand() const
llvm::StructType * getBaseSubobjectLLVMType() const
Return the "base subobject" LLVM type associated with this record.
CK_ToVoid - Cast to void, discarding the computed value.
CharUnits RoundUpToAlignment(const CharUnits &Align) const
RoundUpToAlignment - Returns the next integer (mod 2**64) that is greater than or equal to this quant...
llvm::Constant * GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty=nullptr, bool ForVTable=false, bool DontDefer=false, bool IsForDefinition=false)
Return the address of the given function.
const CGRecordLayout & getCGRecordLayout(const RecordDecl *)
getCGRecordLayout - Return record layout info for the given record decl.
base_class_range vbases()
Represents the canonical version of C arrays with a specified constant size.
unsigned getVectorLength() const
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
Defines enum values for all the target-independent builtin functions.
Represents an implicitly-generated value initialization of an object of a given type.
bool hasLocalStorage() const
hasLocalStorage - Returns true if a variable with function scope is a non-static local variable...
bool hasArrayFiller() const
CharUnits & getLValueOffset()
CK_FloatingToBoolean - Floating point to boolean.