Make ConstantDataArray::get() constructors a single templated one.
Details
Diff Detail
- Repository
- rL LLVM
- Build Status
Buildable 16212 Build 16212: arc lint + arc unit
Event Timeline
include/llvm/IR/Constants.h | ||
---|---|---|
706 | Would it be good to create Type::getTyByScalar: class Type { template <typename ScalarType> Type* getTyByScalar(LLVMContext*) { switch (sizeof(ScalarType)) { ... } } Also, it'd be better to expand getTyByScalar to pointer and all sorts of other crazy types, but Scalar would be a good start. Then ConstantDataArray::get will be like return ArrayType::get(Type::getTyByScalar<ElementTy>(Context), Elts.size()); |
Address comments.
include/llvm/IR/Constants.h | ||
---|---|---|
701 | It made sense to add * CHAR_BIT when passing no of bits to getIntNTy. |
I'm not sure of the rules here, but perhaps this needs to be sizeof(ElementTy) * CHAR_BIT / 8 to be technically correct?