4718 Commits

Author SHA1 Message Date
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
9576f69985 Remove patch for clang::CompoundStmt::replaceStmts 2021-04-23 09:29:06 +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
Pratyush Das
64b4aee4c3 Add GitHub issue template
Template taken from root-project/root's issue template
2021-04-19 14:29:07 +02:00
Enrico Guiraud
f84e601d3f Better SFINAE check to print collection values
In order to specialize cling's value-printing logic for collections
we perform some SFINAE checks. Among other things, the checks
assert that `++(obj.begin())` is well-formed. That compiles for
`std::vector` and other collections with "fat" iterators, but does
not compile for collections that use raw pointers as iterators:

```cpp
auto beg(std::vector<int> &v) {
    return v.begin();
}

int *beg2(std::vector<int> &v) {
    return &v[0];
}

int main() {
    std::vector<int> v{1,2,3};
    beg(v) += 1;
    //beg2(v) += 1; // does not compile - beg2(v) is not an lvalue

    return 0;
}
```

Requiring instead `std::begin(obj)` to be well-formed should be
backward compatible and it should allow collections that use raw
pointers as iterators to also be pretty-printed by cling.

Co-authored-by: Axel Naumann <Axel.Naumann@cern.ch>
2021-04-14 19: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
7cdaa77ea5 Order includes alphabetically (NFC). 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
Pratyush Das
2acd1d2776 Fix cpt for Cling build using LLVM 9
Only fixes builds from LLVM 9 source. Builds using an LLVM 9 binary
release is still broken.

Drop Ubuntu 16.04 Clang build, since Clang 3.8 is very old and causes
build failure.
2021-03-31 18:59:06 +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
Bertrand Bellenot
df5fbb3c46 Fix unresolved external symbol errors on Windows
Resolves root-project/cling#399
Fix the following linker errors:
253>cling.exp : error LNK2001: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl clang::QualType::getAsString(class clang::Type const *,class clang::Qualifiers)" (?getAsString@QualType@clang@@sa?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@PEBVType@2@VQualifiers@2@@z)
253>cling.exp : error LNK2001: unresolved external symbol "private: virtual void __cdecl llvm::raw_ostream::handle(void)" (?handle@raw_ostream@llvm@@EEAAXXZ)
253>D:\work\libs\cling\src\build\Release\bin\cling.exe : fatal error LNK1120: 2 unresolved externals
2021-03-23 22:29:08 +01: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
Pratyush Das
2b222f35f5 Drop --compiler flag
Build compiler can be set using CMake flag
2021-03-18 23:29:07 +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
David
b38fc1e80c make minimal adjustments (for removed headers) to boost modulemap for boost 1.75.0 (+patches for missing includes) 2021-03-18 15:59:04 +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
b921ac814a Bring vanilla-cling lit feature back:
it is needed for test/Autoloading/AutoForwarding.C.
2021-03-16 09:59:04 +01:00
Axel Naumann
897701fb24 Help test find its parts:
was failing before but due to `REQUIRES: vanilla-cling` not run.
2021-03-16 09:59:03 +01:00
Axel Naumann
608a992e5f Fix expected diags in test/Pragmas/load.C:
A failure to load the library will *not* trigger loading the
same file as a source file: `#pragma load` will cause zero or
one diagnostics, not two.

Now that the diagnostic for a missing file to be `#pragma load`ed
is "file not found", re-use the existing `expected-error@input_line_12`
line!.
2021-03-16 09:59:03 +01:00
Axel Naumann
0ae95fb193 Improve diag on #pragma load failure. 2021-03-16 09:59:03 +01:00
Vassil Vassilev
899b3337fc Install the modulemap files 2021-03-11 10:44:07 +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
Pratyush Das
9e2c41e580 Update cpt shebang to reflect Python 3 requirement 2021-03-05 12:44:07 +01:00
Pratyush Das
b7fc2bb37e Clarify in README that cpt requires Python 3 2021-03-05 09:29:07 +01:00
Vassil Vassilev
07ad3c1a72 Allow building clad as a cling plugin via -DCLING_BUILD_PLUGINS=On 2021-03-03 18:44:05 +01:00
Vassil Vassilev
c9dd3e66f8 Revert "[cling] modulemap <string_view> requires C++17."
This reverts commit 93c1649bef398ee310b85848bbe4a2f0182c3a76.
2021-02-28 17:44:05 +01:00
Vassil Vassilev
1804436da1 Add the CLANG_INCLUDE_DIRS if we build as part of LLVM. 2021-02-26 20:59:05 +01:00
Axel Naumann
34405e7a29 modulemap <string_view> requires C++17. 2021-02-26 18:14: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