We will use this opcode for conditionally executed statements that are
invalid in a constant expression.
Differential Revision: https://reviews.llvm.org/D150364
First, we need to handle void types in visitExpr, so we don't run into
an assertion there when we try to pop a return value from the stack
that isn't there.
Secondly, we need to handle it when visiting comma expressions so we
don't do the same thing there.
Differential Revision: https://reviews.llvm.org/D148925
Our comparison opcodes always produce a Boolean value and push it on the
stack. However, the result of such a comparison in C is int, so the
later code expects an integer value on the stack.
Work around this problem by casting the boolean value to int in those
cases. This is not ideal for C however. The comparison is usually
wrapped in a IntegerToBool cast anyway.
Differential Revision: https://reviews.llvm.org/D149645
Our comparison opcodes always produce a Boolean value and push it on the
stack. However, the result of such a comparison in C is int, so the
later code expects an integer value on the stack.
Work around this problem by casting the boolean value to int in those
cases. This is not ideal for C however. The comparison is usually
wrapped in a IntegerToBool cast anyway.
Differential Revision: https://reviews.llvm.org/D149645
We might classify different clang types to the same interp types, so
skip the cast in that case.
No test attached since this is already exercised a few times in the
existing tests.
Our Zero opcode only exists for integer types. Use
visitZeroInitializer() here as well so it works for floats and pointers.
Differential Revision: https://reviews.llvm.org/D149059
The given expression is not necessarily usable to obtain a type for,
so we can't use it to get the floating point semantics. Pass a QualType
instead, which we can use--and classify() that here.
just because we're being told to evaluate it twice. This sometimes
happens when a variable is evaluated again during codegen.
Differential Revision: https://reviews.llvm.org/D147535
Make it clearer that we only need to check for variables and parameters
if we don't have the easy case. Also only do the IsReference check if
necessary.
For the given test case, we were trying to initialize a member of C,
which doesn't have any. Get the proper base pointer instead and
initialize the members there.
Differential Revision: https://reviews.llvm.org/D143466
We can't just use VisitCallExpr() here, as that doesn't handle CallExpr
subclasses such as CXXMemberCallExpr.
Differential Revision: https://reviews.llvm.org/D141772
Since we now handle functions without a body as well, we can't just use
getHasBody() anymore. Funtions that haven't been defined yet are those
that don't have a body *and* aren't valid.
Also, just pass the information about whether the Function has a body or
not along from the FunctionDecl.
Differential Revision: https://reviews.llvm.org/D141591
We usually access array elements in the same pattern, which uses
narrow(). Add an extra opcode for this. This saves us quite some
instructions and makes the bytecode easier to read.
Differential Revision: https://reviews.llvm.org/D140805