Timm Bäder
1ecaa617e7
[clang][Interp] Handle enums
...
Handle DeclRefExprs of enum types. They are otherwise handled like
integers.
Differential Revision: https://reviews.llvm.org/D134020
2022-09-30 08:18:14 +02:00
Timm Bäder
f444a7cc16
Revert "[clang][Interp] Handle enums"
...
This reverts commit c090295916
.
One of the test cases fails. Revert this until I know a way to make it
work reliably.
2022-09-29 13:45:52 +02:00
Timm Bäder
971c1b9647
[clang][Interp][NFC] Remove unused prototypes
2022-09-29 12:50:58 +02:00
Timm Bäder
b721558a91
[clang][Interp][NFC] Make EvalEmitter::isActive() const
2022-09-29 12:50:57 +02:00
Timm Bäder
62bf6acae6
[clang][Interp][NFC] Unifty ReadArg() impl in Disasm.cpp
...
We can use another if constexpr here to make this shorter and easier to
understand.
2022-09-29 12:50:57 +02:00
Timm Bäder
f55c4b4ee3
[clang][Interp] Print Function address in dump()
...
It's used in the bytecode dump of the function itself, so useful to
identify which function is being called.
2022-09-29 12:50:57 +02:00
Timm Bäder
9837a3bd4b
[clang][Interp][NFC] Remove unused opcode argument types
2022-09-29 12:50:57 +02:00
Timm Bäder
7c65d57af0
[clang][Interp][NFC] Unify the two ReadArg() implementations
...
Just use a constexpr if here instead of two different implementations.
[#
2022-09-29 12:50:57 +02:00
Timm Bäder
e8ad1339d4
[clang][Interp][NFC] Remove unused function
2022-09-29 12:50:57 +02:00
Timm Bäder
f927b71376
[clang][Interp] Specify Boolean conversion operartors as (u)int32
...
Follow up to https://reviews.llvm.org/D133934
2022-09-29 12:50:57 +02:00
Timm Bäder
84f1df8aac
[clang][Interp] Properly destruct allocated Records
...
We are otherwise leaking some memory the records might allocate
themselves.
Differential Revision: https://reviews.llvm.org/D134054
2022-09-29 12:50:56 +02:00
Timm Bäder
d5360b932e
[clang][Interp][NFC] Make classes final that can be final
2022-09-29 12:50:56 +02:00
Timm Bäder
8f5b061254
[clang][Interp][NFC] Make some Record methods const
2022-09-29 12:50:56 +02:00
Timm Bäder
eadd505b0c
[clang][Interp][NFC] Limit includes to neccessary ones
2022-09-29 12:50:56 +02:00
Timm Bäder
202ff42f89
[clang][Interp] Rename a local variable to be more specific
...
It's called BaseSize in the Record class as well, so call it BaseSize
when creating the Record.
2022-09-29 12:50:56 +02:00
Timm Bäder
c090295916
[clang][Interp] Handle enums
...
Handle DeclRefExprs of enum types. They are otherwise handled like
integers.
Differential Revision: https://reviews.llvm.org/D134020
2022-09-29 12:50:56 +02:00
Timm Bäder
df1cc801da
[clang][Interp] Record item types in InterpStack
...
The type information is lost when pushing things on the stack. When
later pop()ing items of the wrong type, we can instead simply get
garbage values and those problems are hard to find. Add another stack to
record the type of item we pushed and use that for debugging.
Differential Revision: https://reviews.llvm.org/D133941
2022-09-29 12:50:55 +02:00
Timm Bäder
7c4cad4330
[clang][Interp][NFC] Make a few InterpStack functions const
2022-09-29 12:50:55 +02:00
Timm Bäder
ee2e414d66
[clang][Interp] Handle sizeof()
...
Implement visiting UnaryExprOrTypeTraitExprs to handle sizeof()
expressions.
Differential Revision: https://reviews.llvm.org/D133934
2022-09-29 12:50:55 +02:00
Timm Bäder
1c35f3b93a
[clang][Interp][NFC] Unify emit() implementations
...
Instead of two overloads, use a if constexpr to differentiate between
pointer and non-pointer parameters
2022-09-29 12:50:55 +02:00
Timm Bäder
1d31549e93
[clang][Interp][NFC] Forward-declare Pointer in InterpFrame.h
...
We don't need the full include here.
2022-09-29 12:50:55 +02:00
Timm Bäder
18a5fc52b2
[clang][Interp][NFC] Remove an unnecessary <vector> include.
2022-09-29 12:50:55 +02:00
Timm Bäder
da62ed6ceb
[clang][Interp] Pass initializer when creating globals
...
This is dead code right now but will be used for implementing array
fillers, where we need some information from the initializer when
allocaing the Descriptors.
Differential Revision: https://reviews.llvm.org/D133856
2022-09-29 12:50:54 +02:00
Timm Bäder
53d8687a13
[clang][Interp][NFC] Use constexpr if in OffsetHelper
...
Add is a template parameter, so we can use constexpr if here.
2022-09-13 10:41:34 +02:00
Timm Bäder
b02f6890f5
[clang][Interp][NFC] InterpFrame::getParam can be const
...
Make stackRef() const as well and use that.
2022-09-13 10:41:28 +02:00
Timm Bäder
5d2451468c
[clang][Interp][NFC] InterpFrame::getLocal() can be const
...
Make localRef() const and use that.
2022-09-13 10:41:24 +02:00
Timm Bäder
f756ddba17
[clang][Interp][NFC] InterpFrame: localBlock() can be const
2022-09-13 10:41:18 +02:00
Timm Bäder
9b087a70e6
[clang][Interp][NFC] Forward-declare Pointer in PrimType header
...
No need to include the full Pointer.h here.
2022-09-13 10:40:52 +02:00
Timm Bäder
bf3efa8b16
[clang][Interp] Handle DeclRefExpr of reference types
...
References are implemented through pointers, so we need a second deref
when encountering a DeclRefExpr of a reference type.
Differential Revision: https://reviews.llvm.org/D132997
2022-09-13 10:40:51 +02:00
Fangrui Song
2f23dc9127
[AST/Interp] Fix left shift overflow bug in D64146
...
Noticed by Dmitri Gribenko
2022-09-08 13:49:07 -07:00
Fangrui Song
49c289879c
[AST/Interp] Fix latent unitialized use of memory bug in D64146
...
Exposed by D132727: clang/test/AST/Interp/arrays.cpp fails with --config=msan
2022-09-08 13:39:30 -07:00
Timm Bäder
86271798e5
[clang][Interp] Only initialize initmaps for primitive arrays
...
As the comment states, this code should only run for primitive arrays.
This should fix the memory sanitize builds.
2022-09-08 10:03:06 +02:00
Timm Bäder
651f4ce7b1
[clang][Interp][NFC] Use constexpr if when possible in Integral.h
2022-09-08 07:31:08 +02:00
Timm Bäder
0da7e409e0
[clang][Interp][NFC] Context::classify() can be const
2022-09-08 07:31:08 +02:00
Timm Bäder
3a7d476087
[clang][Interp] Implement array initializers and subscript expressions
...
Differential Revision: https://reviews.llvm.org/D132727
2022-09-08 07:31:07 +02:00
Timm Bäder
aa7c5c9c4e
[clang][Interp] Handle missing local initializers better
...
This is illegal in a constexpr context. We can already figure that out,
but we'd still run into an assertion later on when trying to visit the
missing initializer or run the invalid function.
Differential Revision: https://reviews.llvm.org/D132832
2022-09-08 07:31:07 +02:00
Timm Bäder
5c4dbff0b6
[clang][Interp] Handle SubstNonTypeTemplateParmExprs
...
Differential Revision: https://reviews.llvm.org/D132831
2022-09-08 07:31:07 +02:00
Timm Bäder
4d700ffe67
[clang][Interp] Implement ImplicitValueInitExprs
...
Take the existing Zero opcode and emit it.
Differential Revision: https://reviews.llvm.org/D132829
2022-09-08 07:31:07 +02:00
Timm Bäder
95e6a407d9
[clang][Interp] Implement IntegralToBoolean casts
...
Redo how we do IntegralCasts and implement IntegralToBoolean casts using
the already existing cast op.
Differential Revision: https://reviews.llvm.org/D132739
2022-09-08 07:31:07 +02:00
Timm Bäder
8e41e6a4ea
[clang][Interp] Implement function calls
...
Add Call() and CallVoid() ops and use them to call functions. Only
FunctionDecls are supported for now.
Differential Revision: https://reviews.llvm.org/D132286
2022-09-08 07:31:07 +02:00
Timm Bäder
fdfc0dfa8e
[clang][Interp] Implement pointer (de)ref operators
...
Implement pointer references, dereferences and assignments.
Differential Revision: https://reviews.llvm.org/D132111
2022-08-25 14:20:32 +02:00
Simon Pilgrim
e41dd02052
Fix MSVC "not all control paths return a value" warning
2022-08-19 17:37:37 +01:00
Timm Bäder
7614785e1d
[clang][Interp] Rename Integral::T to Integral::ReprT
...
Just 'T' is a bit generic and causes confusion.
2022-08-19 16:14:37 +02:00
Timm Bäder
80bbc05436
[clang][Interp] Implement inv and neg unary operations
...
Implement negating and inverting values. Also implement
IntegralToBoolean casts so the operations are easier to test.
Differential Revision: https://reviews.llvm.org/D132098
2022-08-19 16:05:00 +02:00
Timm Bäder
a2a5470fc2
[clang][Interp] Implement boolean and nullptr literals
...
Handle CXX bool literals as well as nullptr literals and add a few tests
for each.
Differential Revision: https://reviews.llvm.org/D131942
2022-08-18 07:11:48 +02:00
Sunho Kim
134363208b
[clang] Fix gcc-6 compilation error. (NFC)
...
Fix https://github.com/llvm/llvm-project/issues/55626 .
Differential Revision: https://reviews.llvm.org/D129049
2022-07-04 05:33:05 +09:00
Kazu Hirata
452db157c9
[clang] Don't use Optional::hasValue (NFC)
2022-06-20 10:51:34 -07:00
Kazu Hirata
4969a6924d
Use llvm::less_first (NFC)
2022-06-04 21:23:18 -07:00
Owen Pan
7cd441ff53
[clang][NFC] Wrap TYPE_SWITCH in "do while (0)" in the interpreter
...
Wraps the expansions of TYPE_SWITCH and COMPOSITE_TYPE_SWITCH in
the constexpr interpreter with "do { ... } while (0)" so that these
macros can be used like this:
if (llvm::Optional<PrimType> T = Ctx.classify(FieldTy))
TYPE_SWITCH(*T, Ok &= ReturnValue<T>(FP.deref<T>(), Value));
else
Ok &= Composite(FieldTy, FP, Value);
This bug was found while testing D116316. See also review comment:
https://reviews.llvm.org/D64146?id=208520#inline-584131
Also cleaned up the macro definitions by removing the superfluous
do-while statements and removed the unused INT_TPYE_SWITCH macro.
Differential Revision: https://reviews.llvm.org/D117301
2022-01-24 09:05:27 -08:00
Kazu Hirata
17d4bd3d78
[clang] Fix bugprone argument comments (NFC)
...
Identified with bugprone-argument-comment.
2022-01-09 00:19:49 -08:00