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 =
114 NextFieldOffsetInChars.
alignTo(FieldAlignment);
116 if (AlignedNextFieldOffsetInChars < FieldOffsetInChars) {
118 AppendPadding(FieldOffsetInChars - NextFieldOffsetInChars);
120 assert(NextFieldOffsetInChars == FieldOffsetInChars &&
121 "Did not add enough padding!");
123 AlignedNextFieldOffsetInChars =
124 NextFieldOffsetInChars.
alignTo(FieldAlignment);
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::alignTo(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()));
337 ElementOffsetInChars.
alignTo(ElementAlign);
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;
375 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(RD))
376 if (CXXRD->getNumBases())
380 FieldEnd = RD->
field_end(); Field != FieldEnd; ++Field, ++FieldNo) {
391 llvm::Constant *EltInit;
392 if (ElementNo < ILE->getNumInits())
393 EltInit = CGM.EmitConstantExpr(ILE->
getInit(ElementNo++),
396 EltInit = CGM.EmitNullConstant(Field->
getType());
406 if (
auto *CI = dyn_cast<llvm::ConstantInt>(EltInit)) {
422 : Decl(Decl), Offset(Offset), Index(Index) {
437 const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(RD);
441 if (CD->isDynamicClass() && !IsPrimaryBase) {
442 llvm::Constant *VTableAddressPoint =
443 CGM.getCXXABI().getVTableAddressPointForConstExpr(
445 AppendBytes(Offset, VTableAddressPoint);
451 Bases.reserve(CD->getNumBases());
454 BaseEnd = CD->bases_end();
Base != BaseEnd; ++
Base, ++BaseNo) {
455 assert(!
Base->isVirtual() &&
"should not have virtual bases here");
458 Bases.push_back(BaseInfo(BD, BaseOffset, BaseNo));
460 std::stable_sort(Bases.begin(), Bases.end());
462 for (
unsigned I = 0, N = Bases.size();
I != N; ++
I) {
463 BaseInfo &
Base = Bases[
I];
466 Build(Val.
getStructBase(Base.Index), Base.Decl, IsPrimaryBase,
467 VTableClass, Offset + Base.Offset);
471 unsigned FieldNo = 0;
472 uint64_t OffsetBits = CGM.getContext().toBits(Offset);
475 FieldEnd = RD->
field_end(); Field != FieldEnd; ++Field, ++FieldNo) {
487 llvm::Constant *EltInit =
488 CGM.EmitConstantValueForMemory(FieldValue, Field->
getType(), CGF);
489 assert(EltInit &&
"EmitConstantValue can't fail");
493 AppendField(*Field, Layout.
getFieldOffset(FieldNo) + OffsetBits, EltInit);
496 AppendBitField(*Field, Layout.
getFieldOffset(FieldNo) + OffsetBits,
497 cast<llvm::ConstantInt>(EltInit));
502 llvm::Constant *ConstStructBuilder::Finalize(
QualType Ty) {
504 const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(RD);
508 if (NextFieldOffsetInChars > LayoutSizeInChars) {
512 "Must have flexible array member if struct is bigger than type!");
518 NextFieldOffsetInChars.
alignTo(LLVMStructAlignment);
520 if (LLVMSizeInChars != LayoutSizeInChars)
521 AppendTailPadding(LayoutSizeInChars);
523 LLVMSizeInChars = NextFieldOffsetInChars.
alignTo(LLVMStructAlignment);
526 if (NextFieldOffsetInChars <= LayoutSizeInChars &&
527 LLVMSizeInChars > LayoutSizeInChars) {
528 assert(!Packed &&
"Size mismatch!");
530 ConvertStructToPacked();
531 assert(NextFieldOffsetInChars <= LayoutSizeInChars &&
532 "Converting to packed did not help!");
535 LLVMSizeInChars = NextFieldOffsetInChars.
alignTo(LLVMStructAlignment);
537 assert(LayoutSizeInChars == LLVMSizeInChars &&
538 "Tail padding mismatch!");
543 llvm::StructType *STy =
544 llvm::ConstantStruct::getTypeForElements(CGM.getLLVMContext(),
546 llvm::Type *ValTy = CGM.getTypes().ConvertType(Ty);
547 if (llvm::StructType *ValSTy = dyn_cast<llvm::StructType>(ValTy)) {
548 if (ValSTy->isLayoutIdentical(STy))
552 llvm::Constant *
Result = llvm::ConstantStruct::get(STy, Elements);
554 assert(NextFieldOffsetInChars.alignTo(getAlignment(Result)) ==
555 getSizeInChars(Result) &&
561 llvm::Constant *ConstStructBuilder::BuildStruct(
CodeGenModule &CGM,
563 ConstExprEmitter *Emitter,
564 llvm::ConstantStruct *Base,
566 ConstStructBuilder
Builder(CGM, CGF);
567 if (!
Builder.Build(Emitter, Base, Updater))
572 llvm::Constant *ConstStructBuilder::BuildStruct(
CodeGenModule &CGM,
575 ConstStructBuilder
Builder(CGM, CGF);
583 llvm::Constant *ConstStructBuilder::BuildStruct(
CodeGenModule &CGM,
587 ConstStructBuilder
Builder(CGM, CGF);
593 return Builder.Finalize(ValTy);
605 class ConstExprEmitter :
606 public StmtVisitor<ConstExprEmitter, llvm::Constant*> {
609 llvm::LLVMContext &VMContext;
612 : CGM(cgm), CGF(cgf), VMContext(cgm.getLLVMContext()) {
619 llvm::Constant *VisitStmt(
Stmt *
S) {
623 llvm::Constant *VisitParenExpr(
ParenExpr *PE) {
636 llvm::Constant *VisitChooseExpr(
ChooseExpr *CE) {
644 llvm::Constant *VisitCastExpr(
CastExpr* E) {
645 if (
const auto *ECE = dyn_cast<ExplicitCastExpr>(E))
649 if (!C)
return nullptr;
657 "Destination type is not union type!");
664 Types.push_back(C->getType());
665 unsigned CurSize = CGM.
getDataLayout().getTypeAllocSize(C->getType());
666 unsigned TotalSize = CGM.
getDataLayout().getTypeAllocSize(destType);
668 assert(CurSize <= TotalSize &&
"Union size mismatch!");
669 if (
unsigned NumPadBytes = TotalSize - CurSize) {
672 Ty = llvm::ArrayType::get(Ty, NumPadBytes);
674 Elts.push_back(llvm::UndefValue::get(Ty));
678 llvm::StructType* STy =
679 llvm::StructType::get(C->getType()->getContext(), Types,
false);
680 return llvm::ConstantStruct::get(STy, Elts);
683 case CK_AddressSpaceConversion:
684 return llvm::ConstantExpr::getAddrSpaceCast(C, destType);
686 case CK_LValueToRValue:
687 case CK_AtomicToNonAtomic:
688 case CK_NonAtomicToAtomic:
690 case CK_ConstructorConversion:
693 case CK_Dependent: llvm_unreachable(
"saw dependent cast!");
695 case CK_BuiltinFnToFnPtr:
696 llvm_unreachable(
"builtin functions are handled elsewhere");
698 case CK_ReinterpretMemberPointer:
699 case CK_DerivedToBaseMemberPointer:
700 case CK_BaseToDerivedMemberPointer:
704 case CK_ObjCObjectLValueCast:
705 case CK_ARCProduceObject:
706 case CK_ARCConsumeObject:
707 case CK_ARCReclaimReturnedObject:
708 case CK_ARCExtendBlockObject:
709 case CK_CopyAndAutoreleaseBlockObject:
717 case CK_LValueBitCast:
718 case CK_NullToMemberPointer:
719 case CK_UserDefinedConversion:
720 case CK_CPointerToObjCPointerCast:
721 case CK_BlockPointerToObjCPointerCast:
722 case CK_AnyPointerToBlockPointerCast:
723 case CK_ArrayToPointerDecay:
724 case CK_FunctionToPointerDecay:
725 case CK_BaseToDerived:
726 case CK_DerivedToBase:
727 case CK_UncheckedDerivedToBase:
728 case CK_MemberPointerToBoolean:
730 case CK_FloatingRealToComplex:
731 case CK_FloatingComplexToReal:
732 case CK_FloatingComplexToBoolean:
733 case CK_FloatingComplexCast:
734 case CK_FloatingComplexToIntegralComplex:
735 case CK_IntegralRealToComplex:
736 case CK_IntegralComplexToReal:
737 case CK_IntegralComplexToBoolean:
738 case CK_IntegralComplexCast:
739 case CK_IntegralComplexToFloatingComplex:
740 case CK_PointerToIntegral:
741 case CK_PointerToBoolean:
742 case CK_NullToPointer:
743 case CK_IntegralCast:
744 case CK_BooleanToSignedIntegral:
745 case CK_IntegralToPointer:
746 case CK_IntegralToBoolean:
747 case CK_IntegralToFloating:
748 case CK_FloatingToIntegral:
749 case CK_FloatingToBoolean:
750 case CK_FloatingCast:
751 case CK_ZeroToOCLEvent:
754 llvm_unreachable(
"Invalid CastKind");
777 llvm::Constant *EmitArrayInitialization(
InitListExpr *ILE) {
781 llvm::ArrayType *AType =
782 cast<llvm::ArrayType>(ConvertType(ILE->
getType()));
785 unsigned NumElements = AType->getNumElements();
789 unsigned NumInitableElts =
std::min(NumInitElements, NumElements);
793 llvm::Constant *fillC;
797 fillC = llvm::Constant::getNullValue(ElemTy);
802 if (fillC->isNullValue() && !NumInitableElts)
803 return llvm::ConstantAggregateZero::get(AType);
806 std::vector<llvm::Constant*> Elts;
807 Elts.reserve(NumInitableElts + NumElements);
809 bool RewriteType =
false;
810 for (
unsigned i = 0; i < NumInitableElts; ++i) {
815 RewriteType |= (C->getType() != ElemTy);
819 RewriteType |= (fillC->getType() != ElemTy);
820 Elts.resize(NumElements, fillC);
824 std::vector<llvm::Type*> Types;
825 Types.reserve(NumInitableElts + NumElements);
826 for (
unsigned i = 0, e = Elts.size(); i < e; ++i)
827 Types.push_back(Elts[i]->getType());
828 llvm::StructType *SType = llvm::StructType::get(AType->getContext(),
830 return llvm::ConstantStruct::get(SType, Elts);
833 return llvm::ConstantArray::get(AType, Elts);
836 llvm::Constant *EmitRecordInitialization(
InitListExpr *ILE) {
837 return ConstStructBuilder::BuildStruct(CGM, CGF, ILE);
846 return EmitArrayInitialization(ILE);
849 return EmitRecordInitialization(ILE);
854 llvm::Constant *EmitDesignatedInitUpdater(llvm::Constant *Base,
859 llvm::ArrayType *AType = cast<llvm::ArrayType>(ConvertType(ExprType));
860 llvm::Type *ElemType = AType->getElementType();
863 unsigned NumElements = AType->getNumElements();
865 std::vector<llvm::Constant *> Elts;
866 Elts.reserve(NumElements);
868 if (llvm::ConstantDataArray *DataArray =
869 dyn_cast<llvm::ConstantDataArray>(Base))
870 for (
unsigned i = 0; i != NumElements; ++i)
871 Elts.push_back(DataArray->getElementAsConstant(i));
872 else if (llvm::ConstantArray *Array =
873 dyn_cast<llvm::ConstantArray>(Base))
874 for (
unsigned i = 0; i != NumElements; ++i)
875 Elts.push_back(Array->getOperand(i));
879 llvm::Constant *fillC =
nullptr;
881 if (!isa<NoInitExpr>(filler))
883 bool RewriteType = (fillC && fillC->getType() != ElemType);
885 for (
unsigned i = 0; i != NumElements; ++i) {
886 Expr *Init =
nullptr;
887 if (i < NumInitElements)
892 else if (!Init || isa<NoInitExpr>(Init))
894 else if (
InitListExpr *ChildILE = dyn_cast<InitListExpr>(Init))
895 Elts[i] = EmitDesignatedInitUpdater(Elts[i], ChildILE);
901 RewriteType |= (Elts[i]->getType() != ElemType);
905 std::vector<llvm::Type *> Types;
906 Types.reserve(NumElements);
907 for (
unsigned i = 0; i != NumElements; ++i)
908 Types.push_back(Elts[i]->getType());
909 llvm::StructType *SType = llvm::StructType::get(AType->getContext(),
911 return llvm::ConstantStruct::get(SType, Elts);
914 return llvm::ConstantArray::get(AType, Elts);
918 return ConstStructBuilder::BuildStruct(CGM, CGF,
this,
919 dyn_cast<llvm::ConstantStruct>(Base), Updater);
925 return EmitDesignatedInitUpdater(
943 if (!RD->hasTrivialDestructor())
950 assert(E->
getNumArgs() == 1 &&
"trivial ctor with > 1 argument");
952 "trivial ctor has argument but isn't a copy/move ctor");
956 "argument to copy ctor is of wrong type");
976 T = cast<TypeOfExprType>(T)->getUnderlyingExpr()->getType();
981 Str.resize(CAT->
getSize().getZExtValue(),
'\0');
982 return llvm::ConstantDataArray::getString(VMContext, Str,
false);
985 llvm::Constant *VisitUnaryExtension(
const UnaryOperator *E) {
997 if (
Decl->hasAttr<WeakRefAttr>())
1001 if (
const VarDecl* VD = dyn_cast<VarDecl>(
Decl)) {
1003 if (!VD->hasLocalStorage()) {
1005 if (VD->isFileVarDecl() || VD->hasExternalStorage())
1007 else if (VD->isLocalVarDecl()) {
1017 Expr *E =
const_cast<Expr*
>(LVBase.get<
const Expr*>());
1018 switch (E->getStmtClass()) {
1020 case Expr::CompoundLiteralExprClass: {
1031 auto GV =
new llvm::GlobalVariable(CGM.
getModule(), C->getType(),
1034 C,
".compoundliteral",
nullptr,
1035 llvm::GlobalVariable::NotThreadLocal,
1040 case Expr::StringLiteralClass:
1042 case Expr::ObjCEncodeExprClass:
1044 case Expr::ObjCStringLiteralClass: {
1050 case Expr::PredefinedExprClass: {
1051 unsigned Type = cast<PredefinedExpr>(
E)->getIdentType();
1054 return cast<ConstantAddress>(Res.
getAddress());
1061 case Expr::AddrLabelExprClass: {
1062 assert(CGF &&
"Invalid address of label expression outside function.");
1063 llvm::Constant *Ptr =
1065 Ptr = llvm::ConstantExpr::getBitCast(Ptr, ConvertType(E->
getType()));
1068 case Expr::CallExprClass: {
1072 Builtin::BI__builtin___CFStringMakeConstantString &&
1074 Builtin::BI__builtin___NSStringMakeConstantString)
1079 Builtin::BI__builtin___NSStringMakeConstantString) {
1085 case Expr::BlockExprClass: {
1086 std::string FunctionName;
1088 FunctionName = CGF->
CurFn->getName();
1090 FunctionName =
"global";
1093 llvm::Constant *Ptr =
1097 case Expr::CXXTypeidExprClass: {
1107 case Expr::CXXUuidofExprClass: {
1110 case Expr::MaterializeTemporaryExprClass: {
1127 bool ConstStructBuilder::Build(ConstExprEmitter *Emitter,
1128 llvm::ConstantStruct *Base,
1130 assert(Base &&
"base expression should not be empty");
1135 const llvm::StructLayout *BaseLayout = CGM.
getDataLayout().getStructLayout(
1137 unsigned FieldNo = -1;
1138 unsigned ElementNo = 0;
1143 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(RD))
1144 if (CXXRD->getNumBases())
1157 llvm::Constant *EltInit = Base->getOperand(ElementNo);
1163 BaseLayout->getElementOffsetInBits(ElementNo))
1168 Expr *Init =
nullptr;
1169 if (ElementNo < Updater->getNumInits())
1170 Init = Updater->
getInit(ElementNo);
1172 if (!Init || isa<NoInitExpr>(Init))
1174 else if (
InitListExpr *ChildILE = dyn_cast<InitListExpr>(Init))
1175 EltInit = Emitter->EmitDesignatedInitUpdater(EltInit, ChildILE);
1186 else if (llvm::ConstantInt *CI = dyn_cast<llvm::ConstantInt>(EltInit))
1207 dyn_cast_or_null<CXXConstructExpr>(D.
getInit())) {
1227 assert(E &&
"No initializer to emit");
1229 llvm::Constant* C = ConstExprEmitter(*
this, CGF).Visit(const_cast<Expr*>(E));
1230 if (C && C->getType()->isIntegerTy(1)) {
1232 C = llvm::ConstantExpr::getZExt(C, BoolTy);
1242 bool Success =
false;
1249 llvm::Constant *C =
nullptr;
1253 C = ConstExprEmitter(*
this, CGF).Visit(const_cast<Expr*>(E));
1255 if (C && C->getType()->isIntegerTy(1)) {
1257 C = llvm::ConstantExpr::getZExt(C, BoolTy);
1267 QualType InnerType = AT->getValueType();
1270 uint64_t InnerSize = Context.
getTypeSize(InnerType);
1271 uint64_t OuterSize = Context.
getTypeSize(DestType);
1272 if (InnerSize == OuterSize)
1275 assert(InnerSize < OuterSize &&
"emitted over-large constant for atomic");
1276 llvm::Constant *Elts[] = {
1278 llvm::ConstantAggregateZero::get(
1279 llvm::ArrayType::get(
Int8Ty, (OuterSize - InnerSize) / 8))
1281 return llvm::ConstantStruct::getAnon(Elts);
1286 llvm_unreachable(
"Constant expressions should be initialized.");
1289 llvm::Constant *Offset =
1292 llvm::Constant *C =
nullptr;
1295 if (isa<llvm::ArrayType>(DestTy)) {
1296 assert(Offset->isNullValue() &&
"offset on array initializer");
1297 return ConstExprEmitter(*
this, CGF).Visit(
1298 const_cast<Expr*>(LVBase.get<
const Expr*>()));
1301 C = ConstExprEmitter(*
this, CGF).EmitLValue(LVBase).getPointer();
1304 if (!Offset->isNullValue()) {
1305 unsigned AS = C->getType()->getPointerAddressSpace();
1307 llvm::Constant *Casted = llvm::ConstantExpr::getBitCast(C, CharPtrTy);
1308 Casted = llvm::ConstantExpr::getGetElementPtr(
Int8Ty, Casted, Offset);
1309 C = llvm::ConstantExpr::getPointerCast(Casted, C->getType());
1314 if (isa<llvm::PointerType>(DestTy))
1315 return llvm::ConstantExpr::getPointerCast(C, DestTy);
1317 return llvm::ConstantExpr::getPtrToInt(C, DestTy);
1323 if (isa<llvm::PointerType>(DestTy)) {
1326 C = llvm::ConstantExpr::getIntegerCast(
1329 return llvm::ConstantExpr::getIntToPtr(C, DestTy);
1333 if (C->getType() != DestTy)
1334 return llvm::ConstantExpr::getTrunc(C, DestTy);
1340 return llvm::ConstantInt::get(VMContext, Value.
getInt());
1342 llvm::Constant *Complex[2];
1344 Complex[0] = llvm::ConstantInt::get(VMContext,
1346 Complex[1] = llvm::ConstantInt::get(VMContext,
1350 llvm::StructType *STy = llvm::StructType::get(Complex[0]->getType(),
1351 Complex[1]->getType(),
1353 return llvm::ConstantStruct::get(STy, Complex);
1356 const llvm::APFloat &Init = Value.
getFloat();
1357 if (&Init.getSemantics() == &llvm::APFloat::IEEEhalf &&
1360 return llvm::ConstantInt::get(VMContext, Init.bitcastToAPInt());
1362 return llvm::ConstantFP::get(VMContext, Init);
1365 llvm::Constant *Complex[2];
1367 Complex[0] = llvm::ConstantFP::get(VMContext,
1369 Complex[1] = llvm::ConstantFP::get(VMContext,
1373 llvm::StructType *STy = llvm::StructType::get(Complex[0]->getType(),
1374 Complex[1]->getType(),
1376 return llvm::ConstantStruct::get(STy, Complex);
1382 for (
unsigned I = 0;
I != NumElts; ++
I) {
1385 Inits[
I] = llvm::ConstantInt::get(VMContext, Elt.
getInt());
1387 Inits[
I] = llvm::ConstantFP::get(VMContext, Elt.
getFloat());
1389 llvm_unreachable(
"unsupported vector element type");
1391 return llvm::ConstantVector::get(Inits);
1401 LHS = llvm::ConstantExpr::getPtrToInt(LHS,
IntPtrTy);
1402 RHS = llvm::ConstantExpr::getPtrToInt(RHS,
IntPtrTy);
1403 llvm::Constant *AddrLabelDiff = llvm::ConstantExpr::getSub(LHS, RHS);
1408 return llvm::ConstantExpr::getTruncOrBitCast(AddrLabelDiff, ResultType);
1412 return ConstStructBuilder::BuildStruct(*
this, CGF, Value, DestType);
1419 llvm::Constant *Filler =
nullptr;
1429 if (Filler && Filler->isNullValue() && !NumInitElts) {
1430 llvm::ArrayType *AType =
1431 llvm::ArrayType::get(CommonElementType, NumElements);
1432 return llvm::ConstantAggregateZero::get(AType);
1435 std::vector<llvm::Constant*> Elts;
1436 Elts.reserve(NumElements);
1437 for (
unsigned I = 0;
I < NumElements; ++
I) {
1438 llvm::Constant *C = Filler;
1439 if (
I < NumInitElts)
1443 assert(Filler &&
"Missing filler for implicit elements of initializer");
1445 CommonElementType = C->getType();
1446 else if (C->getType() != CommonElementType)
1447 CommonElementType =
nullptr;
1451 if (!CommonElementType) {
1453 std::vector<llvm::Type*> Types;
1454 Types.reserve(NumElements);
1455 for (
unsigned i = 0, e = Elts.size(); i < e; ++i)
1456 Types.push_back(Elts[i]->getType());
1457 llvm::StructType *SType = llvm::StructType::get(VMContext, Types,
true);
1458 return llvm::ConstantStruct::get(SType, Elts);
1461 llvm::ArrayType *AType =
1462 llvm::ArrayType::get(CommonElementType, NumElements);
1463 return llvm::ConstantArray::get(AType, Elts);
1468 llvm_unreachable(
"Unknown APValue kind");
1476 if (C->getType()->isIntegerTy(1)) {
1478 C = llvm::ConstantExpr::getZExt(C, BoolTy);
1485 assert(E->
isFileScope() &&
"not a file-scope compound literal expr");
1486 return ConstExprEmitter(*
this,
nullptr).EmitLValue(E);
1496 if (
const CXXMethodDecl *method = dyn_cast<CXXMethodDecl>(decl))
1511 bool asCompleteObject) {
1513 llvm::StructType *structure =
1517 unsigned numElements = structure->getNumElements();
1518 std::vector<llvm::Constant *> elements(numElements);
1521 for (
const auto &
I : record->
bases()) {
1522 if (
I.isVirtual()) {
1529 cast<CXXRecordDecl>(
I.getType()->castAs<
RecordType>()->getDecl());
1536 llvm::Type *baseType = structure->getElementType(fieldIndex);
1541 for (
const auto *Field : record->
fields()) {
1553 if (
const auto *FieldRD =
1555 if (FieldRD->findFirstNamedDataMember())
1561 if (asCompleteObject) {
1562 for (
const auto &
I : record->
vbases()) {
1564 cast<CXXRecordDecl>(
I.getType()->castAs<
RecordType>()->getDecl());
1573 if (elements[fieldIndex])
continue;
1575 llvm::Type *baseType = structure->getElementType(fieldIndex);
1581 for (
unsigned i = 0; i != numElements; ++i) {
1583 elements[i] = llvm::Constant::getNullValue(structure->getElementType(i));
1586 return llvm::ConstantStruct::get(structure, elements);
1597 return llvm::Constant::getNullValue(baseType);
1604 if (
getTypes().isZeroInitializable(T))
1605 return llvm::Constant::getNullValue(
getTypes().ConvertTypeForMem(T));
1608 llvm::ArrayType *ATy =
1614 unsigned NumElements = CAT->
getSize().getZExtValue();
1616 return llvm::ConstantArray::get(ATy, Array);
1625 "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...
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
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.
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.
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
CharUnits alignTo(const CharUnits &Align) const
alignTo - Returns the next integer (mod 2**64) that is greater than or equal to this quantity and is ...
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.
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...
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.
bool isCopyOrMoveConstructor(unsigned &TypeQuals) const
Determine whether this is a copy or move constructor.
bool isMemberDataPointerType() const
llvm::Type * ConvertTypeForMem(QualType T)
ConvertTypeForMem - Convert type T into a llvm::Type.
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
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 ...
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()
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
llvm::Constant * GetConstantArrayFromStringLiteral(const StringLiteral *E)
Return a constant array for the given string.
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...
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)
static CharUnits One()
One - Construct a CharUnits quantity of one.
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.
unsigned getCharAlign() const
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.
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.
char __ovld __cnfn min(char x, char y)
Returns y if y < x, otherwise it returns x.
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
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 .
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.
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)
llvm::Constant * getOrCreateStaticVarDecl(const VarDecl &D, llvm::GlobalValue::LinkageTypes Linkage)
bool cleanupsHaveSideEffects() const
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.
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
llvm::Constant * GetAddrOfGlobalVar(const VarDecl *D, llvm::Type *Ty=nullptr, bool IsForDefinition=false)
Return the llvm::Constant for the address of the given global variable.
CharUnits getSize() const
getSize - Get the record size in characters.
virtual ConstantAddress GenerateConstantString(const StringLiteral *)=0
Generate a constant string object.
bool isConstant(const ASTContext &Ctx) const
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()
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.
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.
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.
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.
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
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.
detail::InMemoryDirectory::const_iterator E
A pointer to member type per C++ 8.3.3 - Pointers to members.
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).
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.
virtual llvm::Constant * EmitMemberDataPointer(const MemberPointerType *MPT, CharUnits offset)
Create a member pointer for the given field.
Expr * getArg(unsigned Arg)
Return the specified argument.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
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.
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
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...
char __ovld __cnfn max(char x, char y)
Returns y if x < y, otherwise it returns x.
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.
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
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.
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()