diff options
author | Nick Desaulniers <ndesaulniers@google.com> | 2023-07-25 14:03:20 -0700 |
---|---|---|
committer | Nick Desaulniers <ndesaulniers@google.com> | 2023-07-25 14:12:50 -0700 |
commit | 15a484bf6990c5c3b759f5bbf99055612c20b924 (patch) | |
tree | 3fd39a4316b7f0a42015c833dbb1b3362b59bd29 /clang/lib/CodeGen/CGExprConstant.cpp | |
parent | 070358ec92350c13b0b6c60fbb03bf35a7a00251 (diff) | |
download | llvm-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.cpp | 4 |
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"); |