Commit Graph

261 Commits

Author SHA1 Message Date
Jonas Hahnfeld
52df1a551a Globally enable incremental extensions
We are relying on this since a while, for example for reemission of
template symbols. At the moment, we get the incremental extensions
because Preprocessor::enableIncrementalProcessing() turns them on
internally, but this will change with LLVM 18 where this method only
controls incremental processing of a single Preprocessor object.
2024-08-09 08:59:03 +02:00
Jonas Hahnfeld
afd3692787 Forcefully clean up TemplateIdAnnotations
Upstream Clang keeps TemplateIdAnnotations around "if they might
still be in the token stream." See upstream commit for more details:
6163aa9679
(included in Clang 11, in ROOT since the upgrade to LLVM 13)

This reasoning doesn't apply when we fully reset the Parser state in
ParserStateRAII's destructor, and we expect the swapped out vector of
TemplateIdAnnotations to be empty in order to not leak.

Fixes #16121
2024-08-02 08:29:05 +02:00
Bertrand Bellenot
3cc2a4dd8d Add support for Visual Studio >= v17.10 2024-05-08 10:44:03 +02:00
Devajith Valaparambil Sreeramaswamy
c5692e71f1 Use StringRef::{starts,ends}_with
Follows the changes introduced in https://reviews.llvm.org/D136030
2024-02-23 09:44:06 +01:00
Devajith Valaparambil Sreeramaswamy
a085ccebac Use deduction guides for llvm::ArrayRef 2023-12-13 13:29:07 +01:00
Jonas Hahnfeld
3d5ba159c6 Desugar UnaryTransformType
This fixes PyROOT's handling of smart pointers, such as shared_ptr,
with the new macOS SDK 14.0 resulting in a remove_extent transform.
2023-12-11 08:59:21 +01:00
Jonas Hahnfeld
f636e21faa Handle UsingType in GetPartiallyDesugaredType
According to https://github.com/llvm/llvm-project/commit/af27466c50,
it is used to represent types pulled in with a using declaration, for
example `using std::error_code; error_code x;`.

This fixes the build of the ROOTTMVASofie module on macOS where this
was causing `std::size_t` not be fully desugared to `unsigned long`
at first to later end up with two identical classes in a list that
must not have duplicates.
2023-12-11 08:59:21 +01:00
Jonas Hahnfeld
a1598cba14 Update handling of ElaboratedType in GetFullyQualifiedType
In LLVM 16, we now get ElaboratedType far more often, but they don't
have all namespace qualifiers we need. This fixes the build of the
RooFitCore module, but many other places are likely affected as well.
2023-12-11 08:59:21 +01:00
Jonas Hahnfeld
2c98e68e68 Lexer does not expose getLangOpts() anymore
Store a reference ourselves. Also Lexer::isIdentifierBodyChar() was
renamed to Lexer::isAsciiIdentifierContinueChar().
2023-12-11 08:59:20 +01:00
Jonas Hahnfeld
15b5de6398 getQualifiedTemplateName takes a TemplateName 2023-12-11 08:59:20 +01:00
Jonas Hahnfeld
85c348828f CompoundStmt::Create takes FPOptionsOverride 2023-12-11 08:59:20 +01: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
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
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
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
Sergey Linev
0525bca060 Use nullptr in cling
Avoid warnings when -Wzero-as-null-pointer-constant is specified
2023-01-30 08:29:07 +01:00
Vassil Vassilev
62dc043874 Qualify DestroyTemplateIdAnnotationsRAIIObj. 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
Sergey Linev
6dd621f4d3 add override qualifier for ColoredOutput methods 2022-08-31 09:14:04 +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
Axel Naumann
234772da1c Prevent traling whitespace in -isystem. 2021-11-12 16:14:06 +01: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
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
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
Vassil Vassilev
f2e5f43acf Fix warnings about the ignored quals. 2021-02-25 20:44:19 +01:00
Vassil Vassilev
a4a06e0fdf Fix warnings coming from shadowing names. 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
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
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
a16da5735b BuildDeclRefExpr returns a DeclRefExpr instead of StmtResult. 2021-02-25 20:44:15 +01:00
Axel Naumann
856f8e92f8 Survive NNS not being a namespace. 2020-10-07 17:44:10 +02:00
Jonas Hahnfeld
f2b3a8408e IsClassOrFunction: Handle signedness modifiers
When using these modifiers, a type can consist of multiple tokens
as for example "unsigned int". However the keyword "int" can also
be omitted, making "unsigned" itself also a valid type.

