Commit Graph

4791 Commits

Author SHA1 Message Date
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
acfb998188 Improve DeclShadowing.C test
Check also the declaration context, which should be an inline namespace if the
DefinitionShadower is enabled or the TU otherwise.
2022-02-05 03:59:07 +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
2766ad8421 Add test against ROOT-6095 2022-02-03 09:29:03 +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
52266ba5eb Turn on prtcheck for the ptrcheck tests. 2022-01-11 18: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
Axel Naumann
322960397c README: use githack.com CDN url (NFC). 2022-01-11 18:14:03 +01:00
Axel Naumann
d59d27ad61 README: better use githack.com for serving cling web pages https://github.com/root-project/cling/issues/436 (NFC). 2022-01-11 17:59:07 +01:00
Axel Naumann
26d94654ed README: remove stale build badges; fix web link https://github.com/root-project/cling/issues/444 (NFC). 2022-01-11 17:44:07 +01:00
Vassil Vassilev
884df027c3 Fix bugs in cling's tests.
Patch by Alexander Penev (@alexander-penev).
2022-01-07 16:29:03 +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
186d1100d4 Set default CompilationOptions opt level to 1:
should have no effect as it will be anyway overridden by whatever CodeGen has.
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
6a7fc6bdc8 change compiler flags (#9083)
* [cling][windows] change compiler flags

 - Set the `-std:c++14` / `-std:c++17` flag depending on the version of Visual Studio (only if building outside ROOT)
 - Split the one line exports in three lines to fix a potential issue with Ninja on Windows (missing a white space between each `/EXPORT:` specifier)

* Add a forgotten `endif()`
2021-10-07 16:59: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
8d98340299 InputValidator::validate(): add test against ROOT-9202 2021-09-08 19:14: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
Baidyanath Kundu
8e950be75d Bump clad version to v0.9.
This new release includes some improvements:
* Extended array support
* Add cmake variables to control the locations where find_package discovers LLVM and Clang: `LLVM_CONFIG_EXTRA_PATH_HINTS` and `Clang_CONFIG_EXTRA_PATH_HINTS` respectively.

See more at: https://github.com/vgvassilev/clad/blob/v0.9/docs/ReleaseNotes.md
2021-08-16 06:44:07 +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