10 Commits

Author SHA1 Message Date
Timm Bäder
68516bfd2f [clang][Interp] Lambda This captures can be non-pointers
If they are captured by value.
2024-03-01 18:06:18 +01:00
Timm Bäder
d61864f813 [clang][Interp] Don't create Records for incomplete decls
We would previously create the Record instance with 0 fields,
which is incorrect. We later see it again with 1 field.

Fixes #82203
2024-02-19 09:23:53 +01:00
Timm Bäder
fc38182eab [clang][Interp][NFC] Convert test case to verify=expected,ref style 2024-02-16 18:59:07 +01:00
Timm Bäder
d228191c8b [clang][Interp] Create global variables for TemplateParamObjectDecls 2024-02-16 16:07:42 +01:00
Timm Bäder
cd183428a9 [clang][Interp] Fix handling of generic lambdas
When compiling their static invoker, we need to get the
right specialization.
2024-02-08 16:03:42 +01:00
Timm Bäder
57147bb253 [clang][Interp] Support LambdaThisCaptures
Differential Revision: https://reviews.llvm.org/D154262
2023-10-05 09:46:15 +02:00
Timm Bäder
6dfe55569d [clang][Interp] Rework initializers
Before this patch, we had visitRecordInitializer() and
visitArrayInitializer(), which were different from the regular visit()
in that they expected a pointer on the top of the stack, which they
initialized. For example, visitArrayInitializer handled InitListExprs by
looping over the members and initializing the elements of that pointer.

However, this had a few corner cases and problems. For example, in
visitLambdaExpr() (a lambda is always of record type), it was not clear
whether we should always create a new local variable to save the lambda
to, or not. This is why https://reviews.llvm.org/D153616 changed
things around.

This patch changes the visiting functions to:

 - visit(): Always leaves a new value on the stack. If the expression
   can be mapped to a primitive type, it's just visited and the value is
   put on the stack. If it's of composite type, this function will
   create a local variable for the expression value and call
   visitInitializer(). The pointer to the local variable will stay on
   the stack.

 - visitInitializer(): Visits the given expression, assuming there is a
   pointer on top of the stack that will be initialized by it.

 - discard(): Visit the expression for side-effects, but don't leave a
   value on the stack.

It also adds an additional Initializing flag to differentiate between the initializing and non-initializing case.

Differential Revision: https://reviews.llvm.org/D156027
2023-08-20 13:33:08 +02:00
Timm Bäder
6d2e141e5c [clang][Interp] Handle lambda static invokers
Differential Revision: https://reviews.llvm.org/D150111
2023-07-26 08:42:16 +02:00
Takuya Shimizu
f6be96aa4e [clang][ExprConstant] Fix display of syntactically-invalid note for member function calls
This patch makes the display of member function calls more true to the user-written code by making use of the syntactical structure of the function calls.
This patch also changes the display of conventional value-based printing from arrow operator to dot operator.
This avoids the syntactical invalidness in notes previously caused by the display of & operator
(lack of parentheses and reference of rvalue)

Fixes https://github.com/llvm/llvm-project/issues/57081

Reviewed By: cjdb
Differential Revision: https://reviews.llvm.org/D151720
2023-06-28 00:19:46 +09:00
Timm Bäder
461f91b1e4 [clang][Interp] Handle LambdaExprs
Differential Revision: https://reviews.llvm.org/D146030
2023-06-16 10:05:33 +02:00