Skip to content

Commit 5cc1287

Browse files
committed
[CGBuilder] Use getDataLayout() helpers (NFC)
1 parent bd5a034 commit 5cc1287

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

clang/lib/CodeGen/CGBuilder.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class CGBuilderTy : public CGBuilderBaseTy {
6262
template <bool IsInBounds>
6363
Address createConstGEP2_32(Address Addr, unsigned Idx0, unsigned Idx1,
6464
const llvm::Twine &Name) {
65-
const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
65+
const llvm::DataLayout &DL = BB->getDataLayout();
6666
llvm::GetElementPtrInst *GEP;
6767
if (IsInBounds)
6868
GEP = cast<llvm::GetElementPtrInst>(CreateConstInBoundsGEP2_32(
@@ -218,7 +218,7 @@ class CGBuilderTy : public CGBuilderBaseTy {
218218
Address CreateStructGEP(Address Addr, unsigned Index,
219219
const llvm::Twine &Name = "") {
220220
llvm::StructType *ElTy = cast<llvm::StructType>(Addr.getElementType());
221-
const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
221+
const llvm::DataLayout &DL = BB->getDataLayout();
222222
const llvm::StructLayout *Layout = DL.getStructLayout(ElTy);
223223
auto Offset = CharUnits::fromQuantity(Layout->getElementOffset(Index));
224224

@@ -240,7 +240,7 @@ class CGBuilderTy : public CGBuilderBaseTy {
240240
Address CreateConstArrayGEP(Address Addr, uint64_t Index,
241241
const llvm::Twine &Name = "") {
242242
llvm::ArrayType *ElTy = cast<llvm::ArrayType>(Addr.getElementType());
243-
const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
243+
const llvm::DataLayout &DL = BB->getDataLayout();
244244
CharUnits EltSize =
245245
CharUnits::fromQuantity(DL.getTypeAllocSize(ElTy->getElementType()));
246246

@@ -260,7 +260,7 @@ class CGBuilderTy : public CGBuilderBaseTy {
260260
Address CreateConstInBoundsGEP(Address Addr, uint64_t Index,
261261
const llvm::Twine &Name = "") {
262262
llvm::Type *ElTy = Addr.getElementType();
263-
const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
263+
const llvm::DataLayout &DL = BB->getDataLayout();
264264
CharUnits EltSize = CharUnits::fromQuantity(DL.getTypeAllocSize(ElTy));
265265

266266
return Address(
@@ -277,7 +277,7 @@ class CGBuilderTy : public CGBuilderBaseTy {
277277
Address CreateConstGEP(Address Addr, uint64_t Index,
278278
const llvm::Twine &Name = "") {
279279
llvm::Type *ElTy = Addr.getElementType();
280-
const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
280+
const llvm::DataLayout &DL = BB->getDataLayout();
281281
CharUnits EltSize = CharUnits::fromQuantity(DL.getTypeAllocSize(ElTy));
282282

283283
return Address(CreateGEP(ElTy, Addr.getBasePointer(), getSize(Index), Name),
@@ -290,7 +290,7 @@ class CGBuilderTy : public CGBuilderBaseTy {
290290
using CGBuilderBaseTy::CreateGEP;
291291
Address CreateGEP(CodeGenFunction &CGF, Address Addr, llvm::Value *Index,
292292
const llvm::Twine &Name = "") {
293-
const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
293+
const llvm::DataLayout &DL = BB->getDataLayout();
294294
CharUnits EltSize =
295295
CharUnits::fromQuantity(DL.getTypeAllocSize(Addr.getElementType()));
296296

@@ -412,7 +412,7 @@ class CGBuilderTy : public CGBuilderBaseTy {
412412
unsigned FieldIndex,
413413
llvm::MDNode *DbgInfo) {
414414
llvm::StructType *ElTy = cast<llvm::StructType>(Addr.getElementType());
415-
const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
415+
const llvm::DataLayout &DL = BB->getDataLayout();
416416
const llvm::StructLayout *Layout = DL.getStructLayout(ElTy);
417417
auto Offset = CharUnits::fromQuantity(Layout->getElementOffset(Index));
418418

0 commit comments

Comments
 (0)