Commit Graph

5230 Commits

Author SHA1 Message Date
Jonas Hahnfeld
aeba3fa2c7 DeclUnloader: Remove extra check isInstantiatedInPCH
This effectively reverts commit 74472caaa9 ("[cling] Fixes issue in
DeclUnloader: do not unload templates intantiated in the PCH"), it's
not needed anymore, all tests pass and the snippet in the summary of
https://github.com/root-project/root/pull/4447 works, but it filters
too many declarations from the unloader.
2023-11-30 08:59:08 +01:00
Javier Lopez-Gomez
d3e42235c1 DeclUnloader: do not delete instantiated member functions
The body of member functions of a templated class only gets instantiated
when the function is used.  These `CXXMethodDecl` should not be deleted
from the AST; instead return them to the 'instantiation pending' state.
2023-11-30 08:59:08 +01:00
Javier Lopez-Gomez
33a63913b3 DeclUnloader: remove StaticVarCollector
StaticVarCollector recursively visited descendants of a `FunctionDecl`
node to collect static local variables.  However, these always appear
in the enclosing DeclContext.
2023-11-30 08:59:08 +01:00
Danilo Piparo
a292a61b28 Simplify std::tuple/pair value printer
By using std::apply, now available after moving to C++17,
the implementation can be greatly simplified.
2023-10-18 06:59:05 +02:00
Jonas Hahnfeld
41e07b3b23 Handle length modifiers in IsClassOrFunction
This expands the handling introduced in commit 31e46a65f6 to include
the length modifiers 'short' and 'long' as mentioned back then. It
still doesn't handle the cases of multiple modifiers such as "unsigned
long long int" and "long int unsigned long" (being the same type).

Fixes https://github.com/root-project/root/issues/13288
2023-10-13 10:14:07 +02:00
Jonas Hahnfeld
97485f56de Refactor modifier handling in IsClassOrFunction 2023-10-13 10:14:07 +02:00
Jonas Hahnfeld
a3fa6e22a1 Emit const variables only once (#13614)
Otherwise they are emitted as internal and we get double-construction
and -destruction on the same memory address due to the way we promote
internal declarations in KeepLocalGVPass.

According to upstream tests, the de-duplication doesn't work on Windows
(yet), but I think this problem is severe enough to fix it on the other
platforms sooner rather than later.

Fixes #13429
2023-10-03 17:14:07 +02:00
Javier Lopez-Gomez
45318c5a0e Fix unmatched #pragma clang diagnostic push 2023-08-24 23:44:07 +02:00
Javier Lopez-Gomez
ed8ed246b2 Move helper functions to anonymous namespace at the beginning 2023-08-24 23:44:07 +02:00
Jonas Hahnfeld
dfee35549d Skip IncrementalExecutor for CUDADevice
We don't need it, and with the upgrade to LLVM 16 the NVPTX target
(correctly) errors that there is no (direct) JIT execution support.
2023-08-18 19:29:07 +02:00
Jonas Hahnfeld
345d51a8b0 Fix assertion in ExternalInterpreterSource
As far as I can understand the intent, this wants to check that the
diagnostic is *not* because it's an unsupported AST node.
2023-08-18 19:29:07 +02:00
Jonas Hahnfeld
ba5faff605 Cast to base element type pointer before calling copyArray
(For context, this is important for multi-dimensional constant arrays
as described in ROOT-7016 and tested in Cling's Interfaces/evaluate.C
test. But for reasons unknown to me, the ROOT prompt now seems to have
a different way of handling this case because just reverting commit
d97e4dca363 still works there...)

Instead of using relying on recursive templated calls, perform the
type cast in the ValueExtractionSynthesizer. This has the advantage
of avoiding an ODR violation warning in MultipleInterpreters.C with
LLVM 16 (while unclear if that one is correct or not).
2023-08-18 19:29:07 +02:00
Sergey Linev
0a23c00a1a increase minimal version requirement to 3.5, call before project
Future cmake will no longer support features before version 3.5
Also `cmake_minimum_required` must be called before `project`
2023-08-17 17:44:07 +02:00
Jonas Hahnfeld
76e87e6686 Remove REQUIRES: not_system-windows
Replace it by the standard UNSUPPORTED: system-windows.
2023-08-14 18:44:02 +02:00
Jonas Hahnfeld
bb45512ff6 Stop using triple substrings in UNSUPPORTED
With LLVM 16 and https://reviews.llvm.org/D141007, this will not be
supported anymore. As a replacement, use system-{darwin,linux,windows}.
2023-08-14 18:44:02 +02:00
Sergey Linev
0b175d1f01 fix unsafe mix of type warning in Diagnostic.cpp
Warning appears when building on Windows:

```
Diagnostics.cpp
C:\git\root\interpreter\cling\lib\Utils\Diagnostics.cpp(37,27): warning
C4805: '|': unsafe mix of type 'bool' and type
'int' in operation
[C:\Soft\root_64\interpreter\cling\lib\Utils\obj.clingUtils.vcxproj]
```
2023-08-14 15:14:03 +02:00
Stephan Lachnit
53d69ef760 Improve interface for external LLVM 2023-08-10 09:29:06 +02:00
Stephan Lachnit
c0e9de73bf Explicitly disable linking against shared LLVM 2023-08-10 09:29:06 +02:00
Stephan Lachnit
4261b067ab CMake: use CLING_BINARY_DIR instead of LLVM_BINARY_DIR to configure ClingConfig.cmake
This fixes #12151.

Signed-off-by: Stephan Lachnit <stephanlachnit@debian.org>
2023-08-08 08:44:08 +02:00
Stephan Lachnit
798c565978 Remove usage of --src-root with llvm-config 2023-08-02 10:59:04 +02:00
Jonas Hahnfeld
5a58c4f08d Inject symbols from libc_nonshared.a
These symbols may not be found automatically. See also upstream issue
https://github.com/llvm/llvm-project/issues/61289. This fixes the
test DynamicLibraryManager/cached_realpath.C, approach by Lang Hames.
2023-07-21 13:14:04 +02:00
Vassil Vassilev
5e3310ac04 Bump clad version to v1.2.
This new release includes some improvements:
  * Add experimental support for forward vector mode
  * Add pushforwards for std::floor and std::ceil
  * Improve AD function interfaces with bitmasked options. For example:
    clad::differentiate<<clad::order::first, clad::opts::vector_mode>(f) will
    be equivalent to clad::differentiate<<1, clad::opts::vector_mode>(f) and
    will request the first order derivative of f in forward vector mode.
  * LLVM16 Support

See more at: https://github.com/vgvassilev/clad/blob/v1.2/docs/internalDocs/ReleaseNotes.md
2023-07-20 16:59:07 +02:00
Maksymilian Graczyk
01ff272a9f Fix cling incorrect LLVM path for external LLVM+clang 2023-07-20 12:14:04 +02:00
Jonas Hahnfeld
c1574685cb Automatically adjust C++ version of PCH in Cling's test
This fixes test/CodeUnloading/PCH/VTables.C with C++17 and later.
2023-07-20 08:44:03 +02:00
Jonas Hahnfeld
a9ebc3862c Remove unused tools from Cling's lit.cfg 2023-07-20 08:44:03 +02:00
Jonas Hahnfeld
a8b0ad9867 Remove unused ASTContext from getCorrespondingTypeKind 2023-07-20 08:44:03 +02:00
Jonas Hahnfeld
ebd3404baa Fix void Value across Interpreters
They have different ASTContexts, so the VoidTy is different.
2023-07-20 08:44:03 +02:00
Jonas Hahnfeld
6466a6dfe9 Only execute void expression in MultipleInterpreters.C
It was probably an accident and currently leads to an assertion (that
will be fixed in the next commit).
2023-07-20 08:44:03 +02:00
Jiang Yi
b9e8886af7 Extend test/Prompt/decls.C to test ctor, dtor and operator 2023-07-18 20:14:07 +02:00
Jiang Yi
884b73b2a7 Treat operator overload as normal function. Do not wrap it.
Fixes https://github.com/root-project/root/issues/9449

so it is possible to define operator overload in cling cmd prompt.

btw, Make SkipPointerRefs() to not assume next token being a

tok::raw_identifier since it can be a global-scoped identifier,

e.g. int* ::class_a::func_b(short c) { return nullptr; }
2023-07-18 20:14:07 +02:00
Jiang Yi
7c7f5e0d19 cmd prompt skips global scope while parsing func return type
e.g. ::class_a class_b::mem_func_b() { return 'w'; }

skip :: right before class_a while calculating wrap point
2023-07-18 20:14:07 +02:00
Jiang Yi
097e09d5b7 support defining and declaring default/delete ctor/dtor in cmd prompt
e.g.  class_a::class_a() = default;
      class_a::~class_a();

They have no function definition body so caller of IsClassOrFunction()

should not try to parse their function bodies.
2023-07-18 20:14:07 +02:00
Jonas Hahnfeld
8a633e6d76 Unify access to template_arguments
The other methods, such as directly calling begin() and end() as well
as getNumArgs() and getArgs() will go away in LLVM 16, see commit
https://github.com/llvm/llvm-project/commit/1acffe81ee.
2023-07-11 12:29:06 +02:00
Jonas Hahnfeld
dbb34a4450 Use standard way to set up OverlayFS
This makes it possible to drop our custom CompilerInvocation::addOverlay
functionality (but the rest of the patch that introduced it is still
needed with LLVM 13, so it cannot be reverted for now).
2023-07-11 11:59:07 +02:00
Vassil Vassilev
c2562c72b1 ParseTypeName might trigger deserialization. 2023-07-04 19:29:05 +02:00
Jonas Hahnfeld
4c7a2f1ba7 Add API to iterate already loaded specializations
This avoids deserialization if necessary, for example in DeclUnloader.

See also https://reviews.llvm.org/D154328
2023-07-04 19:29:05 +02:00
Maksymilian Graczyk
67235e8a2a Add jitlink to LLVM_LINK_COMPONENTS in relevant cling parts 2023-07-01 12:44:07 +02:00
Jonas Hahnfeld
30e1bd3c7d Remove checks for deprecated _REENTRANT macro
According to feature_test_macros, this macro is obsolete and "glibc
has been thread-safe by default for many years." Other platforms
don't use it at all, for example FreeBSD.

Some parts of ROOT used it to determine if we are compiling with
-pthread, but this is essentially unused these days because the
CMake build always enables threading support and there exists no
option to turn it off.
2023-06-30 11:14:03 +02:00
Jonas Hahnfeld
95cdce8055 Adopt upstream llvm-project monorepo directory layout (#13049)
This will be required for future LLVM upgrades that rely on a common
cmake/ directory next to clang/ and llvm/.

The bulk of this change is the result of the following commands:
 $ mkdir interpreter/llvm-project/
 $ git mv interpreter/llvm/src/tools/clang/ interpreter/llvm-project/clang/
 $ git mv interpreter/llvm/src/ interpreter/llvm-project/llvm/
 $ git mv interpreter/llvm/llvm-project.tag interpreter/llvm-project/llvm-project.tag
2023-06-25 13:44:07 +02:00
Mikolaj Krzewicki
acb2334131 Initial support for building on FreeBSD (#12996)
Co-authored-by: Mikolaj Krzewicki <Mikolaj Krzewicki mkrzewicki@gmail.com>
2023-06-22 11:14:05 +02:00
Jiang Yi
a1b1c875fd startup script support
Before showing command promt or executing scripts from argv,
enumerate .C files in the directory ${CLING_HOME}/.cling.d/ in alphabetic
order then .x them.

Search order of ${CLING_HOME}:

1. ${CLING_HOME} envvar
2. ${XDG_CONFIG_HOME}/cling/
3. ${HOME}/.config/cling/
4. ${HOME}/
2023-06-16 16:29:08 +02:00
Jonas Hahnfeld
ee2c1bbe2d Remove module for xlocale.h
As commit 2db042523a explains, this header doesn't exist anymore since
glibc 2.26. The oldest distributions that ROOT currently supports are
EL8 and Debian 10, both of which have glibc 2.28. Remove the module as
it also causes problems on FreeBSD due to including locale.h and a
cyclic dependency std -> xlocale.h -> std.
2023-06-13 11:44:04 +02:00
Jiang Yi
42e296f28c meta cmd .x should not crash if no arg is given 2023-06-07 21:59:06 +02:00
Javier Lopez-Gomez
1cca2f0f7e Restore symbol lookup in child interpreters
Prior to the upgrade to LLVM13, child interpreters used to also lookup symbols
in their parent.
This commit introduces a `DefinitionGenerator` that allows for symbol lookup
across different `IncrementalJIT` instances, which restores the old behavior.

This change fixes the following tests:
- CodeUnloading/AtExit.C
- MultipleInterpreters/MultipleInterpreters.C

Fixes #12455.
2023-05-31 21:29:03 +02:00
Javier Lopez-Gomez
09fe1fd2b3 DeclExtractor: use BuildReturnStmt() instead
Do not use `ActOnReturnStmt()`, given that the scope returned by
`m_Sema->getCurScope()` might be == m_Sema->TUScope which obviously is
not a function scope.

This fixes the following crash:
```
1:  #3 0x0000556b6a50389e clang::Sema::ActOnReturnStmt(clang::SourceLocation, clang::Expr*, clang::Scope*) (/home/jalopezg/CERN/repos/root/_build/interpreter/llvm/src/bin/cling+0x225389e)
1:  #4 0x0000556b69215c56 cling::DeclExtractor::EnforceInitOrder(llvm::SmallVector<clang::Stmt*>&) (/home/jalopezg/CERN/repos/root/_build/interpreter/llvm/src/bin/cling+0xf65c56)
1:  #5 0x0000556b69216788 cling::DeclExtractor::ExtractDecl(clang::FunctionDecl*) (/home/jalopezg/CERN/repos/root/_build/interpreter/llvm/src/bin/cling+0xf66788)
1:  #6 0x0000556b69216a75 cling::DeclExtractor::Transform(clang::Decl*) (/home/jalopezg/CERN/repos/root/_build/interpreter/llvm/src/bin/cling+0xf66a75)
```
2023-05-31 21:29:03 +02:00
Jonas Hahnfeld
f23f0ed9ca Re-download all Clad patches from GitHub
This guarantees valid patch files.
2023-05-30 09:14:07 +02:00
Bertrand Bellenot
9735886a70 Fix failing patch on Windows (#12882)
* Fix failing patch on Windows

Fix `fatal: corrupt patch at line 28` on Windows

* More trailing white spaces
2023-05-25 15:14:06 +02:00
Jonas Hahnfeld
833c1c1b75 Simplify logic for build with old toolchain
Setting LLVM_FORCE_USE_OLD_TOOLCHAIN will skip all checks in
interpreter/llvm/src/cmake/modules/CheckCompilerVersion.cmake, which
is what we want.
2023-05-25 11:14:05 +02:00
Javier Lopez-Gomez
ef943ddcfa Always promote warn_falloff_nonvoid_function to error
This diagnostic should always be promoted to error, regardless of the ignoring
state in `FilteringDiagConsumer`.
This fixes the SourceCall/ErrorMacro.C test.

The failure became visible after merging
https://github.com/root-project/root/pull/12654, given that `IgnorePromptDiags`
now defaults to 0 in `makeDefaultCompilationOptions()`.
2023-05-19 23:29:06 +02:00
Javier Lopez-Gomez
5ca904dabd Fix DynamicLibraryManager/cached_realpath.C test
Fetching the value of `errno` only makes sense after a failed call to
`realpath()`, i.e. if the return value of the function is NULL.
2023-05-19 23:29:06 +02:00