aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Interpreter/InterpreterTest.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-08-20[clang-repl] Fix InstantiateTemplate & Value test while building against ↵Anutosh Bhat1-16/+0
emscripten (#154513) Building with assertions flag (-sAssertions=2) gives me these ``` [ RUN ] InterpreterTest.InstantiateTemplate Aborted(Assertion failed: undefined symbol '__clang_Interpreter_SetValueWithAlloc'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Error in loading dynamic library incr_module_3.wasm: RuntimeError: Aborted(Assertion failed: undefined symbol '__clang_Interpreter_SetValueWithAlloc'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Could not load dynamic lib: incr_module_3.wasm RuntimeError: Aborted(Assertion failed: undefined symbol '__clang_Interpreter_SetValueWithAlloc'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) [ RUN ] InterpreterTest.InstantiateTemplate Aborted(Assertion failed: undefined symbol '__clang_Interpreter_SetValueNoAlloc'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Error in loading dynamic library incr_module_3.wasm: RuntimeError: Aborted(Assertion failed: undefined symbol '__clang_Interpreter_SetValueNoAlloc'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Could not load dynamic lib: incr_module_3.wasm RuntimeError: Aborted(Assertion failed: undefined symbol '__clang_Interpreter_SetValueNoAlloc'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) [ RUN ] InterpreterTest.InstantiateTemplate Aborted(Assertion failed: undefined symbol '_ZnwmPv26__clang_Interpreter_NewTag'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Error in loading dynamic library incr_module_23.wasm: RuntimeError: Aborted(Assertion failed: undefined symbol '_ZnwmPv26__clang_Interpreter_NewTag'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Could not load dynamic lib: incr_module_23.wasm RuntimeError: Aborted(Assertion failed: undefined symbol '_ZnwmPv26__clang_Interpreter_NewTag'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) [ RUN ] InterpreterTest.Value Aborted(Assertion failed: undefined symbol '_Z9getGlobalv'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Error in loading dynamic library incr_module_36.wasm: RuntimeError: Aborted(Assertion failed: undefined symbol '_Z9getGlobalv'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Could not load dynamic lib: incr_module_36.wasm [ RUN ] InterpreterTest.Value Aborted(Assertion failed: undefined symbol '_Z9getGlobalv'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Error in loading dynamic library incr_module_36.wasm: RuntimeError: Aborted(Assertion failed: undefined symbol '_Z9setGlobali'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Could not load dynamic lib: incr_module_36.wasm ``` **So we have some symbols missing here that are needed by the side modules being created here.** First 2 are needed by both tests Last 3 are needed for these lines accordingly in the Value test. https://github.com/llvm/llvm-project/blob/dc23869f98452ca2c4086f12bb431a8d6fdb8169/clang/unittests/Interpreter/InterpreterTest.cpp#L355 https://github.com/llvm/llvm-project/blob/dc23869f98452ca2c4086f12bb431a8d6fdb8169/clang/unittests/Interpreter/InterpreterTest.cpp#L364 https://github.com/llvm/llvm-project/blob/dc23869f98452ca2c4086f12bb431a8d6fdb8169/clang/unittests/Interpreter/InterpreterTest.cpp#L365 Everything should work as expected after this ``` [----------] 9 tests from InterpreterTest [ RUN ] InterpreterTest.Sanity [ OK ] InterpreterTest.Sanity (18 ms) [ RUN ] InterpreterTest.IncrementalInputTopLevelDecls [ OK ] InterpreterTest.IncrementalInputTopLevelDecls (45 ms) [ RUN ] InterpreterTest.Errors [ OK ] InterpreterTest.Errors (29 ms) [ RUN ] InterpreterTest.DeclsAndStatements [ OK ] InterpreterTest.DeclsAndStatements (34 ms) [ RUN ] InterpreterTest.UndoCommand /Users/anutosh491/work/llvm-project/clang/unittests/Interpreter/InterpreterTest.cpp:156: Skipped Test fails for Emscipten builds [ SKIPPED ] InterpreterTest.UndoCommand (0 ms) [ RUN ] InterpreterTest.FindMangledNameSymbol [ OK ] InterpreterTest.FindMangledNameSymbol (85 ms) [ RUN ] InterpreterTest.InstantiateTemplate [ OK ] InterpreterTest.InstantiateTemplate (127 ms) [ RUN ] InterpreterTest.Value [ OK ] InterpreterTest.Value (608 ms) [ RUN ] InterpreterTest.TranslationUnit_CanonicalDecl [ OK ] InterpreterTest.TranslationUnit_CanonicalDecl (64 ms) [----------] 9 tests from InterpreterTest (1014 ms total) ``` This is similar to how we need to take care of some symbols while building side modules during running cppinterop's test suite !
2025-08-14Enable running ClangReplInterpreterTests in an Emscripten environment (#150977)mcbarton1-0/+24
@vgvassilev @anutosh491 This is what it took for me to enable running ClangReplInterpreterTests in an Emscripten environment. When I ran this patch for llvm 20 we could run InterpreterTest.InstantiateTemplate , but now it crashes gtest when running in node. Let me know what you think.
2025-08-12Revert "[clang-repl] Enable extending `launchExecutor` (#152562)" (#153180)Abhinav Kumar1-11/+0
Reverts #152562. Seems to be causing test failures on Solaris bot. Co-authored-by: kr-2003 <kumar.kr.abhinav@gmail.com>
2025-08-08[clang-repl] Enable extending `launchExecutor` (#152562)Abhinav Kumar1-0/+11
This patch introduces the ability to customize the fork process with an external lambda function. This is useful for downstream clients where they want to do stream redirection.
2025-07-23[clang-repl] Improve error message on failed undos (#149396)Aaron Danen1-2/+2
Updated error message logic for undo function. Throws different errors for the case of there being nothing to undo, and for the case of requesting more undos than there are operations to undo. Fixes https://github.com/llvm/llvm-project/issues/143668
2025-07-20[clang-repl] Another try on system-z.Vassil Vassilev1-3/+0
This patch should make msan happy as it found a real bug where we always try to read an unsigned long long without respecting the underlying enum type. Another follow-up on llvm/llvm-project#102858
2025-07-19[clang-repl] Mark asan and systemz as unsupported for now.Vassil Vassilev1-0/+5
While waiting for the bot owners it seems that this is not a major issue due to the big endianness of the systemz platform. Instead it looks like we are not modelling something well for enum types. Probably `va_arg` has a bug for that platform or similar. The asan failure seems to be a crash in asan and maybe related to the issues we've mentioned in llvm/llvm-project#102858. This patch should appease the bots that were broken by llvm/llvm-project#148701
2025-07-19[clang-repl] Lay the basic infrastructure for pretty printing of types (#148701)Vassil Vassilev1-0/+20
The idea is to store a type-value pair in clang::Value which is updated by the interpreter runtime. The class copies builtin types and boxes non-builtin types to provide some lifetime control. The patch enables default printers for C and C++ using a very minimalistic approach. We handle enums, arrays and user types. Once we land this we can focus on enabling user-defined pretty-printers which take control over printing of types The work started as part of https://reviews.llvm.org/D146809, then we created a giant in https://github.com/llvm/llvm-project/pull/84769
2025-05-22Reapply "[clang] Remove intrusive reference count from `DiagnosticOptions` ↵Jan Svoboda1-6/+9
(#139584)" This reverts commit e2a885537f11f8d9ced1c80c2c90069ab5adeb1d. Build failures were fixed right away and reverting the original commit without the fixes breaks the build again.
2025-05-22Revert "[clang] Remove intrusive reference count from `DiagnosticOptions` ↵Kazu Hirata1-9/+6
(#139584)" This reverts commit 9e306ad4600c4d3392c194a8be88919ee758425c. Multiple builtbot failures have been reported: https://github.com/llvm/llvm-project/pull/139584
2025-05-22[clang] Remove intrusive reference count from `DiagnosticOptions` (#139584)Jan Svoboda1-6/+9
The `DiagnosticOptions` class is currently intrusively reference-counted, which makes reasoning about its lifetime very difficult in some cases. For example, `CompilerInvocation` owns the `DiagnosticOptions` instance (wrapped in `llvm::IntrusiveRefCntPtr`) and only exposes an accessor returning `DiagnosticOptions &`. One would think this gives `CompilerInvocation` exclusive ownership of the object, but that's not the case: ```c++ void shareOwnership(CompilerInvocation &CI) { llvm::IntrusiveRefCntPtr<DiagnosticOptions> CoOwner = &CI.getDiagnosticOptions(); // ... } ``` This is a perfectly valid pattern that is being actually used in the codebase. I would like to ensure the ownership of `DiagnosticOptions` by `CompilerInvocation` is guaranteed to be exclusive. This can be leveraged for a copy-on-write optimization later on. This PR changes usages of `DiagnosticOptions` across `clang`, `clang-tools-extra` and `lldb` to not be intrusively reference-counted.
2025-04-19[clang] llvm::append_range (NFC) (#136440)Kazu Hirata1-1/+1
2025-02-14[clang-repl] fix error recovery while parsing completely fails (#127087)Vipul Cariappa1-0/+7
Fixes the following crash in clang-repl ```c++ clang-repl> try { throw 1; } catch { 0; } In file included from <<< inputs >>>:1: input_line_1:1:23: error: expected '(' 1 | try { throw 1; } catch { 0; } | ^ | ( clang-repl: /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/lib/AST/DeclBase.cpp:1757: void clang::DeclContext::addHiddenDecl(clang::Decl*): Assertion `D->getLexicalDeclContext() == this && "Decl inserted into wrong lexical context"' failed. #0 0x000059b28459e6da llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/llvm/lib/Support/Unix/Signals.inc:804:22 #1 0x000059b28459eaed PrintStackTraceSignalHandler(void*) /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/llvm/lib/Support/Unix/Signals.inc:880:1 #2 0x000059b28459bf7f llvm::sys::RunSignalHandlers() /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/llvm/lib/Support/Signals.cpp:105:20 #3 0x000059b28459df8e SignalHandler(int, siginfo_t*, void*) /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/llvm/lib/Support/Unix/Signals.inc:418:13 #4 0x000077cdf444ea50 (/usr/lib/libc.so.6+0x42a50) #5 0x000077cdf44aee3b pthread_kill (/usr/lib/libc.so.6+0xa2e3b) #6 0x000077cdf444e928 raise (/usr/lib/libc.so.6+0x42928) #7 0x000077cdf443156c abort (/usr/lib/libc.so.6+0x2556c) #8 0x000077cdf44314d2 __assert_perror_fail (/usr/lib/libc.so.6+0x254d2) #9 0x000077cdf4444c56 (/usr/lib/libc.so.6+0x38c56) #10 0x000059b28495bfc4 clang::DeclContext::addHiddenDecl(clang::Decl*) /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/lib/AST/DeclBase.cpp:1759:3 #11 0x000059b28495c0f5 clang::DeclContext::addDecl(clang::Decl*) /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/lib/AST/DeclBase.cpp:1785:37 #12 0x000059b28773cc2a clang::Sema::ActOnStartTopLevelStmtDecl(clang::Scope*) /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/lib/Sema/SemaDecl.cpp:20302:18 #13 0x000059b286f1efdf clang::Parser::ParseTopLevelStmtDecl() /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/lib/Parse/ParseDecl.cpp:6024:62 #14 0x000059b286ef18ee clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/lib/Parse/Parser.cpp:1065:35 #15 0x000059b286ef0702 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/lib/Parse/Parser.cpp:758:36 #16 0x000059b28562dff2 clang::IncrementalParser::ParseOrWrapTopLevelDecl() /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/lib/Interpreter/IncrementalParser.cpp:66:36 #17 0x000059b28562e5b7 clang::IncrementalParser::Parse(llvm::StringRef) /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/lib/Interpreter/IncrementalParser.cpp:132:8 #18 0x000059b28561832b clang::Interpreter::Parse(llvm::StringRef) /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/lib/Interpreter/Interpreter.cpp:570:8 #19 0x000059b285618cbd clang::Interpreter::ParseAndExecute(llvm::StringRef, clang::Value*) /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/lib/Interpreter/Interpreter.cpp:649:8 #20 0x000059b2836f9343 main /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/tools/clang-repl/ClangRepl.cpp:255:59 #21 0x000077cdf443388e (/usr/lib/libc.so.6+0x2788e) #22 0x000077cdf443394a __libc_start_main (/usr/lib/libc.so.6+0x2794a) #23 0x000059b2836f7965 _start (./bin/clang-repl+0x73b8965) fish: Job 1, './bin/clang-repl' terminated by signal SIGABRT (Abort) ``` With this change: ```c++ clang-repl> try { throw 1; } catch { 0; } In file included from <<< inputs >>>:1: input_line_1:1:23: error: expected '(' 1 | try { throw 1; } catch { 0; } | ^ | ( error: Parsing failed. clang-repl> 1; clang-repl> %quit ```
2024-09-27[clang] return first Decl for CanonicalDecl in TranslationUnitDecl (#110101)Vipul Cariappa1-0/+22
Return the first `Decl` when using `TranslationUnitDecl::getCanonicalDecl`
2024-07-03[clang-repl] Fix RuntimeInterfaceBuilder for 32-bit systems (#97071)Stefan Gränitz1-4/+0
When generating runtime interface bindings, extend integral types to the native register size rather than 64-bit per se Fixes #94994
2024-06-30[clang] Avoid 'raw_string_ostream::str' (NFC)Youngsuk Kim1-2/+2
Since `raw_string_ostream` doesn't own the string buffer, it is desirable (in terms of memory safety) for users to directly reference the string buffer rather than use `raw_string_ostream::str()`. Work towards TODO comment to remove `raw_string_ostream::str()`.
2024-06-14[clang-interp] Use -fno-sized-deallocation in two tests (#95546)Nico Weber1-1/+2
At least on my Windows machine, these two tests fail due to not being able to look up `??3@YAXPEAX_K@Z` (which is `void __cdecl operator delete(void *, unsigned __int64)` in demangled) after 130e93cc26ca. Since they don't test anything related to sized deallocation, just disable sized allocation for them. Possibly fixes #95451.
2024-06-10[clang][test] Update link for Arm clang-repl test disableDavid Spickett1-1/+1
The original bug is legitimate UB, but this is in the clang constant expression interpreter, not clang-repl. https://github.com/llvm/llvm-project/issues/94994 covers investigation of this specific bug in clang-repl.
2024-06-07[clang][test] Skip interpreter value test on Arm 32 bitDavid Spickett1-0/+4
https://github.com/llvm/llvm-project/pull/89811 caused this test to fail, somehow. I think it may not be at fault, but actually be exposing some existing undefined behaviour, see https://github.com/llvm/llvm-project/issues/94741. Skipping this for now to get the bots green again.
2024-05-30[clang-repl] Fix SetUp in CodeCompletionTest fixture (#93816)Stefan Gränitz1-6/+1
And sort out some unused headers
2024-05-30[clang-repl] Introduce common fixture class in unittests (NFC) (#93816)Stefan Gränitz1-84/+16
Reduce code bloat by checking test requirements in a common test fixture
2024-05-30[clang-repl] Even more tests create the Interpreter and must check host JIT ↵Stefan Gränitz1-0/+4
support 2 (#84758)
2024-05-28[clang-repl] Check host JIT support in all tests that create an Interpreter ↵Stefan Gränitz1-31/+57
(#84758)
2024-03-25[clang-repl] Fix Value for platforms where unqualified char is unsigned (#86118)Stefan Gränitz1-0/+6
Signedness of unqualified `char` is unspecified and varies between platforms. This patch adds `Char_U` in `REPL_BUILTIN_TYPES` to account for platforms that default to `unsigned char`.
2024-01-20[clang-repl] We do not need to call new in the object allocation. (#78843)Vassil Vassilev1-9/+6
This test demonstrates template instantiation via the interpreter code. In order to do that we can allocate the object on the stack and extend its lifetime by boxing it into a clang::Value. That avoids the subtle problem where we call the new operator on an object only known to the interpreter and we cannot destroy it from compiled code since there is not suitable facility in clang::Value yet. That should resolve the asan issues that was reported in llvm/llvm-project#76218.
2024-01-18[clang-repl][test] Suppress memory lease after #76218Vitaly Buka1-0/+8
`new` was introduced in this patch, but I don't see `delete` to release the memory.
2024-01-18[clang-repl] Add a interpreter-specific overload of operator new for C++ ↵Vassil Vassilev1-24/+5
(#76218) This patch brings back the basic support for C by inserting the required for value printing runtime only when we are in C++ mode. Additionally, it defines a new overload of operator placement new because we can't really forward declare it in a library-agnostic way. Fixes the issue described in llvm/llvm-project#69072.
2023-09-27Re-apply "[ORC][LLJIT] Move enable-debugger-support utility out of..."Lang Hames1-3/+1
This re-applies e1a5bb59b91, which was reverted in e5f169f91a8 due to LSan failures on some bots (see https://github.com/llvm/llvm-project/issues/67586). The LSan failures were not caused by this patch (just exposed by it), so LSan was disabled for the failing test in 47625fea5e3. This should be safe to re-land now.
2023-09-22Revert "[ORC][LLJIT] Move enable-debugger-support utility out of LLJITBuilder."Lang Hames1-1/+3
This reverts commit e1a5bb59b91d60c0d87feb78f0e0614589a4c927 while I investigate the bot failure at https://lab.llvm.org/buildbot/#/builders/168/builds/15831
2023-09-22[ORC][LLJIT] Move enable-debugger-support utility out of LLJITBuilder.Lang Hames1-3/+1
This change means that debugger support only needs to be linked in if it's used. The code size of debugger support is expected to increase as we improve it (e.g. pulling in DWARF parsing), so making it an optional extra is useful for controlling final binary sizes.
2023-09-05[Clang] Fix JIT test on 32-bit systemsSam James1-1/+1
As reported by mgorny at https://reviews.llvm.org/D159115#4638037, the unsigned long long cast fails on 32-bit systems at least with GCC. It looks like a pointer provenance/aliasing issue rather than a bug in GCC. Acked by Vassil Vassilev on the original revision.
2023-08-29Reland "[clang-repl] Adapt to the recent dylib-related changes in ORC."Vassil Vassilev1-3/+13
Original commit message:" ORC splits into separate dylibs symbols coming from the process and symbols materialized in the Jit. This patch adapts intent of the existing interface and adds a regression test to make sure both Jit'd and compiled symbols can be found. Differential revision: https://reviews.llvm.org/D159115 " This patch disables the test statement on windows as it seems we might have a bug in the way we model dllimports.
2023-08-29Revert "[clang-repl] Adapt to the recent dylib-related changes in ORC."Vassil Vassilev1-9/+3
This reverts commit 196d8569d46dc5200c44e70cdf839b042148b988 while investigating bot failure: https://lab.llvm.org/buildbot/#/builders/216/builds/26444
2023-08-29[clang-repl] Adapt to the recent dylib-related changes in ORC.Vassil Vassilev1-3/+9
ORC splits into separate dylibs symbols coming from the process and symbols materialized in the Jit. This patch adapts intent of the existing interface and adds a regression test to make sure both Jit'd and compiled symbols can be found. Differential revision: https://reviews.llvm.org/D159115
2023-08-24[ORC][clang-repl] Fix another unit test after 122ebe3b500.Lang Hames1-1/+3
Same fix as 8a62d6ba7e: We need to make sure that the supports-JIT check uses the same JIT config that will be used in the actual test.
2023-05-27[clang-repl][CUDA] Re-land: Initial interactive CUDA support for clang-replAnubhab Ghosh1-1/+3
CUDA support can be enabled in clang-repl with --cuda flag. Device code linking is not yet supported. inline must be used with all __device__ functions. Differential Revision: https://reviews.llvm.org/D146389
2023-05-23Reland "Reland [clang-repl] Introduce Value to capture expression results"Jun Zhang1-2/+106
This reverts commit 094ab4781262b6cb49d57b0ecdf84b047c879295. Reland with changing `ParseAndExecute` to `Parse` in `Interpreter::create`. This avoid creating JIT instance everytime even if we don't really need them. This should fixes failures like https://lab.llvm.org/buildbot/#/builders/38/builds/11955 The original reverted patch also causes GN bot fails on M1. (https://lab.llvm.org/buildbot/#/builders/38/builds/11955) However, we can't reproduce it so let's reland it and see what happens. See discussions here: https://reviews.llvm.org/rGd71a4e02277a64a9dece591cdf2b34f15c3b19a0
2023-05-20Revert "[clang-repl][CUDA] Initial interactive CUDA support for clang-repl"Anubhab Ghosh1-3/+1
This reverts commit 80e7eed6a610ab3c7289e6f9b7ec006bc7d7ae31.
2023-05-20[clang-repl][CUDA] Initial interactive CUDA support for clang-replAnubhab Ghosh1-1/+3
CUDA support can be enabled in clang-repl with --cuda flag. Device code linking is not yet supported. inline must be used with all __device__ functions. Differential Revision: https://reviews.llvm.org/D146389
2023-05-19Revert "Reland [clang-repl] Introduce Value to capture expression results"Jun Zhang1-106/+2
This reverts commit d71a4e02277a64a9dece591cdf2b34f15c3b19a0. See http://45.33.8.238/macm1/61024/step_7.txt
2023-05-19Reland [clang-repl] Introduce Value to capture expression resultsJun Zhang1-2/+106
This reverts commit 7158fd381a0bc0222195d6a07ebb42ea57957bda. * Fixes endianness issue on big endian machines like PowerPC-bl * Disable tests on platforms that having trouble to support JIT Signed-off-by: Jun Zhang <jun@junz.org>
2023-05-16Revert "[clang-repl] Introduce Value to capture expression results"Jun Zhang1-98/+2
This reverts commit a423b7f1d7ca8b263af85944f57a69aa08fc942c. See https://lab.llvm.org/buildbot/#/changes/95083
2023-05-16[clang-repl] Introduce Value to capture expression resultsJun Zhang1-2/+98
This is the second part of the below RFC: https://discourse.llvm.org/t/rfc-handle-execution-results-in-clang-repl/68493 This patch implements a Value class that can be used to carry expression results in clang-repl. In other words, when we see a top expression without semi, it will be captured and stored to a Value object. You can explicitly specify where you want to store the object, like: ``` Value V; llvm::cantFail(Interp->ParseAndExecute("int x = 42;")); llvm::cantFail(Interp->ParseAndExecute("x", &V)); ``` `V` now stores some useful infomation about `x`, you can get its real value (42), it's `clang::QualType` or anything interesting. However, if you don't specify the optional argument, it will be captured to a local variable, and automatically called `Value::dump`, which is not implemented yet in this patch. Signed-off-by: Jun Zhang <jun@junz.org>
2023-04-16[clang-repl] JITTargetAddress --> ExecutorAddr, NFCJun Zhang1-2/+3
Most of Orc and JITLink are movinng away from JITTargetAddress and use ExecutorAddr instead. Signed-off-by: Jun Zhang <jun@junz.org> Differential Revision: https://reviews.llvm.org/D148434
2022-12-03[clang-repl] Support statements on global scope in incremental mode.Vassil Vassilev1-7/+1
This patch teaches clang to parse statements on the global scope to allow: ``` ./bin/clang-repl clang-repl> int i = 12; clang-repl> ++i; clang-repl> extern "C" int printf(const char*,...); clang-repl> printf("%d\n", i); 13 clang-repl> %quit ``` Generally, disambiguating between statements and declarations is a non-trivial task for a C++ parser. The challenge is to allow both standard C++ to be translated as if this patch does not exist and in the cases where the user typed a statement to be executed as if it were in a function body. Clang's Parser does pretty well in disambiguating between declarations and expressions. We have added DisambiguatingWithExpression flag which allows us to preserve the existing and optimized behavior where needed and implement the extra rules for disambiguating. Only few cases require additional attention: * Constructors/destructors -- Parser::isConstructorDeclarator was used in to disambiguate between ctor-looking declarations and statements on the global scope(eg. `Ns::f()`). * The template keyword -- the template keyword can appear in both declarations and statements. This patch considers the template keyword to be a declaration starter which breaks a few cases in incremental mode which will be tackled later. * The inline (and similar) keyword -- looking at the first token in many cases allows us to classify what is a declaration. * Other language keywords and specifiers -- ObjC/ObjC++/OpenCL/OpenMP rely on pragmas or special tokens which will be handled in subsequent patches. The patch conceptually models a "top-level" statement into a TopLevelStmtDecl. The TopLevelStmtDecl is lowered into a void function with no arguments. We attach this function to the global initializer list to execute the statement blocks in the correct order. Differential revision: https://reviews.llvm.org/D127284
2022-07-30[clang-repl] Disable exectuion unitests on unsupported platform by lljit ↵Sunho Kim1-3/+20
instance test. The method used in 4191d661c74622c6fa72c1643e4567f45e6c9e1b was fragile because it didn't consider cross-platform builds and rely on enlisting unsupported targets. Uses the host-supports-jit mechanism to make an escape path. This should fix buildbot failures happening in upstream as well as out-of-tree.
2022-07-30[clang-repl] Disable execution unittests on unsupported platforms.Sunho Kim1-2/+8
After the intoduction of global destructor support, there is a possiblity to run invalid instructions in the destructor of Interpreter class. Completely disable tests in platforms with failing test cases. Differential Revision: https://reviews.llvm.org/D130786
2022-07-27clang: include ManagedStatic.h for llvm_shutdownNicolai Hähnle1-0/+1
The code relied on ManagedStatic.h being included indirectly. This is about to change as uses of ManagedStatic are removed throughout the codebase. Differential Revision: https://reviews.llvm.org/D130575
2022-07-16[test] Fix leak in testVitaly Buka1-1/+4
2022-06-26[clang-repl] Implement code undo.Jun Zhang1-0/+45
In interactive C++ it is convenient to roll back to a previous state of the compiler. For example: clang-repl> int x = 42; clang-repl> %undo clang-repl> float x = 24 // not an error To support this, the patch extends the functionality used to recover from errors and adds functionality to recover the low-level execution infrastructure. The current implementation is based on watermarks. It exploits the fact that at each incremental input the underlying compiler infrastructure is in a valid state. We can only go N incremental inputs back to a previous valid state. We do not need and do not do any further dependency tracking. This patch was co-developed with V. Vassilev, relies on the past work of Purva Chaudhari in clang-repl and is inspired by the past work on the same feature in the Cling interpreter. Co-authored-by: Purva-Chaudhari <purva.chaudhari02@gmail.com> Co-authored-by: Vassil Vassilev <v.g.vassilev@gmail.com> Signed-off-by: Jun Zhang <jun@junz.org>