Commit Graph

3362 Commits

Author SHA1 Message Date
Vassil Vassilev
1b0fffe4ba Expr dependence was reworked and made protected.
By default we should get no dependence, assert that instead.

See llvm/llvm-project@ec3060c72d
2022-12-09 08:44:16 +01:00
Vassil Vassilev
1afd43b6da stripPointerCastsNoFollowAliases got renamed to stripPointerCasts
See llvm/llvm-project@2452d7030b
2022-12-09 08:44:16 +01:00
Vassil Vassilev
cef10fdf63 createOutputFile was simplified.
See llvm/llvm-project@ad7aaa475e
2022-12-09 08:44:16 +01:00
Vassil Vassilev
7fcc35181a FileInfo always has content cache and replaceBuffer became setBuffer.
See llvm/llvm-project@296314516d
2022-12-09 08:44:16 +01:00
Vassil Vassilev
0041450ed4 ContentCache::getRawBuffer is replaced with getBufferDataIfLoaded
See llvm/llvm-project@156e8b3702
2022-12-09 08:44:16 +01:00
Vassil Vassilev
62dc043874 Qualify DestroyTemplateIdAnnotationsRAIIObj. 2022-12-09 08:44:16 +01:00
Vassil Vassilev
62d600d2cf FileManager::getFile returns an llvm::ErrorOr which needs to be checked. 2022-12-09 08:44:16 +01:00
Vassil Vassilev
f086a7e06f getFlags returns llvm::Expected. 2022-12-09 08:44:16 +01:00
Vassil Vassilev
a82c91dbc1 The BuiltinContext is in a separate header. 2022-12-09 08:44:16 +01:00
Vassil Vassilev
dd4a124b8f OmitFramePointer flag became an enum.
See llvm/llvm-project@ff22ec3d70
2022-12-09 08:44:16 +01:00
Vassil Vassilev
0679bcbd75 ShowTimers went in CodeGenOptions.
See llvm/llvm-project@1821265db6
2022-12-09 08:44:16 +01:00
Vassil Vassilev
b3196f3644 CreateFromArgs takes now an ArrayRef.
See llvm/llvm-project@1fac68b0dc
2022-12-09 08:44:16 +01:00
Vassil Vassilev
9a73829827 llvm::sys::fs went into a separate header. 2022-12-09 08:44:16 +01:00
Vassil Vassilev
6f04131d85 CPlusPlus2a was renamed to CPlusPlus20. 2022-12-09 08:44:16 +01:00
Vassil Vassilev
64125520ed getName returns now Expected<StringRef>
See llvm/llvm-project@bcc00e1afb
2022-12-09 08:44:16 +01:00
Vassil Vassilev
e08a5e0fee Preprocessor::LookupFile returns FileEntryRef.
See llvm/llvm-project@4dc5573acc
2022-12-09 08:44:16 +01:00
Vassil Vassilev
e209eba70b The mangler accepts GlobalDecls and we don't need special cases ctors and dtors.
See llvm/llvm-project/29e1a16be8216066d1ed733a763a749aed13ff47
2022-12-09 08:44:16 +01:00
Vassil Vassilev
2a956809bb Color handling moved from raw_fd_ostream to raw_ostream.
We do not need the wrapper which did more than needed.

