aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Context.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-07-19 07:18:51 +0200
committerGitHub <noreply@github.com>2025-07-19 07:18:51 +0200
commitef49ed4829bc1b111e31a08d70b0ccae66427ebf (patch)
tree7773c35177b9813dc562feda358811cb63055610 /clang/lib/AST/ByteCode/Context.cpp
parenta5481e7d5af07161b5d135100cb8754ae614accf (diff)
downloadllvm-ef49ed4829bc1b111e31a08d70b0ccae66427ebf.zip
llvm-ef49ed4829bc1b111e31a08d70b0ccae66427ebf.tar.gz
llvm-ef49ed4829bc1b111e31a08d70b0ccae66427ebf.tar.bz2
[clang][bytecode] Use bytecode interpreter in isPotentialConstantExprU… (#149462)
…nevaluated Fake a function call to the given function and evaluate the given expression as if it was part of that function call. Fixes #149383
Diffstat (limited to 'clang/lib/AST/ByteCode/Context.cpp')
-rw-r--r--clang/lib/AST/ByteCode/Context.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/AST/ByteCode/Context.cpp b/clang/lib/AST/ByteCode/Context.cpp
index a629ff9..ead6e4a 100644
--- a/clang/lib/AST/ByteCode/Context.cpp
+++ b/clang/lib/AST/ByteCode/Context.cpp
@@ -52,6 +52,19 @@ bool Context::isPotentialConstantExpr(State &Parent, const FunctionDecl *FD) {
return Func->isValid();
}
+void Context::isPotentialConstantExprUnevaluated(State &Parent, const Expr *E,
+ const FunctionDecl *FD) {
+ assert(Stk.empty());
+ ++EvalID;
+ size_t StackSizeBefore = Stk.size();
+ Compiler<EvalEmitter> C(*this, *P, Parent, Stk);
+
+ if (!C.interpretCall(FD, E)) {
+ C.cleanup();
+ Stk.clearTo(StackSizeBefore);
+ }
+}
+
bool Context::evaluateAsRValue(State &Parent, const Expr *E, APValue &Result) {
++EvalID;
bool Recursing = !Stk.empty();