[clang] 15a484b - [clang][ConstExprEmitter] handle IntegerLiterals
Nick Desaulniers via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 25 14:21:18 PDT 2023
Author: Nick Desaulniers
Date: 2023-07-25T14:12:50-07:00
New Revision: 15a484bf6990c5c3b759f5bbf99055612c20b924
URL: https://github.com/llvm/llvm-project/commit/15a484bf6990c5c3b759f5bbf99055612c20b924
DIFF: https://github.com/llvm/llvm-project/commit/15a484bf6990c5c3b759f5bbf99055612c20b924.diff
LOG: [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
Added:
Modified:
clang/lib/CodeGen/CGExprConstant.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index 353ee56839f37e..836561a0fb7325 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -1215,6 +1215,10 @@ class ConstExprEmitter :
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");
More information about the cfe-commits
mailing list