Skip to content

Commit 15a484b

Browse files
[clang][ConstExprEmitter] handle IntegerLiterals
Improves the ability of ConstExprEmitter to evaluate constants. Found by adding asserts to ConstantEmitter::tryEmitPrivate to find cases where ConstExprEmitter::Visit() fails to resolve (obvious) constants. Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D156154
1 parent 070358e commit 15a484b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

clang/lib/CodeGen/CGExprConstant.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,10 @@ class ConstExprEmitter :
12151215
return Visit(E->getSubExpr(), T);
12161216
}
12171217

1218+
llvm::Constant *VisitIntegerLiteral(IntegerLiteral *I, QualType T) {
1219+
return llvm::ConstantInt::get(CGM.getLLVMContext(), I->getValue());
1220+
}
1221+
12181222
llvm::Constant *EmitArrayInitialization(InitListExpr *ILE, QualType T) {
12191223
auto *CAT = CGM.getContext().getAsConstantArrayType(ILE->getType());
12201224
assert(CAT && "can't emit array init for non-constant-bound array");

0 commit comments

Comments
 (0)