See llvm/llvm-project@8744d7f25b
2022-12-09 08:44:16 +01:00
Vassil Vassilev
c8c61d7aa9 llvm::StringRef does not support automatic conversion to string anymore.
See llvm/llvm-project@777180a32b
2022-12-09 08:44:16 +01:00
Vassil Vassilev
83ff0acdd2 Add getSizeExpr parameter.
See llvm-project/llvm@772e266fbf
2022-12-09 08:44:16 +01:00
Jonas Hahnfeld
eb2b4bd693 Revert "Add support for profiling/debugging interpreted/JITted code"
This reverts commit 22b1606f5fd842590f04724d789de5b29495efc6 until it
is re-implemented on top of the changes for upgrading to LLVM 13.
2022-12-09 08:44:15 +01:00
Vassil Vassilev
4d262fb1f5 Revert "Disable optimizations and keep frame pointer when debugging"
This reverts commit b3193eb7c7ac0a7fb273b3c09be179bca7e8e8c9.
2022-12-09 08:44:15 +01:00
Vassil Vassilev
7bfde53296 Revert "Accept only true values for CLING_PROFILE and CLING_DEBUG"
This reverts commit a8e50f882e284b1dc47eb60951ef0672490ac31d.
2022-12-09 08:44:15 +01:00
Jiang Yi
7c1e968336 Delete UITabCompletion* with unique_ptr 2022-11-19 16:14:05 +01:00
Guilherme Amadio
086229fd34 Accept only true values for CLING_PROFILE and CLING_DEBUG
This implementation of ConvertEnvValueToBool uses const char* as
input intentionally in order to be able to accept nullptr for when
environment variables are not set, but also because using something
like std::string would require bringing in several extra headers.
2022-11-10 09:44:07 +01:00
Guilherme Amadio
13f82d17fe Disable optimizations and keep frame pointer when debugging 2022-11-10 09:44:07 +01:00
Baidyanath Kundu
6cabc7a8f8 Fix long long error in findBuiltinType 2022-09-20 15:14:04 +02:00
Sergey Linev
6dd621f4d3 add override qualifier for ColoredOutput methods 2022-08-31 09:14:04 +02:00
Jonas Hahnfeld
b1db1932ef Try to avoid crashes in llvm::identify_magic (#11174)
The overload taking a path opens the file and then mmap its contents.
This can cause bus errors when another process truncates the file
while we are trying to read it. Instead just read the first 1024 bytes,
which should be enough for identify_magic to do its work.
2022-08-12 14:29:05 +02:00
Jonas Hahnfeld
52fdb631cf Use logical operators for boolean operands (#10787)
This addresses a warning of recent Clang versions about the "use of
bitwise '|' with boolean operands [-Wbitwise-instead-of-logical]".
2022-07-27 11:44:07 +02:00
Enrico Guiraud
5f0c2a38ae Remove unused include of "llvm/Config/config.h"
Including that header from cling breaks building ROOT with
external llvm and clang (which is needed e.g. for the conda
package): `config.h` is not avaiable in that scenario.
2022-06-08 15:14:03 +02:00
Guilherme Amadio
bbc1089732 Add support for profiling/debugging interpreted/JITted code
This commit builds on previous work for getting GDB support for JITted
and interpreted code working in cling. It adds a JIT event listener as
well to create perf map files to allow profiling of interpreted/JITted
code with cling.

The functionality provided is disabled by default. The interface to
enable it has been chosen to be via environment variables to allow both
interpreted code in the prompt as well as linked code to be able to
optionally enable debugging/profiling. Using ld.so as example, where
LD_DEBUG and LD_PROFILE exist, we chose CLING_DEBUG and CLING_PROFILE
to enable these features. For the moment, setting these variables to
anything enables the feature. Later on, if support for oprofile is
added, for example, it may be better to enable specific JIT event
listeners depending on the value of the variables, for example with
CLING_PROFILE=perf or CLING_PROFILE=oprofile, respectively.
2022-06-07 21:59:05 +02:00
Simeon Ehrig
521bf307eb Fix crash, if cling is started with the arguments -xcuda -fsyntax-only
The crash occurs due to a missing guard that prevents `libcudart.so` from being
loaded. Loading a library requires an executor which is not available in
syntax-only mode.
2022-05-30 17:59:03 +02:00
Simeon Ehrig
5754b5ada3 DynamicLibraryManager::loadLibrary if the parameter resolve is false
The error occurs only when `loadLibrary()` is called with the argument `resolved = false`.
A const string reference is not possible here because a temporary copy of
lResolved would be referenced. The return type of libStem.str() has the
value type prvalue. Therefore, lResolved requires the same type and the
compiler inserts a copy constructor to satisfy this. For more details
see rule 3.3.1 here:
https://en.cppreference.com/w/cpp/language/operator_other#Conditional_operator
2022-05-19 15:29:04 +02:00
Jonas Hahnfeld
da46c747a1 Do not throw CompilationExceptions on Apple M1 (#10561)
See https://github.com/root-project/root/issues/7541 for details.

Closes #7744
2022-05-11 14:14:04 +02:00
Sergey Linev
460e7b8877 Use override syntax in cling classes 2022-05-06 20:59:03 +02:00
Axel Naumann
4d3d8b6ca3 .typedef: separate underlying and type alias name by space. 2022-04-26 14:14:02 +02:00
ferdymercury
b6e5c228bf fix missing newline also for class 2022-04-26 14:14:02 +02:00
ferdymercury
f7a3d879ac add missing newline
otherwise .typedef command shows weird format
2022-04-26 14:14:02 +02:00
ferdymercury
6486be661b Allow '.Class' command to take a class name
* make .Class the verbose equivalent of .class and take into account name passed to .Class. As it was the case in CINT.
* merge similar functions into one with a verbose arg
2022-04-25 17:44:06 +02:00
ferdymercury
877dbb58b4 Minor aesthetic fix in cling '.help' message
fix indentation
2022-04-25 17:44:06 +02:00
ferdymercury
19a2c1b73e Improve output of .help command
Co-authored-by: Javier Lopez-Gomez <javier.lopez.gomez@cern.ch>
2022-04-05 23:44:05 +02:00
ferdymercury
e359b1bacd add short version of help, as in quit (#10055)
* MetaSema: add short version of help, as in quit
Primer: join help and ?, mention .quit and .exit
TRint: mention .?
TApplication: mention .? and CINT 2 Cling

* clarify class name with ROOT7
2022-03-15 11:29:03 +01:00
Javier Lopez-Gomez
9d09611d77 TransactionUnloader: ensure function instantiations are processed only once
Implicit instantiation of a function template calls
`DeclCollector::HandleCXXImplicitFunctionInstantiation()`, which appends the
FunctionDecl to the transaction.  According to clang documentation, the body of
the function has not yet been instantiated. `HandleTopLevelDecl()` will be
called again for this decl at the end of the TU, which will append it
again to the transaction - same `Decl *`, different ConsumerCallInfo.

This is by design. However, unloading of decls in the transaction should
not process the same `Decl *` twice. In particular, entries with ConsumerCallInfo
== `kCCIHandleCXXImplicitFunctionInstantiation` will omitted.

Fixes issue #9850.
2022-03-03 18:29:03 +01:00
Javier Lopez-Gomez
2ec73dd62a DeclUnloader: reset the anonymous namespace in the enclosing DC
From SemaDeclCXX.cpp:
```
C++ [namespace.unnamed]p1.  An unnamed-namespace-definition behaves as if it
were replaced by
     namespace unique { /* empty body */ }
     using namespace unique;
     namespace unique { namespace-body }
where all occurrences of 'unique' in a translation unit are replaced by the same
identifier and this identifier differs from all other identifiers in the entire
program.
```

Thus, the first declaration of an unnamed namespace creates an implicit
UsingDirectiveDecl that makes the names available in the parent DC.

If we are reverting such first declaration, make sure we reset the anonymous
namespace for the parent DeclContext so that the implicit UsingDirectiveDecl
is created again when parsing the next anonymous namespace.

Fixes issue #7483.
2022-03-01 12:59:03 +01:00
Axel Naumann
b651b2bdb4 DynamicLibraryManagerSymbol.cpp formatting (NFC). 2022-02-24 18:14:07 +01:00
Axel Naumann
1eceb4880a realpath: add continue back, fixing https://github.com/root-project/root/pull/9911
(cherry picked from commit 573e70bf979a764ec2221eecb3db5b87bea2dad6)
2022-02-23 09:29:06 +01:00
Javier Lopez-Gomez
e9474a2fc9 ValuePrinter: minor readability improvement 2022-02-22 17:59:04 +01:00
Javier Lopez-Gomez
ba4ece8f3d ValuePrinter: for auto decls, we should use the deduced type
Value printing an expression of type `AutoType` ended up in calling the general
fallback `printValue(const void *)`.
To call the appropriate overload, the deduced type should be used instead.

Fixes ROOT-9687.
2022-02-22 17:59:04 +01:00
Vassil Vassilev
96fccb8e76 Do not alter the llvm::Module when running the static inits.
This change was from MCJIT times and now is not needed anymore. Moreover, the
orcv2 jit infrastructure considers the llvm::Module immutable after it takes
control of it via emitModule. This change will allow us to migrate easier to
orcv2.
2022-02-18 10:14:08 +01:00
Axel Naumann
c20559d390 Do not skip hidden directories:
path elements starting with "." should not be ignored, only "./" itself.
Fixes issue #9697.
2022-02-17 09:59:03 +01:00
Jonas Rembser
a6e4261e51 Remove unused variables to fix build warnings on mac11arm 2022-02-15 14:59:08 +01:00
Javier Lopez-Gomez
1ebe5a8c91 Minor readability/aesthetic changes
Co-authored-by: Axel Naumann <Axel.Naumann@cern.ch>
2022-02-11 01:59:05 +01:00
Javier Lopez-Gomez
0d71789370 Diagnose shadowing of decls in the std namespace
Related to the discussion in ROOT-5971 (see https://sft.its.cern.ch/jira/browse/ROOT-5971),
this commit improves the situation by diagnosing the shadowing of declarations
in the `std` namespace.

In summary, given that ROOT issues an implicit `using namespace std;` and due to
the way `SemaLookup` works, decls that shadow something in the `std` namespace
cannot be referenced without using their fully-qualified name, i.e. `::xxx`.
Thus, we need to emit a warning for that case.
2022-02-11 01:59:05 +01:00
Javier Lopez-Gomez
2e500a3fb8 Add Interpreter::m_InputFlags
This member provides additional information about the context in which parsing
occurs.
In particular, the `kInputFromFile` and `kIFFLineByLine` flags allow to tell
whether a sequence of calls to `Interpreter::process()` is issued from
`MetaProcessor::readInputFromFile()` for the contents of an external file.
2022-02-11 01:59:05 +01:00
Javier Lopez-Gomez
56ec372a51 Extracted decls should be unconditionally moved to the parent DeclContext
Declarations extracted by DeclExtractor, regardless of their type, should be
moved to the parent declaration context (be it the `TranslationUnitDecl` or a
`NamespaceDecl` if DefinitionShadower is enabled).

This prevents the following situation:
```
root [] struct X {} foo
(struct X &) @0x7f545a5ff018
root [] .stats asttree
|-NamespaceDecl 0x5647ecc93780 <<invalid sloc>> <invalid sloc> __cling_N50 inline
| |-VarDecl 0x5647ecc89f10 <ROOT_prompt_0:1:1, col:13> col:13 used foo 'struct X':'X' callinit
| | `-CXXConstructExpr 0x5647ecc8a420 <col:13> 'struct X':'X' 'void () noexcept'
| `-FunctionDecl 0x5647ecc89bc8 <input_line_8:1:1, ROOT_prompt_0:3:1> input_line_8:1:6 __cling_Un1Qu30 'void (void *)'
...
|-CXXRecordDecl 0x5647ecc89c98 <line:1:1, col:11> col:8 struct X definition
```
2022-02-05 03:59:07 +01:00
Javier Lopez-Gomez
b20c0fba6c Make enumerators in a scopeless enum visible in the enclosing scope
A bug in DeclExtractor was preventing names introduced by an anonymous scopeless
enum to become available in the parent scope.

Fixes ROOT-6095.
2022-02-03 09:29:03 +01:00
Javier Lopez-Gomez
9ea7dd97e3 Add MetaProcessor::awaitingMoreInput()
`MetaProcessor::awaitingMoreInput()` returns whether the collected input is
incomplete, either because it contains unbalanced braces or we found a
backslash-newline (the last seen token is a `\`).

Part of a patch series to fix ROOT-5219.

Co-authored-by: Axel Naumann <Axel.Naumann@cern.ch>
2022-01-31 19:29:04 +01:00
Javier Lopez-Gomez
71cbd0a80e Add InputValidator::getLastResult() member function
`InputValidator::getLastResult()` returns the validation result of the last call
to `validate()`.
This will be used to implement `MetaProcessor::awaitingMoreInput()`.

Part of a patch series to fix ROOT-5219.
2022-01-31 19:29:04 +01:00
Javier Lopez-Gomez
288488c35b Revert "[cling] Enable -Wredundant-parens"
This reverts commit eb52895d22aaad0a88d47b8e7bb18c7f47ff35be.

As discussed, we should try to make clang parse input containing solely a
function-style cast (e.g. `bool(i)`) as an expression instead of a declaration.

In the interim, this patch is reverted to silence unwanted warnings in
third-party code.
The PR https://github.com/root-project/root/pull/9695 will also be closed.
2022-01-26 16:14:05 +01:00
Jonas Hahnfeld
b8d15115a3 Fix AutoSynthesizer on CXXTryStmt (#9691)
This was an oversight in commit 34590aeef4: After fixing the handler
blocks, the code needs to create new CXXCatchStmts to eventually
construct the CXXTryStmt.

Fixes #9664
2022-01-26 14:44:08 +01:00
Axel Naumann
5440500f0b Only add NullPtrChk if enabled. 2022-01-26 10:29:05 +01:00
Axel Naumann
c6dcc185a8 With O1 being default, also set NDEBUG. 2022-01-13 17:59:04 +01:00
Axel Naumann
c0eed39bfe Remove backtrace on invalid ptr:
As the JIT does not provide debug symbols (yet), users see
only the call frames invoking the JIT - which is not helpful
as it is unrelated to their code.

We can turn this back on (possibly restricting to JIT frames)
once we emit debug symbols in the JIT.
2022-01-12 09:29:04 +01:00
Axel Naumann
9154e98478 Introduce --ptrcheck, disabled by default:
With more focus on performance of cling, disable the pointer check by default.
Can be enabled by passing --ptrcheck to the invocation / construction.
2022-01-11 18:29:04 +01:00
Axel Naumann
bd4b710e6a Complain about __cling__ptrcheck not being on or off. 2022-01-11 18:29:04 +01:00
Vassil Vassilev
4fa39ba82f Do not resolve symbols from executables compiled with -fPIE.
Executables that are compiled with fPIE means they are compiled in a position
independent manner and are almost indistinguishable from the shared objects. A
reasonably reliable way to find if this was a `pie executable` is to check the
`DF_1_PIE` in the dynamic section of ELF.

The pseudo-code is:
```
if DT_FLAGS_1 dynamic section entry is present
  if DF_1_PIE is set in DT_FLAGS_1:
    print pie executable
  else
    print shared object
```

See https://stackoverflow.com/questions/34519521/why-does-gcc-create-a-shared-object-instead-of-an-executable-binary-according-to/34522357#34522357

Fixes root-project/root#7366

Patch by Alexander Penev (@alexander-penev)
2022-01-07 16:29:03 +01:00
Jonas Hahnfeld
29d368ec6b Implement -mllvm for option passing to LLVM 2021-12-02 08:29:08 +01:00
Jonas Hahnfeld
f4641c0cb0 Remove unused CUDAFatbinaryArgs 2021-12-02 08:29:08 +01:00
Karel Balej
c1a6a8a634 concretize condition 2021-11-23 10:44:03 +01:00
Axel Naumann
517d7e4bca Revert "[cxxmodules] Enable a module if json is present."
This reverts commit 0cdfa69f216854d7319a6a31a61021a1e5ac45de.
We need to hide json includes: modules cannot cope with them, and it introduces a runtime requirement to find json.
2021-11-12 16:29:06 +01:00
Axel Naumann
a860c891d4 EvaluateInternal: capture ValuePrinting request early:
`RunFunction()` might trigger unloading of `lastT`, so store its setting
for "want value printing" in a local variable before calling RunFunction().

Fixes valgrind complaining about `./stressInterpreter` which is reloading
the "outer" stressInterpreter.cxx from inside `RunFunction()`.
2021-11-12 16:14:06 +01:00
Axel Naumann
3afd3b4056 ReuseExistingWeakSymbols: prevent stale symbol emission:
When determining whether a weak symbol was already emitted (and its
subsequent definition can thus be replaced by a declaration) look
for emitted symbols in the symbol table and the in-process symbols,
instead of possibly generating symbols through the JIT. This prevents
symbols being emitted that refer into
IncrementalExecutor::m_PendingModules elements that have since been
removed.
2021-11-12 16:14:06 +01:00
Axel Naumann
234772da1c Prevent traling whitespace in -isystem. 2021-11-12 16:14:06 +01:00
Axel Naumann
9fb41f09f0 Let opt of transaction decide on inlining, fixes O3. 2021-11-12 16:14:06 +01:00
Vassil Vassilev
605924e143 Enable a module if json is present. 2021-11-06 08:14:07 +01:00
Javier Lopez-Gomez
9eef0a1354 Remove unneed assert()
The case of `ExprAddresses == nullptr` seems to be naturally handled in the
lines below. Therefore, removing this assertion -as discussed with vvassilev.

Closes issue #8389.
2021-11-04 19:29:05 +01:00
Axel Naumann
9a8996f714 Remove llvm_unreachable:
This is now hit for variables on Windows (which don't see the GlobalVariable case).
Before the `#ifndef WIN32`, this case was not hit by roottest, neither on Windows
nor macOS nor Linux - so the coverage of "make it a declaration" is good.
2021-10-14 15:14:05 +02:00
Axel Naumann
00bbb8e081 Windows: always emit definitions of JITed "weak" variables
Fixes test failures (crashes) in
    projectroot.test.test_stressiterators_interpreted
    projectroot.roottest.cling.dict.roottest_cling_dict_assertTmpltDefArgCtor
    projectroot.test.test_stresshistogram_interpreted
    projectroot.roottest.root.meta.roottest_root_meta_runnamespace_auto
2021-10-14 15:14:05 +02:00
Axel Naumann
11d203f55d Do not emit existing weak symbols:
Instead of suppressing the emission of weak symbols that have an existing
in-process definition, remove the definition of the weak symbol from the
module. This prevents relocation "surprises" as seen e.g. on Apple M1, where
weak symbol definitions are expected to be found within the module, and
relocations are thus expected to be local. By removing the definition, the
symbol becomes a reference (declaration) and relocation will work as for any
non-local symbol.

Thus also reduces the amount of duplicate work, as in-process weak symbols
will now be suppressed early.
2021-10-14 15:14:05 +02:00
Axel Naumann
fe70a6fe6e getSymbolAddressWithoutMangling() already handles injected syms and dlsym. 2021-10-14 15:14:05 +02:00
Bertrand Bellenot
027b698255 Add the _MSC_VER value for Visual Studio 2022
Add the _MSC_VER value (between 1930 and 1940) for the coming soon `Visual Studio 2022`
2021-10-05 14:59:03 +02:00
Vassil Vassilev
9c22d6ef0e Complain if glibc is not installed.
Likely will improve root-project/root#8157
2021-10-04 14:44:06 +02:00
Javier Lopez-Gomez
dd1a74f009 Enable replacement of the default diagnostic consumer
These changes enable the replacement of the default DiagnosticConsumer provided
by CIFactory.  Concretely, two member functions have been added to the
Interpreter class:

- replaceDiagnosticConsumer(): replaces the default CIFactory-provided DiagnosticConsumer.

- hasReplacedDiagnosticConsumer(): returns whether the default diagnostic
consumer has been replaced.
2021-09-09 14:59:06 +02:00
Javier Lopez-Gomez
a8a3db4611 Cleanup MetaLexer; remove unused LexPunctuatorAndAdvance() 2021-09-08 19:14:06 +02:00
Javier Lopez-Gomez
e2d44c31a3 Rewrite of InputValidator::validate()
Replace implementation of `InputValidator::validate()` by simpler, more
maintainable code that also fixes ROOT-9202.

The previous implementation was unable to properly handle line continuation
after ',' or '\'.  Specifically, it skipped over non-punctuation tokens,
entering continuation mode even if ',' or '\' were not the last tokens in the
input, e.g. `int a, b` or 'int a \      b'.

Fixes ROOT-9202.
2021-09-08 19:14:06 +02:00
Javier Lopez-Gomez
41f3ed6c97 MetaLexer: return /* and */ as tokens; added ReadToEndOfLine()
This commit includes the following changes to MetaLexer:
- Update `MetaLexer::Lex()` to return `/*` (tok::l_comment), `*/` (tok::r_comment),
and `<` (tok::less) as tokens.

- Added `MetaLexer::ReadToEndOfLine()` function: consume input until `\r` or `\n`.

- Added `MetaLexer::RAII`, a RAII object that saves/restores the current position.
2021-09-08 19:14:06 +02:00
Vassil Vassilev
d78d1a03fe Fix building ROOT with external llvm.
Fixes #8141.
2021-08-17 10:29:05 +02:00
Axel Naumann
10180ae79f On Win, do not always-append to cling-compiledata.h.in:
Before, cling-compiledata.h caused
```
interpreter\cling\lib\Interpreter\cling-compiledata.h(6,1): warning C4005: 'CLING_UCRT_VERSION': macro redefinition
  interpreter\cling\lib\Interpreter\cling-compiledata.h(3): message : see previous definition of 'CLING_UCRT_VERSION'
```
due to it containing
```

      #define CLING_INCLUDE_PATHS ""
      #define CLING_UCRT_VERSION  ""
      #define CLING_INCLUDE_PATHS ""
      #define CLING_UCRT_VERSION  "10.0.19041.0"
```
2021-08-10 12:29:07 +02:00
Vassil Vassilev
276a46bcfa Silence warning ignoring return value of readlink. 2021-08-07 09:29:07 +02:00
Vassil Vassilev
d36bfe15e4 Ask for the real path in any case. 2021-08-07 09:29:07 +02:00
Vassil Vassilev
55a4e89b3b Fix ROOT-10484 by implementing dyld support for RPATH.
Some libraries are layered can depend on other libraries on a private paths.
That is, libA can depend on libB which is neither on the LD_LIBRARY_PATH nor
on a known system path. The posix linker injects "variables" such as @rpath
which is expanded at link time to resolve the libraries on a relative path.

Prior to this patch, cling's Dyld-based symbol resolution could not trace down
such cases causing failures in symbol resolution when a symbol is only defined
in libB (a private library).

This patch implements the basic posix linker substitutions allowing cling's
Dyld-based symbol resolution implementation to follow more closely the linker
rules.

Kudos Alexander Penev (@alexander-penev).
2021-08-07 09:29:07 +02:00
Vassil Vassilev
03e02c57bb Fix regression in #pragma cling add_library_path().
This regression was introduced by root-project/root@561e905b where we stopped
iterating, on every lookup, over the -L paths passed at start up.

This patch adds the path to the search paths of the DynamicLibraryManager
rather than to the invocation options.
2021-08-07 09:29:07 +02:00
Bertrand Bellenot
95ab06f44d Replace the __CUDACC__ preprocessor macro by _HAS_CONDITIONAL_EXPLICIT=0
The `__CUDACC__` preprocessor define macro is not needed anymore (thanks to Axel), but the `_HAS_CONDITIONAL_EXPLICIT=0` one still is.
2021-07-12 17:59:07 +02:00
Bertrand Bellenot
8d5ab809ec Use C++ syntax (and not the CMake one) 2021-07-12 17:59:07 +02:00
Bertrand Bellenot
901018c7fd Disable the __CUDACC__ macro definition with latest Visual Studio
Disable the silly workaround for cling not being able to parse the STL headers anymore after the update of Visual Studio v16.7.0. Works now with the upgrade of LLVM and Visual Studio 16.10.3.
This workaround had side effects when trying to use code supporting CUDA (e.g. boost) inside the interpreter.
2021-07-12 17:59:07 +02:00
Javier Lopez-Gomez
4f714ac55b Enable -Wredundant-parens
Warn on redundant parentheses in declarators whose parsing might not match
the user intent, e.g.
```
root [0] int i = 1;
root [1] (bool)i
(bool) true
root [2] bool(i)
ROOT_prompt_1:1:5: warning: redundant parentheses surrounding declarator [-Wredundant-parens]
bool(i)
    ^~~
(bool) false
```

For more information see http://github.com/root-project/issues/8304.
Closes issue #8304.
2021-07-09 11:59:03 +02:00
Axel Naumann
2d948ebcff Also fwd decl underlying type of using decls:
Before, only the using decl itself was forward declared, causing
undeclared identifiers in forward declaration code, as witnessed in
https://github.com/root-project/root/issues/8499

Given the similarity of using and typedef, merge both into a single
function, making sure both have the same featureset, and through that
fixing this issue as a side-effect.
2021-06-23 10:14:05 +02:00
Mattias Ellert
35259e725a Actually request the use of the large code model for ppc64/ppc64le
Instead of erroring out with an assert.
2021-05-26 10:44:02 +02:00
Axel Naumann
bb143fbd2f Remove symbols explicitly exported through CLING_EXPORT. 2021-05-25 16:29:06 +02:00
Axel Naumann
3bd3ff18cb Make sure required symbols are exported:
and use a standard mechanism that plays well with -fvisibility.
Given that several symbols now use declspec(dllexport), remove them from
the ad-hoc cling_exports in ROOT's CMakeLists.txt.
2021-05-25 16:29:06 +02:00
Axel Naumann
fc5b3e6f16 Silence GCC 4.8 / CentOS7 warnings:
cling/include/cling/Interpreter/LookupHelper.h:61:69: warning: missing initializer for member ‘std::array<const clang::Type*, 4ul>::_M_elems’ [-Wmissing-field-initializers]
     std::array<const clang::Type*, kNumCachedStrings> m_StringTy = {};
                                                                     ^
2021-05-21 09:44:08 +02:00
Javier Lopez-Gomez
668dfdcc7f cleanup MetaSema.cpp
Additionally, this commit extends the behavior of `.x`. Specifically, it adds
support for a list of function names whose execution will be tried in order.

To be compliant with the old behavior, this list currently only includes an
entry that matches the macro filename.
2021-05-12 17:59:06 +02:00
Vassil Vassilev
561e905b24 Use the dyld to show more meaningful message when a symbol is missing.
The dynamic library manager's dyld can search a symbol in the library path.
This patch uses that functionality to aid the 'unresolved while linking'
diagnostics.

Now we get:

cling -L lib/

****************** CLING ******************
* Type C++ code and press enter to run it *
*             Type .q to exit             *
*******************************************
[cling]$ extern int gErrorIgnoreLevel;
[cling]$ gErrorIgnoreLevel
IncrementalExecutor::executeFunction: symbol 'gErrorIgnoreLevel' unresolved while linking [cling interface function]!
Symbol found in '/.../lib/libCore.so'; did you mean to load it with .L /.../lib/libCore.so ?
[cling]$
2021-05-08 20:59:07 +02:00
Vassil Vassilev
74f74a7d0b Remove the include to IncrementalExecutor.
This exposed a set of missing includes and constructors to destroy the
backend passes.
2021-05-08 20:59:07 +02:00
Vassil Vassilev
d466a98e30 Consider only dll files to be shared libraries.
This avoids problems where we consider other executables and object files as
libraries and the dyld decides to scan them. Upon this we hit files opened by
other processes and locked by the system (such as bootstat.dat :))

Thanks to Bertrand Bellenot for the diagnosis!
2021-05-08 20:59:06 +02:00
Axel Naumann
db2c5de3f2 Lifetime of MetaParser is that of its input:
Before, MetaParser might have pointed to a StringRef whose storage
was gone, see asan failure in roottest/cling/other/runfileClose.C below.

This was caused by recursive uses of MetaParser; see stack trace below:
the inner recursion returned, but as the same MetaParser object was used
by both frames, the objects cursor now pointed to freed memory.

Instead, create a MetaParser (and MetaLexer) object per input. That way,
their lifetime corresponds to the lifetime of their input.

=================================================================
==529104==ERROR: AddressSanitizer: stack-use-after-return on address 0x7ffff3afd82a at pc 0x7fffea18df6d bp 0x7fffffff8170 sp 0x7fffffff8168
READ of size 1 at 0x7ffff3afd82a thread T0
[Detaching after fork from child process 529183]
    #0 0x7fffea18df6c in cling::MetaLexer::Lex(cling::Token&) src/interpreter/cling/lib/MetaProcessor/MetaLexer.cpp:58:11
    #1 0x7fffea190d7c in cling::MetaParser::lookAhead(unsigned int) src/interpreter/cling/lib/MetaProcessor/MetaParser.cpp:89:15
    #2 0x7fffea190bd5 in cling::MetaParser::consumeToken() src/interpreter/cling/lib/MetaProcessor/MetaParser.cpp:49:5
    #3 0x7fffea191d4d in cling::MetaParser::isLCommand(cling::MetaSema::ActionResult&) src/interpreter/cling/lib/MetaProcessor/MetaParser.cpp:147:9
    #4 0x7fffea1914dd in cling::MetaParser::isCommand(cling::MetaSema::ActionResult&, cling::Value*) src/interpreter/cling/lib/MetaProcessor/MetaParser.cpp:123:12
    #5 0x7fffea191216 in cling::MetaParser::isMetaCommand(cling::MetaSema::ActionResult&, cling::Value*) src/interpreter/cling/lib/MetaProcessor/MetaParser.cpp:101:33
    #6 0x7fffea14e5aa in cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) src/interpreter/cling/lib/MetaProcessor/MetaProcessor.cpp:317:24
    #7 0x7fffe99b67b7 in HandleInterpreterException(cling::MetaProcessor*, char const*, cling::Interpreter::CompilationResult&, cling::Value*) src/core/metacling/src/TCling.cxx:2431:29
    #8 0x7fffe99bde30 in TCling::Load(char const*, bool) src/core/metacling/src/TCling.cxx:3454:10
    #9 0x7ffff7865f11 in TSystem::Load(char const*, char const*, bool) src/core/base/src/TSystem.cxx:1941:27
    #10 0x7ffff7b8a0e3 in TUnixSystem::Load(char const*, char const*, bool) src/core/unix/src/TUnixSystem.cxx:2789:20
    #11 0x7fffd78dd08b  (<unknown module>)
    #12 0x7fffe9f8a5d9 in cling::IncrementalExecutor::executeWrapper(llvm::StringRef, cling::Value*) const src/interpreter/cling/lib/Interpreter/IncrementalExecutor.cpp:376:3
    #13 0x7fffe9d73dc2 in cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) src/interpreter/cling/lib/Interpreter/Interpreter.cpp:1141:20
    #14 0x7fffe9d6e317 in cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) src/interpreter/cling/lib/Interpreter/Interpreter.cpp:1391:29
    #15 0x7fffe9d6c1fe in cling::Interpreter::process(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::Value*, cling::Transaction**, bool) src/interpreter/cling/lib/Interpreter/Interpreter.cpp:819:9
    #16 0x7fffea151826 in cling::MetaProcessor::readInputFromFile(llvm::StringRef, cling::Value*, unsigned long, bool) src/interpreter/cling/lib/MetaProcessor/MetaProcessor.cpp:507:22
    #17 0x7fffe99b585b in TCling::ProcessLine(char const*, TInterpreter::EErrorCode*) src/core/metacling/src/TCling.cxx:2570:39
    #18 0x7fffe99bbfee in TCling::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) src/core/metacling/src/TCling.cxx:3496:17
    #19 0x7ffff77203d3 in TApplication::ExecuteFile(char const*, int*, bool) src/core/base/src/TApplication.cxx:1608:30
    #20 0x7ffff771ebdf in TApplication::ProcessFile(char const*, int*, bool) src/core/base/src/TApplication.cxx:1480:11
    #21 0x7ffff771e385 in TApplication::ProcessLine(char const*, bool, int*) src/core/base/src/TApplication.cxx:1453:14
    #22 0x7ffff7f8157a in TRint::ProcessLineNr(char const*, char const*, int*) src/core/rint/src/TRint.cxx:766:11
    #23 0x7ffff7f802f0 in TRint::Run(bool) src/core/rint/src/TRint.cxx:424:22
    #24 0x4ff96d in main src/main/src/rmain.cxx:30:12
    #25 0x7ffff6e040b2 in __libc_start_main /build/glibc-YbNSs7/glibc-2.31/csu/../csu/libc-start.c:308:16
    #26 0x41f35d in _start (asan/bin/root.exe+0x41f35d)

Address 0x7ffff3afd82a is located in stack of thread T0 at offset 42 in frame
    #0 0x7fffe99b3d8f in TCling::ProcessLine(char const*, TInterpreter::EErrorCode*) src/core/metacling/src/TCling.cxx:2456

  This frame has 21 object(s):
    [32, 56) 'sLine' (line 2462) <== Memory access at offset 42 is inside this variable
    [96, 104) 'R__guard2471' (line 2471)
    [128, 136) 'R__guard2488' (line 2488)
    [160, 176) 'interpreterFlagsRAII' (line 2491)
    [192, 240) 'result' (line 2511)
    [272, 276) 'compRes' (line 2512)
    [288, 312) 'mod_line' (line 2517)
    [352, 376) 'aclicMode' (line 2518)
    [416, 440) 'arguments' (line 2519)
    [480, 504) 'io' (line 2520)
    [544, 568) 'fname' (line 2521)
    [608, 632) 'ref.tmp' (line 2547)
    [672, 696) 'ref.tmp145' (line 2547)
    [736, 768) 'code' (line 2555)
    [800, 832) 'codeline' (line 2556)
    [864, 1384) 'in' (line 2559)
    [1520, 1552) 'ref.tmp176' (line 2562)
    [1584, 1600) 'agg.tmp'
    [1616, 1624) 'ref.tmp198' (line 2568)
    [1648, 1664) 'agg.tmp207'
    [1680, 1696) 'autoParseRaii' (line 2588)
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-use-after-return src/interpreter/cling/lib/MetaProcessor/MetaLexer.cpp:58:11 in cling::MetaLexer::Lex(cling::Token&)
Shadow bytes around the buggy address:
  0x10007e757ab0: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
  0x10007e757ac0: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
  0x10007e757ad0: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
  0x10007e757ae0: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
  0x10007e757af0: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
=>0x10007e757b00: f5 f5 f5 f5 f5[f5]f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
  0x10007e757b10: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
  0x10007e757b20: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
  0x10007e757b30: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
  0x10007e757b40: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
  0x10007e757b50: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==529104==ABORTING

    at src/interpreter/cling/lib/MetaProcessor/MetaLexer.cpp:49
    at src/interpreter/cling/lib/MetaProcessor/MetaParser.cpp:41
    compRes=@0x7ffff3afd910: cling::Interpreter::kSuccess, result=0x7ffff3afd8c0, disableValuePrinting=false)
    at src/interpreter/cling/lib/MetaProcessor/MetaProcessor.cpp:314
    input_line=0x7ffff3afd829 "#define XYZ 21", compRes=@0x7ffff3afd910: cling::Interpreter::kSuccess,
    result=0x7ffff3afd8c0) at src/core/metacling/src/TCling.cxx:2431
    error=0x7fffd78cb0f4 <x>) at src/core/metacling/src/TCling.cxx:2591
    sync=false, err=0x7fffd78cb0f4 <x>) at src/core/base/src/TApplication.cxx:1472
    line=0x7fffd78c9000 "#define XYZ 21", error=0x7fffd78cb0f4 <x>)
    at src/core/base/src/TROOT.cxx:2328
   from asan/roottest/cling/other/fileClose_C.so
    filename=0x6070000f0fd0 "asan/roottest/cling/other/fileClose_C.so", flag=257)
    at /home/axel/build/llvm/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:6270
    at src/interpreter/cling/lib/Utils/PlatformPosix.cpp:118
    permanent=false, resolved=true)
    at src/interpreter/cling/lib/Interpreter/DynamicLibraryManager.cpp:184
    at src/interpreter/cling/lib/Interpreter/Interpreter.cpp:1444
    T=0x0) at src/interpreter/cling/lib/Interpreter/Interpreter.cpp:1560
    at src/interpreter/cling/lib/MetaProcessor/MetaSema.cpp:57
    actionResult=@0x7ffff39532b0: cling::MetaSema::AR_Success)