Note that this only handles the most basic case for the modifiers.
The size modifiers "short", "long", and "long long" would need
similar treatment. Moreover the standard permits any order for the
type specifiers, ie "unsigned long long int" and "long int unsigned
long" are both valid (and actually the same type).
2020-07-01 22:44:08 +02:00
Axel Naumann
9220b498f3 Capture/reset expression eval context (ROOT-10511):
Without resetting the eval context to the Parser default (PotentiallyEvaluated),
recursive parsing can potentially assume wrong context and not emit referenced entities.
2020-02-19 11:30:36 +01:00
Sergey Linev
269608a831 Fix memory leak in cling/lib/Utils/PlatformWin.cpp
Seems to be, buffer is not released correctly.
I guess, error should be fixed in cling repository first
2020-01-30 16:29:05 +01:00
Chris Burr
500f426c2f Fix building clingutils tetss with builtin_clang=OFF for conda 2020-01-24 15:44:19 +01:00
Simeon Ehrig
65b9ee7a8c Add functionality to SourceNormalization to detect cuda kernels
- a really weak solution, which should replaced by a generic solution
2019-11-07 19:29:15 +01:00
Guilherme Amadio
111fa41390 Add assertion to ensure that page_size is a power of two 2019-08-08 18:14:03 +02:00
Nikita Ermakov
4b61a2134b Little optimization for the cling pointer check.
Use precalculated PAGE_MASK which is equals to ~(page_size - 1) at
pointer check instead of recalculate it each check.
2019-08-08 17:14:46 +02:00
Guilherme Amadio
0c6588cd0c Fix cling valid pointer check
Assuming that page_size is a power of 2, the calculation of the
base address of the page can be simplified and avoid a division.

According to POSIX, either MS_SYNC or MS_ASYNC must be specified
when calling msync(). Failure to include one of these flags will
cause msync() to fail on some systems.

When msync() returns -1, the pointer is only considered invalid
when errno is set to ENOMEM. In principle, the other possible
values for errno won't happen, but if they do, that should be
considered an error, hence the assert condition needed an update.
EBUSY shouldn't happen since we do not add MS_INVALIDATE to flags,
and EINVAL shouldn't happen because we always pass a multiple of
the page size to msync(). EFAULT is only used in Linux 2.4.18 and
earlier instead of ENOMEM.
2019-08-07 16:29:14 +02:00
Nikita Ermakov
d1faf4e905 Change pointer check method to msync.
The POSIX does not contains /dev/random [1]. Moreover the /dev/random
might not have write permissions. The better way is to use an another
solution which is based on the msync system call [2]. Also this solution
reduces the number of context switching.

[1] -- https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap10.html
[2] -- https://pubs.opengroup.org/onlinepubs/009695399/functions/msync.html
2019-08-06 19:59:22 +02:00
Vassil Vassilev
d71643dcf8 Support recursive lookup helper calls.
The implementation of class->library mapping makes a call to the
LookupHelper::findScope. This makes the recursive invocations to
LookupHelper::findScope -> ... -> LookupHelper::findScope happen more often.
2019-06-02 21:44:26 +02:00
Bertrand Bellenot
7fc4f8539c Add support for Visual Studio 2019 (16) 2019-04-15 12:29:37 +02:00
Vassil Vassilev
eab5eca3ea Optimize IsWrapper
The getNameAsString interface causes a lot of temporary allocations.
The analysis if a decl is a cling-style wrapper can work only on a
simple declarations on the global scope.

This patch filters out complex declarations (eg in namespaces) and
checks only the identifier content.

The patch reduces the memory footprint difference shown in root-project/root#3012.
2019-03-25 19:14:13 +01:00