Skip to content

Commit 6fad712

Browse files
committed
[clang][Interp][NFC] Remove unused parameter from emitConst()
1 parent e83bea4 commit 6fad712

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,8 @@ bool ByteCodeExprGen<Emitter>::VisitIntegerLiteral(const IntegerLiteral *LE) {
145145
if (DiscardResult)
146146
return true;
147147

148-
auto Val = LE->getValue();
149-
QualType LitTy = LE->getType();
150-
if (Optional<PrimType> T = classify(LitTy))
151-
return emitConst(*T, getIntWidth(LitTy), LE->getValue(), LE);
148+
if (Optional<PrimType> T = classify(LE->getType()))
149+
return emitConst(*T, LE->getValue(), LE);
152150
return this->bail(LE);
153151
}
154152

@@ -345,7 +343,7 @@ bool ByteCodeExprGen<Emitter>::VisitArrayInitIndexExpr(
345343
return false;
346344
QualType IndexType = E->getType();
347345
APInt Value(getIntWidth(IndexType), *ArrayIndex);
348-
return this->emitConst(classifyPrim(IndexType), 0, Value, E);
346+
return this->emitConst(classifyPrim(IndexType), Value, E);
349347
}
350348

351349
template <class Emitter>
@@ -569,8 +567,8 @@ bool ByteCodeExprGen<Emitter>::dereferenceVar(
569567
}
570568

571569
template <class Emitter>
572-
bool ByteCodeExprGen<Emitter>::emitConst(PrimType T, unsigned NumBits,
573-
const APInt &Value, const Expr *E) {
570+
bool ByteCodeExprGen<Emitter>::emitConst(PrimType T, const APInt &Value,
571+
const Expr *E) {
574572
switch (T) {
575573
case PT_Sint8:
576574
return this->emitConstSint8(Value.getSExtValue(), E);
@@ -1092,8 +1090,7 @@ bool ByteCodeExprGen<Emitter>::VisitDeclRefExpr(const DeclRefExpr *E) {
10921090
} else if (const auto *ECD = dyn_cast<EnumConstantDecl>(Decl)) {
10931091
PrimType T = *classify(ECD->getType());
10941092

1095-
return this->emitConst(T, getIntWidth(ECD->getType()), ECD->getInitVal(),
1096-
E);
1093+
return this->emitConst(T, ECD->getInitVal(), E);
10971094
}
10981095

10991096
// References are implemented using pointers, so when we get here,

clang/lib/AST/Interp/ByteCodeExprGen.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,13 @@ class ByteCodeExprGen : public ConstStmtVisitor<ByteCodeExprGen<Emitter>, bool>,
232232
llvm::function_ref<bool(PrimType)> Indirect);
233233

234234
/// Emits an APInt constant.
235-
bool emitConst(PrimType T, unsigned NumBits, const llvm::APInt &Value,
236-
const Expr *E);
235+
bool emitConst(PrimType T, const llvm::APInt &Value, const Expr *E);
237236

238237
/// Emits an integer constant.
239238
template <typename T> bool emitConst(const Expr *E, T Value) {
240239
QualType Ty = E->getType();
241-
unsigned NumBits = getIntWidth(Ty);
242-
APInt WrappedValue(NumBits, Value, std::is_signed<T>::value);
243-
return emitConst(*Ctx.classify(Ty), NumBits, WrappedValue, E);
240+
APInt WrappedValue(getIntWidth(Ty), Value, std::is_signed<T>::value);
241+
return emitConst(*Ctx.classify(Ty), WrappedValue, E);
244242
}
245243

246244
/// Returns the index of a global.

0 commit comments

Comments
 (0)