2021-05-05 09:44:04 +02:00
Vassil Vassilev
682b7b9505 Reimplement HandleInvalidTagDeclDefinition without clang support.
See https://reviews.llvm.org/D92248
2021-05-03 19:29:03 +02:00
Axel Naumann
7a35c2ddbc LookupHelper: suppress diags from adding templt funcs:
Sema::AddTemplateOverloadCandidate() can issue diagnostics as part of the
template instantiation it performs. The LookupHelper just wants to know
whether there is a matching function, which is similar to a SFINAE context
and a good reason to silence potential diagnostics if asked to do so!

Do get there, simple increase the scope of the setSuppressAllDiagnostics()
calls, and make it an RAII for robustness.
2021-04-27 11:29:05 +02:00
Jonas Hahnfeld
fd2212c84e Create new CompoundStmt instead of replacing children
For the update of LLVM 9, Cling required another patch to Clang for
replacing the children of a CompoundStmt. Instead solve this by
creating a new CompoundStmt with the right Stmts attached.

Co-authored-by: Jonas Hahnfeld <Hahnfeld@itc.rwth-aachen.de>
Co-authored-by: Jonas Hahnfeld <hahnjo@hahnjo.de>
2021-04-23 09:29:06 +02:00
Jonas Hahnfeld
e13eff3119 Skip recursive visits in EvaluateTSynthesizer
As Node is still a CompoundStmt, this will call the same function
recursively and again visit all previously visited and replaced
children, which doesn't seem necessary.
2021-04-23 09:29:06 +02:00
Jonas Hahnfeld
9e43996a41 Set full target for Apple M1 (#7787)
The argument -Xclang -triple=... completely bypasses Clang's Driver
logic and only sets the triple in CC1. This suffices for most code
generation tasks, but the Driver cannot compute the correct ABI and
sets the generic AArch64 "aapcs" instead of the specific "darwinpcs".
In turn, this causes integer arguments with less than 32 bits not
being sign-extended but being passed directly, which for example
manifests as (short)-1 being read as 65535 on the callee side.

The new argument --target=arm64-apple-darwin20.3.0 matches what
Apple's and LLVM main's clang return for --print-target-triple.

Fixes #7090
2021-04-06 17:29:06 +02:00
Axel Naumann
9432fb6582 LookupHelper must not unload Transactions:
Outer RAIIs might still reference the Transaction, and unload is
assuming that it owns the transaction and can delete it / put it
into the TransactionPool.

This fixes https://github.com/root-project/root/issues/7657

We still need to track ownership as what has happened here (unload
of a Transaction held by an RAII) can happen again / elsewhere.
This will be addressed by a subsequent PR in master.
2021-04-06 00:14:05 +02:00
Axel Naumann
4edb1ed0f2 Assert released transaction is != last in pool:
a cheap way to notice what went wrong in https://github.com/root-project/root/issues/7657.
2021-04-06 00:14:05 +02:00
Axel Naumann
2555c8f542 Remove historical leftover in TransactionPool size (NFC). 2021-04-06 00:14:05 +02:00
Axel Naumann
8b80e83595 Assert that no nested attaches to unloading Transaction. 2021-04-06 00:14:05 +02:00
Axel Naumann
db8d306106 Fix alignment of Transaction allocation:
new of a char array might not have the correct alignment to hold a Transaction.
Allocate a Transaction itself directly, instead of in-place constructing it in
the character array.

Each Transaction in the pool is thus constructed through `new Transaction(S)`
and destructed through `delete T`, which is nicely symmetrical. The use of
`::operator new` and `::operator delete` isn't actually necessary.

While I'm at it, improve the assert message's wording.
2021-04-06 00:14:05 +02:00
Vassil Vassilev
0a3384a342 Remove comment, clarify intent. 2021-04-02 08:59:05 +02:00
Axel Naumann
cfc6f86de1 Throw less exceptions on Apple M1:
As llvm JIT cannot catch exceptions on Apple M1 (see
https://github.com/root-project/root/issues/7541) cling
should throw less. This is a hack to reduce the impact
a bit.
2021-03-31 15:29:04 +02:00
Vassil Vassilev
a89bbcbb04 Do not bind cling's sysroot to a particular version of osx sdk.
The CMAKE_OSX_SYSROOT exports the exact version of the sdk which we build
against. However, this means that binary releases become sensitive to minor sdk
upgrades (eg. MacOSX11.1.sdk -> MacOSX11.2.sdk). Our infrastructure is
relatively resilient to such changes.

This patch introduces a workaround to address this issue -- it uses the fact
that the current sdk's parent directory has a symlink MacOSX.sdk which points
to the current sdk.

This should resolve root-project/root#7021.
2021-03-21 21:59:03 +01:00
Axel Naumann
2b1af22926 In failed lookup, unload only decls produced, not existing fwd decl:
Before, pre-existing fwd decls of specializations got unloaded.

OTOH, any decl produced during (failed) template instantiation must
also be unloaded; see #6331. Those are easiest identified by unloading
the whole (failed) transaction.

```
error: no member named 'value' in 'std::__and_<std::is_copy_assignable<std::__cxx11::basic_string<char> >, std::is_copy_assignable<Inner<int> > >'
                       is_copy_assignable<_T2>>::value,
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~^
```

which is due to the first decl being invalid (as `Inner<int>` does not have a deinition and a `static_assert` /usr/lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/type_traits:1093 being triggered), then not unloaded, and then picked up again where we *do* have the definition for `Inner<int>`.

Add test for templt spec lookup vs unloading.
2021-03-18 19:59:03 +01:00
Axel Naumann
9ca9606a74 PushTransactionRAII: do not commit broken transactions:
There is no point in emitting a transaction that has been rolled back to
CodeGen. To make matters worse, a rolled-back transaction will not show up
in the list of transactions.
2021-03-18 19:59:03 +01:00
Axel Naumann
e66ea9ad58 Allow unloading of Transactions that have not been committed:
If Lookup fails to instantiate, its transaction should not be committed,
as we know it's useless and must be unloaded as it might contain invalid
Decls.
But that means Lookup needs to unload a non-committed transaction.
2021-03-18 19:59:03 +01:00
Axel Naumann
2fc0a3c5c4 Skip non-regular files to find dylibs:
To determine the file magic, the file needs to be opened and read.
This is done with *each* file in $LD_LIBRARY_PATH, including ./
If one of them is e.g. a FIFO then reading blocks until someone
writes into the FIFO, which might cause the process to hang. This
was reported a couple of times, such as at https://root-forum.cern.ch/t/compiling-from-source-first-interactive-command-hangs/43997/5

Solution: only check for the file magic of *regular* files.

Sadly, llvm::sys::fs::get_file_type never sets file_not_found but
returns an unspecific status_error.
2021-03-18 19:44:06 +01:00
Axel Naumann
81b683bf1d When injecting symbols, do not rely on the last Module:
With llvm9, the module ptr gets reset upon emission.
Instead, just look for the symbol in the JIT - where it should be found,
as Init() is injecting it there, and we want to find *that* symbol,
not the one from the binary.

Fixes `CodeUnloading/AtExit.C` cling test.
2021-03-16 09:59:04 +01:00
Axel Naumann
0ae95fb193 Improve diag on #pragma load failure. 2021-03-16 09:59:03 +01:00
Jonas Hahnfeld
b38192f29f Disable GlobalISel on AArch64 (#7419)
In tests on an Apple M1 after the upgrade to LLVM 9, this new
instruction selection framework emits branches / calls that expect
all code to be reachable in +/- 128 MB. This cannot be guaranteed
during JIT, which generates code into allocated pages on the heap
and could span the entire address space of the process.
2021-03-09 21:29:04 +01:00
Axel Naumann
d1c49f4397 Put else back to handle CastExpr of DeclRefExpr 2021-03-07 00:14:03 +01:00
Axel Naumann
e0249a77d2 ForwardDeclPrinter: also log skipped types. 2021-03-07 00:14:03 +01:00
Axel Naumann
44f304c672 skipDecl if template arg cannot be fwd declared:
Fixes CMS dictionary build issue with forward declaring a template argument
of enum constant type - something we do not forward declare.
2021-03-07 00:14:03 +01:00
Axel Naumann
31cbf79eb6 A CastExpr cannot be a DeclRefExpr. 2021-03-07 00:14:03 +01:00
Simeon Ehrig
6fddcc0e42 Fix bug in cling's diagnostic engine, if CUDA mode is enable
- solves the bug, that error messages of the device compiler was
not prefixed with "cling-ptx"
2021-03-06 09:29:07 +01:00
Axel Naumann
7c83a3e0ae Windows needs more symbols to be injected:
such as __dllonexit() and _onexit(). Without, static destruction
does not happen, as can be seen by roottest/cling/staticinit/execROOT-7775.C
failing to call the static destructors.
2021-02-25 20:44:19 +01:00
Javier Lopez-Gomez
b5348025ef DeclExtractor: exit early if there is nothing to do
In LLVM 9, the `CompoundStmt::replaceStmts()` call seems to write to an invalid
memory location if the body was empty. This may happen after a parse error and
might end up corrupting the program state.

This patch makes `DeclExtractor` to exit early if there is nothing to do, which
solves the aforementioned problem.
2021-02-25 20:44:19 +01:00
Vassil Vassilev
dad7ed462e removeRedeclFromChain is a template static. Fixes osx warning. 2021-02-25 20:44:19 +01:00
Vassil Vassilev
f2e5f43acf Fix warnings about the ignored quals. 2021-02-25 20:44:19 +01:00
Simeon Ehrig
be5ea3a651 Fixed CUDA mode for Clang/LLVM 9 upgrade
- fix bug, which was caused by executing a transaction in the device
interpreter
- fixed warning from the device compiler
- update test cases
2021-02-25 20:44:19 +01:00
Vassil Vassilev
84bcd07963 Add a module for Vc.
This should fix a problem where the ClingTest unit test fails due to the fact
that std::vector is copied and delivered by Vc pulling a wrong dependency.
2021-02-25 20:44:19 +01:00
Vassil Vassilev
fedeedc2cd Improve "[cling] DefinitionShadower: allow shadowing of non-user-defined declarations (#6571)"
The patch applies a patch to remove duplicated entries from the StoredDeclsList.
Apparently, reading a yet-to-be-determined PCM file adds the same `Decl *` to
the lookup table. Trying to remove it using `StoredDeclsList::remove()` makes
an internal assertion to fail, as it expects the Decl to disappear from the
lookup table after being removed.

So far, `darwin.pcm` seems like one of the possible causes of this problem, but
more investigation is needed.
2021-02-25 20:44:18 +01:00
Axel Naumann
74e4407225 Unload even if no T->module:
Modules are constructed lazily; not having one still means
DeferredDecls need to be unloaded. This fixes stressInterpreter.
2021-02-25 20:44:18 +01:00
Axel Naumann
400f7c7ffb Remove pseudo-conditional / simplify (NFC). 2021-02-25 20:44:18 +01:00
Axel Naumann
eac42c613b Reset Sema::CurContext to TU before auto-import:
Sema create an ImportDecl, and that should not end up e.g. inside
a class definition, or wherever else the "autoparsing" was triggered.
Fixes roottest-root-meta-assertVarOffset.

(cherry picked from commit 4d8fcf0984118663a356d462eeec6cb6c34ebfef)
2021-02-25 20:44:18 +01:00
Axel Naumann
02ec8bf986 Only JIT symbols that are unavailable:
fixes CodeGeneration/Symbols.C
2021-02-25 20:44:18 +01:00
Vassil Vassilev
0ae75bafcd cling::Transaction::Initialize does not need Sema. 2021-02-25 20:44:18 +01:00
Vassil Vassilev
a4a06e0fdf Fix warnings coming from shadowing names. 2021-02-25 20:44:18 +01:00
Vassil Vassilev
d0904c1ec2 Remove unused member from the JIT. 2021-02-25 20:44:18 +01:00
Vassil Vassilev
deafa47202 Remove unused parameters. Fixes -Wunused-parameter. 2021-02-25 20:44:18 +01:00
Vassil Vassilev
cad5c25c17 Implement -Dbuiltin_cling=Off
Cling needs to be built and installed as part of llvm/clang and
then we need to specify paths as we do for builtin_clang=Off.
2021-02-25 20:44:18 +01:00
Vassil Vassilev
b4daff130e LLVM_ON_WIN32 was dropped.
See llvm-mirror/llvm@4833be0
2021-02-25 20:44:18 +01:00
Vassil Vassilev
f66cd2585a Store the llvm::Module ptr before moving it. 2021-02-25 20:44:17 +01:00
Vassil Vassilev
fa7c45b1ca Orc JIT now takes the ownership of the llvm::Module.
The old JIT infrastructure assumed shared ownership of the llvm::Module
implemented via shared_ptr. This guaranteed each client can have a uniform
view of the llvm::Module. The new infrastructure claims ownership of the object
and even more transfer ownership when the llvm::Module travels through different
layers of the JIT. The claimed advantage is better thread safety.

The new logic defines away an important property which cling has been built
around, that is the shared symbol object ownership.

This patch makes the cling::Transaction the owner of the llvm::Module. The
ownership is transfered when we want the JIT to 'emit' the module. Fortunately,
there is a JIT callback which can transfer back the ownership to the transaction.

This preserves some consistency, however, makes some operations unsafe. For
example, we cannot rely on Transaction::getModule when the module is being
handed to the JIT.

This patch tries to adapt to the new infrastructure by reducing the dependency
on the transaction's llvm::Module in favor of relying more on the information
available in the execution engine (eg. at_exit handling).
2021-02-25 20:44:17 +01:00
Vassil Vassilev
2d1a60d163 Drop support of #pragma cling load header.h
llvm-mirror/clang@444665e219 says:
"Remove use of lookahead from _Pragma handling and from all other

internal lexing steps in the preprocessor.

It is not safe to use the preprocessor's token lookahead except when
operating on the final sequence of tokens that would be produced by
phase 4 of translation. Doing so corrupts the token lookahead cache used
by the parser. (See added testcase for an example.) Lookahead should
instead be viewed as a layer on top of the normal lexer.

Added assertions to catch any further incorrect uses of lookahead within
lexing actions."

This tells us that if we try to #include the header.h while processing the
2021-02-25 20:44:17 +01:00
Vassil Vassilev
6a66cbd1df Fix wrong asserts. 2021-02-25 20:44:17 +01:00
Vassil Vassilev
16988119ae ActOnModuleImport takes an export location.
See See llvm-mirror/clang@33eb2ff
2021-02-25 20:44:17 +01:00
Vassil Vassilev
51ce81f72e SymbolRef::getContents returns Expected<StringRef> 2021-02-25 20:44:17 +01:00
Vassil Vassilev
86c99ba57e BuildReturnStmt requires setting up a current function scope.
See llvm-mirror/clang@84b007fae6
2021-02-25 20:44:17 +01:00
Vassil Vassilev
9d168479f3 BuildCXXNew takes an llvm::Optional and passing 0 means ArraySize is 0.
See llvm-mirror/clang@5b0a110410
2021-02-25 20:44:17 +01:00
Vassil Vassilev
08d52941b2 Delegate the TargetMachine initialization to JITTargetMachineBuilder.
This fixes the uninitialized CodeModel and also is able to detect which is
the best setup for running a JIT.
2021-02-25 20:44:17 +01:00
Vassil Vassilev
ca290d04a0 Try moving cling to the new orc jit api. 2021-02-25 20:44:17 +01:00
Vassil Vassilev
dbc4d6631a first and second were renamed to getBegin and getEnd. 2021-02-25 20:44:17 +01:00
Vassil Vassilev
c9fb0ce320 The SourceLocation parameter is optional.
See llvm-mirror/clang@497bb75060
2021-02-25 20:44:17 +01:00
Vassil Vassilev
9acd5936f9 Add LLVM_FALLTHROUGH to silence warnings. 2021-02-25 20:44:17 +01:00
Vassil Vassilev
3e364c42a5 CreateASTDumper takes 2 more parameters.
See llvm-mirror/clang@dff959c
2021-02-25 20:44:17 +01:00
Vassil Vassilev
7581cf55c8 Fix unintended negation typo. 2021-02-25 20:44:17 +01:00
Vassil Vassilev
e16a3b2e19 BuryPointer went to llvm. 2021-02-25 20:44:17 +01:00
Vassil Vassilev
9d149b5748 getNewUninitMemBuffer is only available in WritableMemoryBuffer.
See llvm-mirror/llvm@2a379e0
2021-02-25 20:44:17 +01:00
Vassil Vassilev
8c77337f72 The default JIT settings are assumed by default now.
See llvm-mirror/llvm@9aafb85.
2021-02-25 20:44:16 +01:00
Vassil Vassilev
89a9b377da Remove redundant include. 2021-02-25 20:44:16 +01:00
Vassil Vassilev
641183d4e8 Add an include to the LegacyPassManager for object's size. 2021-02-25 20:44:16 +01:00
Vassil Vassilev
ce3ba64099 The interface requires us to tell if the value will be discarded.
See llvm-mirror/clang@bf91d084.
2021-02-25 20:44:16 +01:00
Vassil Vassilev
f4b6851414 Index goes behind the getASTIndex interface.
See llvm-mirror/clang@03ebcc82 and llvm-mirror/clang@f4ca1ac
2021-02-25 20:44:16 +01:00
Vassil Vassilev
c85cf9e4ea Use directly the const-checking routine. 2021-02-25 20:44:16 +01:00
Vassil Vassilev
dffacf9ee2 getTypeQualifiers was renamed to getMethodQualifiers.
See llvm-mirror/clang@8a8b20e
2021-02-25 20:44:16 +01:00
Vassil Vassilev
5c5d94f5ac TypeNameContext was moved to DeclaratorContext.
See llvm-mirror/clang@ef699b2164
2021-02-25 20:44:16 +01:00
Vassil Vassilev
4a2cc489a3 Add override keyword and InclusionDirective callback takes extra arg.
See llvm-mirror/clang@ef699b2.
2021-02-25 20:44:16 +01:00
Vassil Vassilev
08814ef1fb addPassesToEmitFile takes an extra argument.
See llvm-mirror/llvm@9ffe073.
2021-02-25 20:44:16 +01:00
Vassil Vassilev
bd580208a7 isExplicitSpecified was refactored into an enum.
See llvm-mirror/clang@7a6d690
2021-02-25 20:44:16 +01:00
Vassil Vassilev
2419680d6b isExplicitSpecified was renamed to hasExplicitSpecifier.
See llvm-mirror/clang@7a6d690.
2021-02-25 20:44:16 +01:00
Vassil Vassilev
99a5da9134 Fix weird whitespace. 2021-02-25 20:44:16 +01:00
Vassil Vassilev
172fcc4c42 The member was hidden in favor of an accessor.
See llvm-mirror/clang@672ad52
2021-02-25 20:44:16 +01:00
Vassil Vassilev
355e9bcfe5 PragmaIntroducerKind was renamed to PragmaIntroducer.
See llvm-mirror/clang@6333880.
2021-02-25 20:44:16 +01:00
Vassil Vassilev
adb3a16dff The PCHGenerator was enhanced to protect against build races.
See llvm-mirror/clang@d28cf14 and llvm-mirror/clang@2d59837.
2021-02-25 20:44:16 +01:00
Vassil Vassilev
0e04207ce2 setBuffer was renamed to replaceBuffer.
See llvm-mirror/clang@5fa94c9
2021-02-25 20:44:16 +01:00
Vassil Vassilev
e1368fcfbc getLocStart was renamed to getBeginLoc and getLocEnd to getEndLoc. 2021-02-25 20:44:16 +01:00
Vassil Vassilev
a498073ef8 Replace the statements only if they differ. 2021-02-25 20:44:16 +01:00
Vassil Vassilev
60bed9429d CompoundStmt::setStmts was reimplemented to save a pointer.
Unfortunately this break external tools such as cling which alters CompoundStmts
to implement its interactive extensions.

We have implemented a patch in clang which brings the old facilities only when
the new interface CompoundStmt::replaceStmts is called.

See llvm-mirror/clang@d0ee47a
2021-02-25 20:44:16 +01:00
Vassil Vassilev
ab1ea2bb02 driver::ArgStringList moved to llvm::opt. 2021-02-25 20:44:16 +01:00
Vassil Vassilev
62891a2537 clang::vfs::getVFSFromYAML moved to llvm. 2021-02-25 20:44:15 +01:00
Vassil Vassilev
14c4b6c575 Add support for c++2a. 2021-02-25 20:44:15 +01:00
Vassil Vassilev
b3238e5f1c LookupFile takes an extra optional argument. 2021-02-25 20:44:15 +01:00
Vassil Vassilev
f960a3520d Various ASTImporter import interfaces return llvm::Expected. 2021-02-25 20:44:15 +01:00
Vassil Vassilev
8d3b178cca Import does not have a return result anymore.
See llvm-mirror/clang@1e1ffe5
2021-02-25 20:44:15 +01:00
Vassil Vassilev
1a5b0a95f3 ForRedeclaration is split in two: {ForVisible,ForExternal}Redeclaration.
ForVisibleRedeclaration does not try to deserialize content from module files.
It should be used for efficiency and when we are sure that what we look up is
in the present TU and it does not make sense to ask the module files.

See llvm-mirror/clang@6bbe311
2021-02-25 20:44:15 +01:00
Vassil Vassilev
71218c74c1 CudaGpuBinaryFileNames was renamed to CudaGpuBinaryFileName.
llvm-mirror/clang@f828172bcf tells it is a NFC.
2021-02-25 20:44:15 +01:00
Vassil Vassilev
419d51346c EmitSummaryIndex was renamed to PrepareForThinLTO 2021-02-25 20:44:15 +01:00
Vassil Vassilev
7f30da6043 createAddDiscriminatorsPass went into llvm/Transforms/Utils.h 2021-02-25 20:44:15 +01:00
Vassil Vassilev
a16da5735b BuildDeclRefExpr returns a DeclRefExpr instead of StmtResult. 2021-02-25 20:44:15 +01:00
Vassil Vassilev
f6e74124ea CodeGenOptions.h moved from Frontend to Basic. 2021-02-25 20:44:15 +01:00
Simeon Ehrig
da1bb78f3d Apply Axel's suggestion for PR "Fixed cling argumenent --cuda-path"
- see: https://github.com/root-project/root/pull/6707
2021-02-10 15:18:14 +01:00
Simeon Ehrig
d00b927467 cling interpreter: add prefix to error messages, only in CUDA mode 2021-02-10 15:18:14 +01:00