llvm.org GIT mirror llvm / d35f86e
Suppress all uses of LLVM_END_WITH_NULL. NFC. Use variadic templates instead of relying on <cstdarg> + sentinel. This enforces better type checking and makes code more readable. Differential Revision: https://reviews.llvm.org/D32541 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302571 91177308-0d34-0410-b5e6-96231b3b80d8 Serge Guelton 2 years ago
22 changed file(s) with 122 addition(s) and 157 deletion(s). Raw diff Collapse all Expand all
705705 std::is_same::value || is_one_of::value;
706706 };
707707
708 /// \brief traits class for checking whether type T is a base class for all
709 /// the given types in the variadic list.
710 template struct are_base_of {
711 static const bool value = true;
712 };
713
714 template
715 struct are_base_of {
716 static const bool value =
717 std::is_base_of::value && are_base_of::value;
718 };
719
708720 //===----------------------------------------------------------------------===//
709721 // Extra additions for arrays
710722 //===----------------------------------------------------------------------===//
2525 #include "llvm/ADT/ArrayRef.h"
2626 #include "llvm/ADT/None.h"
2727 #include "llvm/ADT/Optional.h"
28 #include "llvm/ADT/STLExtras.h"
2829 #include "llvm/ADT/StringRef.h"
2930 #include "llvm/IR/Constant.h"
3031 #include "llvm/IR/DerivedTypes.h"
451452 public:
452453 // ConstantStruct accessors
453454 static Constant *get(StructType *T, ArrayRef V);
454 static Constant *get(StructType *T, ...) LLVM_END_WITH_NULL;
455
456 template
457 static typename std::enable_if::value,
458 Constant *>::type
459 get(StructType *T, Csts *... Vs) {
460 SmallVector Values{{Vs...}};
461 return get(T, Values);
462 }
455463
456464 /// Return an anonymous struct that has the specified elements.
457465 /// If the struct is possibly empty, then you must specify a context.
1818 #define LLVM_IR_DERIVEDTYPES_H
1919
2020 #include "llvm/ADT/ArrayRef.h"
21 #include "llvm/ADT/STLExtras.h"
2122 #include "llvm/ADT/StringRef.h"
2223 #include "llvm/IR/Type.h"
2324 #include "llvm/Support/Casting.h"
227228 static StructType *create(LLVMContext &Context, ArrayRef Elements,
228229 StringRef Name, bool isPacked = false);
229230 static StructType *create(LLVMContext &Context, ArrayRef Elements);
230 static StructType *create(StringRef Name, Type *elt1, ...) LLVM_END_WITH_NULL;
231 template
232 static typename std::enable_if::value,
233 StructType *>::type
234 create(StringRef Name, Type *elt1, Tys *... elts) {
235 assert(elt1 && "Cannot create a struct type with no elements with this");
236 SmallVector StructFields{{elt1, elts...}};
237 return create(StructFields, Name);
238 }
231239
232240 /// This static method is the primary way to create a literal StructType.
233241 static StructType *get(LLVMContext &Context, ArrayRef Elements,
239247 /// This static method is a convenience method for creating structure types by
240248 /// specifying the elements as arguments. Note that this method always returns
241249 /// a non-packed struct, and requires at least one element type.
242 static StructType *get(Type *elt1, ...) LLVM_END_WITH_NULL;
250 template
251 static typename std::enable_if::value,
252 StructType *>::type
253 get(Type *elt1, Tys *... elts) {
254 assert(elt1 && "Cannot create a struct type with no elements with this");
255 LLVMContext &Ctx = elt1->getContext();
256 SmallVector StructFields{{elt1, elts...}};
257 return llvm::StructType::get(Ctx, StructFields);
258 }
243259
244260 bool isPacked() const { return (getSubclassData() & SCDB_Packed) != 0; }
245261
268284
269285 /// Specify a body for an opaque identified type.
270286 void setBody(ArrayRef Elements, bool isPacked = false);
271 void setBody(Type *elt1, ...) LLVM_END_WITH_NULL;
287
288 template
289 typename std::enable_if::value, void>::type
290 setBody(Type *elt1, Tys *... elts) {
291 assert(elt1 && "Cannot create a struct type with no elements with this");
292 SmallVector StructFields{{elt1, elts...}};
293 setBody(StructFields);
294 }
272295
273296 /// Return true if the specified type is valid as a element type.
274297 static bool isValidElementType(Type *ElemTy);
108108 #define LLVM_PREFETCH(addr, rw, locality) __builtin_prefetch(addr, rw, locality)
109109 #else
110110 #define LLVM_PREFETCH(addr, rw, locality)
111 #endif
112
113 #if __has_attribute(sentinel) || LLVM_GNUC_PREREQ(3, 0, 0)
114 #define LLVM_END_WITH_NULL __attribute__((sentinel))
115 #else
116 #define LLVM_END_WITH_NULL
117111 #endif
118112
119113 #if __has_attribute(used) || LLVM_GNUC_PREREQ(3, 1, 0)
9292 doubleUnderDataTy, // __data
9393 VoidPtrTy, // __personality
9494 VoidPtrTy, // __lsda
95 doubleUnderJBufTy, // __jbuf
96 nullptr);
95 doubleUnderJBufTy // __jbuf
96 );
9797
9898 return true;
9999 }
2929 #include "llvm/Support/MathExtras.h"
3030 #include "llvm/Support/raw_ostream.h"
3131 #include
32 #include
32
3333 using namespace llvm;
3434
3535 //===----------------------------------------------------------------------===//
963963 return UndefValue::get(ST);
964964
965965 return ST->getContext().pImpl->StructConstants.getOrCreate(ST, V);
966 }
967
968 Constant *ConstantStruct::get(StructType *T, ...) {
969 va_list ap;
970 SmallVector Values;
971 va_start(ap, T);
972 while (Constant *Val = va_arg(ap, llvm::Constant*))
973 Values.push_back(Val);
974 va_end(ap);
975 return get(T, Values);
976966 }
977967
978968 ConstantVector::ConstantVector(VectorType *T, ArrayRef V)
18091799 Constant *ConstantExpr::getAlignOf(Type* Ty) {
18101800 // alignof is implemented as: (i64) gep ({i1,Ty}*)null, 0, 1
18111801 // Note that a non-inbounds gep is used, as null isn't within any object.
1812 Type *AligningTy =
1813 StructType::get(Type::getInt1Ty(Ty->getContext()), Ty, nullptr);
1802 Type *AligningTy = StructType::get(Type::getInt1Ty(Ty->getContext()), Ty);
18141803 Constant *NullPtr = Constant::getNullValue(AligningTy->getPointerTo(0));
18151804 Constant *Zero = ConstantInt::get(Type::getInt64Ty(Ty->getContext()), 0);
18161805 Constant *One = ConstantInt::get(Type::getInt32Ty(Ty->getContext()), 1);
15421542 SynchronizationScope SynchScope,
15431543 Instruction *InsertBefore)
15441544 : Instruction(
1545 StructType::get(Cmp->getType(), Type::getInt1Ty(Cmp->getContext()),
1546 nullptr),
1545 StructType::get(Cmp->getType(), Type::getInt1Ty(Cmp->getContext())),
15471546 AtomicCmpXchg, OperandTraits::op_begin(this),
15481547 OperandTraits::operands(this), InsertBefore) {
15491548 Init(Ptr, Cmp, NewVal, SuccessOrdering, FailureOrdering, SynchScope);
15551554 SynchronizationScope SynchScope,
15561555 BasicBlock *InsertAtEnd)
15571556 : Instruction(
1558 StructType::get(Cmp->getType(), Type::getInt1Ty(Cmp->getContext()),
1559 nullptr),
1557 StructType::get(Cmp->getType(), Type::getInt1Ty(Cmp->getContext())),
15601558 AtomicCmpXchg, OperandTraits::op_begin(this),
15611559 OperandTraits::operands(this), InsertAtEnd) {
15621560 Init(Ptr, Cmp, NewVal, SuccessOrdering, FailureOrdering, SynchScope);
2929 #include "llvm/Support/Path.h"
3030 #include "llvm/Support/RandomNumberGenerator.h"
3131 #include
32 #include
3332 #include
3433
3534 using namespace llvm;
1515 #include "llvm/ADT/SmallString.h"
1616 #include "llvm/IR/Module.h"
1717 #include
18 #include
1918 using namespace llvm;
2019
2120 //===----------------------------------------------------------------------===//
418417 return get(Context, None, isPacked);
419418 }
420419
421 StructType *StructType::get(Type *type, ...) {
422 assert(type && "Cannot create a struct type with no elements with this");
423 LLVMContext &Ctx = type->getContext();
424 va_list ap;
425 SmallVector StructFields;
426 va_start(ap, type);
427 while (type) {
428 StructFields.push_back(type);
429 type = va_arg(ap, llvm::Type*);
430 }
431 auto *Ret = llvm::StructType::get(Ctx, StructFields);
432 va_end(ap);
433 return Ret;
434 }
435
436420 StructType *StructType::create(LLVMContext &Context, ArrayRef Elements,
437421 StringRef Name, bool isPacked) {
438422 StructType *ST = create(Context, Name);
459443 assert(!Elements.empty() &&
460444 "This method may not be invoked with an empty list");
461445 return create(Elements[0]->getContext(), Elements, StringRef());
462 }
463
464 StructType *StructType::create(StringRef Name, Type *type, ...) {
465 assert(type && "Cannot create a struct type with no elements with this");
466 LLVMContext &Ctx = type->getContext();
467 va_list ap;
468 SmallVector StructFields;
469 va_start(ap, type);
470 while (type) {
471 StructFields.push_back(type);
472 type = va_arg(ap, llvm::Type*);
473 }
474 auto *Ret = llvm::StructType::create(Ctx, StructFields, Name);
475 va_end(ap);
476 return Ret;
477446 }
478447
479448 bool StructType::isSized(SmallPtrSetImpl *Visited) const {
505474 if (!SymbolTableEntry) return StringRef();
506475
507476 return ((StringMapEntry *)SymbolTableEntry)->getKey();
508 }
509
510 void StructType::setBody(Type *type, ...) {
511 assert(type && "Cannot create a struct type with no elements with this");
512 va_list ap;
513 SmallVector StructFields;
514 va_start(ap, type);
515 while (type) {
516 StructFields.push_back(type);
517 type = va_arg(ap, llvm::Type*);
518 }
519 setBody(StructFields);
520 va_end(ap);
521477 }
522478
523479 bool StructType::isValidElementType(Type *ElemTy) {
22642264 SDValue Callee =
22652265 DAG.getExternalSymbol(LibcallName, getPointerTy(DAG.getDataLayout()));
22662266
2267 StructType *RetTy = StructType::get(ArgTy, ArgTy, nullptr);
2267 StructType *RetTy = StructType::get(ArgTy, ArgTy);
22682268 TargetLowering::CallLoweringInfo CLI(DAG);
22692269 CLI.setDebugLoc(dl)
22702270 .setChain(DAG.getEntryNode())
73637363 const TargetLowering &TLI = DAG.getTargetLoweringInfo();
73647364
73657365 // Pair of floats / doubles used to pass the result.
7366 Type *RetTy = StructType::get(ArgTy, ArgTy, nullptr);
7366 Type *RetTy = StructType::get(ArgTy, ArgTy);
73677367 auto &DL = DAG.getDataLayout();
73687368
73697369 ArgListTy Args;
1311313113 SDValue Callee = DAG.getExternalSymbol(getLibcallName(LC),
1311413114 getPointerTy(DAG.getDataLayout()));
1311513115
13116 Type *RetTy = (Type*)StructType::get(Ty, Ty, nullptr);
13116 Type *RetTy = StructType::get(Ty, Ty);
1311713117
1311813118 if (Subtarget->isTargetWindows())
1311913119 InChain = WinDBZCheckDenominator(DAG, Op.getNode(), InChain);
2330523305 SDValue Callee =
2330623306 DAG.getExternalSymbol(LibcallName, TLI.getPointerTy(DAG.getDataLayout()));
2330723307
23308 Type *RetTy = isF64
23309 ? (Type*)StructType::get(ArgTy, ArgTy, nullptr)
23310 : (Type*)VectorType::get(ArgTy, 4);
23308 Type *RetTy = isF64 ? (Type *)StructType::get(ArgTy, ArgTy)
23309 : (Type *)VectorType::get(ArgTy, 4);
2331123310
2331223311 TargetLowering::CallLoweringInfo CLI(DAG);
2331323312 CLI.setDebugLoc(dl)
17811781 // On recent Mach-O platforms, use a structure which binds the liveness of
17821782 // the global variable to the metadata struct. Keep the list of "Liveness" GV
17831783 // created to be added to llvm.compiler.used
1784 StructType *LivenessTy = StructType::get(IntptrTy, IntptrTy, nullptr);
1784 StructType *LivenessTy = StructType::get(IntptrTy, IntptrTy);
17851785 SmallVector LivenessGlobals(ExtendedGlobals.size());
17861786
17871787 for (size_t i = 0; i < ExtendedGlobals.size(); i++) {
17921792
17931793 // On recent Mach-O platforms, we emit the global metadata in a way that
17941794 // allows the linker to properly strip dead globals.
1795 auto LivenessBinder = ConstantStruct::get(
1796 LivenessTy, Initializer->getAggregateElement(0u),
1797 ConstantExpr::getPointerCast(Metadata, IntptrTy), nullptr);
1795 auto LivenessBinder =
1796 ConstantStruct::get(LivenessTy, Initializer->getAggregateElement(0u),
1797 ConstantExpr::getPointerCast(Metadata, IntptrTy));
17981798 GlobalVariable *Liveness = new GlobalVariable(
17991799 M, LivenessTy, false, GlobalVariable::InternalLinkage, LivenessBinder,
18001800 Twine("__asan_binder_") + G->getName());
18921892 // We initialize an array of such structures and pass it to a run-time call.
18931893 StructType *GlobalStructTy =
18941894 StructType::get(IntptrTy, IntptrTy, IntptrTy, IntptrTy, IntptrTy,
1895 IntptrTy, IntptrTy, IntptrTy, nullptr);
1895 IntptrTy, IntptrTy, IntptrTy);
18961896 SmallVector NewGlobals(n);
18971897 SmallVector Initializers(n);
18981898
19281928 assert(((RightRedzoneSize + SizeInBytes) % MinRZ) == 0);
19291929 Type *RightRedZoneTy = ArrayType::get(IRB.getInt8Ty(), RightRedzoneSize);
19301930
1931 StructType *NewTy = StructType::get(Ty, RightRedZoneTy, nullptr);
1932 Constant *NewInitializer =
1933 ConstantStruct::get(NewTy, G->getInitializer(),
1934 Constant::getNullValue(RightRedZoneTy), nullptr);
1931 StructType *NewTy = StructType::get(Ty, RightRedZoneTy);
1932 Constant *NewInitializer = ConstantStruct::get(
1933 NewTy, G->getInitializer(), Constant::getNullValue(RightRedZoneTy));
19351934
19361935 // Create a new global variable with enough space for a redzone.
19371936 GlobalValue::LinkageTypes Linkage = G->getLinkage();
20122011 ConstantExpr::getPointerCast(Name, IntptrTy),
20132012 ConstantExpr::getPointerCast(ModuleName, IntptrTy),
20142013 ConstantInt::get(IntptrTy, MD.IsDynInit), SourceLoc,
2015 ConstantExpr::getPointerCast(ODRIndicator, IntptrTy), nullptr);
2014 ConstantExpr::getPointerCast(ODRIndicator, IntptrTy));
20162015
20172016 if (ClInitializers && MD.IsDynInit) HasDynamicallyInitializedGlobals = true;
20182017
387387 ArgTypes.push_back(ShadowPtrTy);
388388 Type *RetType = T->getReturnType();
389389 if (!RetType->isVoidTy())
390 RetType = StructType::get(RetType, ShadowTy, (Type *)nullptr);
390 RetType = StructType::get(RetType, ShadowTy);
391391 return FunctionType::get(RetType, ArgTypes, T->isVarArg());
392392 }
393393
475475 GetArgTLS = ConstantExpr::getIntToPtr(
476476 ConstantInt::get(IntptrTy, uintptr_t(GetArgTLSPtr)),
477477 PointerType::getUnqual(
478 FunctionType::get(PointerType::getUnqual(ArgTLSTy),
479 (Type *)nullptr)));
478 FunctionType::get(PointerType::getUnqual(ArgTLSTy), (Type*)nullptr)));
480479 }
481480 if (GetRetvalTLSPtr) {
482481 RetvalTLS = nullptr;
483482 GetRetvalTLS = ConstantExpr::getIntToPtr(
484483 ConstantInt::get(IntptrTy, uintptr_t(GetRetvalTLSPtr)),
485484 PointerType::getUnqual(
486 FunctionType::get(PointerType::getUnqual(ShadowTy),
487 (Type *)nullptr)));
485 FunctionType::get(PointerType::getUnqual(ShadowTy), (Type*)nullptr)));
488486 }
489487
490488 ColdCallWeights = MDBuilder(*Ctx).createBranchWeights(1, 1000);
397397 // u64 *ArrayCounter;
398398 // };
399399 auto *StructInfoTy =
400 StructType::get(Int8PtrTy, Int32Ty, Int32Ty, Int32PtrTy, Int32PtrTy,
401 Int8PtrPtrTy, Int64PtrTy, Int64PtrTy, nullptr);
400 StructType::get(Int8PtrTy, Int32Ty, Int32Ty, Int32PtrTy, Int32PtrTy,
401 Int8PtrPtrTy, Int64PtrTy, Int64PtrTy);
402402 auto *StructInfoPtrTy = StructInfoTy->getPointerTo();
403403 // This structure should be kept consistent with the CacheFragInfo struct
404404 // in the runtime library.
407407 // u32 NumStructs;
408408 // StructInfo *Structs;
409409 // };
410 auto *CacheFragInfoTy =
411 StructType::get(Int8PtrTy, Int32Ty, StructInfoPtrTy, nullptr);
410 auto *CacheFragInfoTy = StructType::get(Int8PtrTy, Int32Ty, StructInfoPtrTy);
412411
413412 std::vector Vec = M.getIdentifiedStructTypes();
414413 unsigned NumStructs = 0;
456455 ArrayCounterIdx[0] = ConstantInt::get(Int32Ty, 0);
457456 ArrayCounterIdx[1] = ConstantInt::get(Int32Ty,
458457 getArrayCounterIdx(StructTy));
459 Initializers.push_back(
460 ConstantStruct::get(
461 StructInfoTy,
462 ConstantExpr::getPointerCast(StructCounterName, Int8PtrTy),
463 ConstantInt::get(Int32Ty,
464 DL.getStructLayout(StructTy)->getSizeInBytes()),
465 ConstantInt::get(Int32Ty, StructTy->getNumElements()),
466 Offset == nullptr ? ConstantPointerNull::get(Int32PtrTy) :
467 ConstantExpr::getPointerCast(Offset, Int32PtrTy),
468 Size == nullptr ? ConstantPointerNull::get(Int32PtrTy) :
469 ConstantExpr::getPointerCast(Size, Int32PtrTy),
470 TypeName == nullptr ? ConstantPointerNull::get(Int8PtrPtrTy) :
471 ConstantExpr::getPointerCast(TypeName, Int8PtrPtrTy),
472 ConstantExpr::getGetElementPtr(CounterArrayTy, Counters,
473 FieldCounterIdx),
474 ConstantExpr::getGetElementPtr(CounterArrayTy, Counters,
475 ArrayCounterIdx),
476 nullptr));
458 Initializers.push_back(ConstantStruct::get(
459 StructInfoTy,
460 ConstantExpr::getPointerCast(StructCounterName, Int8PtrTy),
461 ConstantInt::get(Int32Ty,
462 DL.getStructLayout(StructTy)->getSizeInBytes()),
463 ConstantInt::get(Int32Ty, StructTy->getNumElements()),
464 Offset == nullptr ? ConstantPointerNull::get(Int32PtrTy)
465 : ConstantExpr::getPointerCast(Offset, Int32PtrTy),
466 Size == nullptr ? ConstantPointerNull::get(Int32PtrTy)
467 : ConstantExpr::getPointerCast(Size, Int32PtrTy),
468 TypeName == nullptr
469 ? ConstantPointerNull::get(Int8PtrPtrTy)
470 : ConstantExpr::getPointerCast(TypeName, Int8PtrPtrTy),
471 ConstantExpr::getGetElementPtr(CounterArrayTy, Counters,
472 FieldCounterIdx),
473 ConstantExpr::getGetElementPtr(CounterArrayTy, Counters,
474 ArrayCounterIdx)));
477475 }
478476 // Structs.
479477 Constant *StructInfo;
490488
491489 auto *CacheFragInfoGV = new GlobalVariable(
492490 M, CacheFragInfoTy, true, GlobalVariable::InternalLinkage,
493 ConstantStruct::get(CacheFragInfoTy,
494 UnitName,
495 ConstantInt::get(Int32Ty, NumStructs),
496 StructInfo,
497 nullptr));
491 ConstantStruct::get(CacheFragInfoTy, UnitName,
492 ConstantInt::get(Int32Ty, NumStructs), StructInfo));
498493 return CacheFragInfoGV;
499494 }
500495
6666 // Create a cleanup block.
6767 LLVMContext &C = F.getContext();
6868 BasicBlock *CleanupBB = BasicBlock::Create(C, CleanupBBName, &F);
69 Type *ExnTy =
70 StructType::get(Type::getInt8PtrTy(C), Type::getInt32Ty(C), nullptr);
69 Type *ExnTy = StructType::get(Type::getInt8PtrTy(C), Type::getInt32Ty(C));
7170 if (!F.hasPersonalityFn()) {
7271 Constant *PersFn = getDefaultPersonalityFn(F.getParent());
7372 F.setPersonalityFn(PersFn);
3434 // Upgrade a 2-field global array type to the new 3-field format if needed.
3535 if (Data && OldEltTy->getNumElements() < 3)
3636 EltTy = StructType::get(IRB.getInt32Ty(), PointerType::getUnqual(FnTy),
37 IRB.getInt8PtrTy(), nullptr);
37 IRB.getInt8PtrTy());
3838 else
3939 EltTy = OldEltTy;
4040 if (Constant *Init = GVCtor->getInitializer()) {
4343 for (unsigned i = 0; i != n; ++i) {
4444 auto Ctor = cast(Init->getOperand(i));
4545 if (EltTy != OldEltTy)
46 Ctor = ConstantStruct::get(
47 EltTy, Ctor->getAggregateElement((unsigned)0),
48 Ctor->getAggregateElement(1),
49 Constant::getNullValue(IRB.getInt8PtrTy()), nullptr);
46 Ctor =
47 ConstantStruct::get(EltTy, Ctor->getAggregateElement((unsigned)0),
48 Ctor->getAggregateElement(1),
49 Constant::getNullValue(IRB.getInt8PtrTy()));
5050 CurrentCtors.push_back(Ctor);
5151 }
5252 }
5454 } else {
5555 // Use the new three-field struct if there isn't one already.
5656 EltTy = StructType::get(IRB.getInt32Ty(), PointerType::getUnqual(FnTy),
57 IRB.getInt8PtrTy(), nullptr);
57 IRB.getInt8PtrTy());
5858 }
5959
6060 // Build a 2 or 3 field global_ctor entry. We don't take a comdat key.
14491449 // x86_64 can't use {float, float} since that would be returned in both
14501450 // xmm0 and xmm1, which isn't what a real struct would do.
14511451 ResTy = T.getArch() == Triple::x86_64
1452 ? static_cast(VectorType::get(ArgTy, 2))
1453 : static_cast(StructType::get(ArgTy, ArgTy, nullptr));
1452 ? static_cast(VectorType::get(ArgTy, 2))
1453 : static_cast(StructType::get(ArgTy, ArgTy));
14541454 } else {
14551455 Name = "__sincospi_stret";
1456 ResTy = StructType::get(ArgTy, ArgTy, nullptr);
1456 ResTy = StructType::get(ArgTy, ArgTy);
14571457 }
14581458
14591459 Module *M = OrigCallee->getParent();
948948 Constant *NewV;
949949 if (IsOldCtorDtor) {
950950 auto *S = cast(V);
951 auto *E1 = mapValue(S->getOperand(0));
952 auto *E2 = mapValue(S->getOperand(1));
953 Value *Null = Constant::getNullValue(VoidPtrTy);
954 NewV =
955 ConstantStruct::get(cast(EltTy), E1, E2, Null, nullptr);
951 auto *E1 = cast(mapValue(S->getOperand(0)));
952 auto *E2 = cast(mapValue(S->getOperand(1)));
953 Constant *Null = Constant::getNullValue(VoidPtrTy);
954 NewV = ConstantStruct::get(cast(EltTy), E1, E2, Null);
956955 } else {
957956 NewV = cast_or_null(mapValue(V));
958957 }
231231 std::vector ArrayElts;
232232 Type *Int32Ty = Type::getInt32Ty(TorList[0].first->getContext());
233233
234 StructType *STy =
235 StructType::get(Int32Ty, TorList[0].first->getType(), nullptr);
234 StructType *STy = StructType::get(Int32Ty, TorList[0].first->getType());
236235 for (unsigned i = 0, e = TorList.size(); i != e; ++i) {
237236 Constant *Elts[] = {ConstantInt::get(Int32Ty, TorList[i].second),
238237 TorList[i].first};
100100 public:
101101 static StructType *get(LLVMContext &Context) {
102102 return StructType::get(
103 TypeBuilder[256], XCompile>::get(Context), nullptr);
103 TypeBuilder[256], XCompile>::get(Context));
104104 }
105105 };
106106
263263
264264 TEST(TypeBuilderTest, Extensions) {
265265 LLVMContext Context;
266 EXPECT_EQ(PointerType::getUnqual(
267 StructType::get(TypeBuilder::get(Context),
268 TypeBuilder::get(Context),
269 TypeBuilder::get(Context))),
270 (TypeBuilder::get(Context)));
266271 EXPECT_EQ(PointerType::getUnqual(StructType::get(
267 TypeBuilder::get(Context),
268 TypeBuilder::get(Context),
269 TypeBuilder::get(Context), (void *)nullptr)),
270 (TypeBuilder::get(Context)));
271 EXPECT_EQ(
272 PointerType::getUnqual(StructType::get(
273 TypeBuilder, false>::get(Context),
274 TypeBuilder *, false>::get(Context),
275 TypeBuilder *[], false>::get(Context), (void *)nullptr)),
276 (TypeBuilder::get(Context)));
277 EXPECT_EQ(
278 PointerType::getUnqual(StructType::get(
279 TypeBuilder, false>::get(Context),
280 TypeBuilder *, false>::get(Context),
281 TypeBuilder *[], false>::get(Context), (void *)nullptr)),
282 (TypeBuilder::get(Context)));
272 TypeBuilder, false>::get(Context),
273 TypeBuilder *, false>::get(Context),
274 TypeBuilder *[], false>::get(Context))),
275 (TypeBuilder::get(Context)));
276 EXPECT_EQ(PointerType::getUnqual(StructType::get(
277 TypeBuilder, false>::get(Context),
278 TypeBuilder *, false>::get(Context),
279 TypeBuilder *[], false>::get(Context))),
280 (TypeBuilder::get(Context)));
283281 }
284282
285283 } // anonymous namespace