Skip to content

Commit

Permalink
[Clang] Rename getElementBitCast() -> withElementType() (NFC)
Browse files Browse the repository at this point in the history
This no longer creates a bitcast, just changes the element type
of the ConstantAddress.
  • Loading branch information
nikic committed Jun 14, 2023
1 parent 2f171b2 commit 0211a75
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions clang/lib/CodeGen/Address.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,8 @@ class ConstantAddress : public Address {
return llvm::cast<llvm::Constant>(Address::getPointer());
}

ConstantAddress getElementBitCast(llvm::Type *ElemTy) const {
llvm::Constant *BitCast = llvm::ConstantExpr::getBitCast(
getPointer(), ElemTy->getPointerTo(getAddressSpace()));
return ConstantAddress(BitCast, ElemTy, getAlignment());
ConstantAddress withElementType(llvm::Type *ElemTy) const {
return ConstantAddress(getPointer(), ElemTy, getAlignment());
}

static bool isaImpl(Address addr) {
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static void EmitDeclDestroy(CodeGenFunction &CGF, const VarDecl &D,
}
// Otherwise, the standard logic requires a helper function.
} else {
Addr = Addr.getElementBitCast(CGF.ConvertTypeForMem(Type));
Addr = Addr.withElementType(CGF.ConvertTypeForMem(Type));
Func = CodeGenFunction(CGM)
.generateDestroyHelper(Addr, Type, CGF.getDestroyer(DtorKind),
CGF.needsEHCleanup(DtorKind), &D);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1987,7 +1987,7 @@ static ConstantLValue emitConstantObjCStringLiteral(const StringLiteral *S,
QualType T,
CodeGenModule &CGM) {
auto C = CGM.getObjCRuntime().GenerateConstantString(S);
return C.getElementBitCast(CGM.getTypes().ConvertTypeForMem(T));
return C.withElementType(CGM.getTypes().ConvertTypeForMem(T));
}

ConstantLValue
Expand Down

0 comments on commit 0211a75

Please sign in to comment.