aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGExprConstant.cpp
diff options
context:
space:
mode:
authorNick Desaulniers <ndesaulniers@google.com>2023-07-25 14:03:20 -0700
committerNick Desaulniers <ndesaulniers@google.com>2023-07-25 14:12:50 -0700
commit15a484bf6990c5c3b759f5bbf99055612c20b924 (patch)
tree3fd39a4316b7f0a42015c833dbb1b3362b59bd29 /clang/lib/CodeGen/CGExprConstant.cpp
parent070358ec92350c13b0b6c60fbb03bf35a7a00251 (diff)
downloadllvm-15a484bf6990c5c3b759f5bbf99055612c20b924.zip
llvm-15a484bf6990c5c3b759f5bbf99055612c20b924.tar.gz
llvm-15a484bf6990c5c3b759f5bbf99055612c20b924.tar.bz2
[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
Diffstat (limited to 'clang/lib/CodeGen/CGExprConstant.cpp')
-rw-r--r--clang/lib/CodeGen/CGExprConstant.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index 353ee56..836561a 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -1215,6 +1215,10 @@ public:
return Visit(E->getSubExpr(), T);
}
+ llvm::Constant *VisitIntegerLiteral(IntegerLiteral *I, QualType T) {
+ return llvm::ConstantInt::get(CGM.getLLVMContext(), I->getValue());
+ }
+
llvm::Constant *EmitArrayInitialization(InitListExpr *ILE, QualType T) {
auto *CAT = CGM.getContext().getAsConstantArrayType(ILE->getType());
assert(CAT && "can't emit array init for non-constant-bound array");