Summary:
Remote server should not send messages that are invalid and will cause problems
on the client side. The client should not be affected by server's failures
whenever possible.
Also add more error messages and logs.
Reviewers: sammccall
Reviewed By: sammccall
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D83826
When a semantic checking fails on a syntactic InitListExpr, we will
get an ill-formed semantic InitListExpr (e.g. some inits are nullptr),
using this semantic InitListExpr in clang (without setting the err-bits) is crashy.
Differential Revision: https://reviews.llvm.org/D84140
* Try to apply heuristic resolution recursively to the base
expression of a CXXDependentScopeMemberExpr.
* Try to apply heuristic resolution recursively to the callee
expression in a call expression.
Fixes https://github.com/clangd/clangd/issues/441
Subscribers: ilya-biryukov, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D82739
Summary:
This patch mostly reverts D74850.
We could not use `AST.getTokens()` here, because it does not have tokens from the preamble.
Reviewers: sammccall, kadircet
Reviewed By: kadircet
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, kbobyrev, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D84144
This prevents selection of empty preprocessor entities (like #define directives,
or text in disabled sections) creating a selection in the parent element.
Summary: Based on D83508 by Aleksandr Platonov.
Reviewers: ArcsinX, kadircet
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D84012
In clang <3.9 the `unique_ptr` constructor that is supposed to allow
for Derived to Base conversion does not work. Remove this if we drop
support for such configurations.
This is the same fix as in fda901a987, and it updates the comments
to better reflect the actual issue. The same thing reproduces with
libc++ with older clangs.
Summary:
Clangd is returning current working directory for overriden commands.
This can cause inconsistencies between:
- header and the main files, as OverlayCDB only contains entries for the main
files it direct any queries for the headers to the base, creating a
discrepancy between the two.
- different clangd instances, as the results will be different depending on the
timing of execution of the query and override of the command. hence clangd
might see two different project infos for the same file between different
invocations.
- editors and the way user has invoked it, as current working directory of
clangd will depend on those, hence even when there's no underlying base CWD
might change depending on the editor, or the directory user has started the
editor in.
This patch gets rid of that discrepency by always directing queries to base or
returning llvm::None in absence of it.
For a sample bug see https://reviews.llvm.org/D83099#2154185.
Reviewers: sammccall
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D83934
Summary:
I hit this while trying to add a config-over-LSP lit test, which I think
is an appropriate way to test this feature.
That needs a few more changes though...
Reviewers: kadircet
Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D83802
Following on fcf7cc268f and 672207c319 which granted checks the ability to read boolean configuration arguments as `true` or `false`.
This enables storing the options back to the configuration file using `true` and `false`.
This is in line with how clang-format dumps boolean options in its style config.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D83053
Summary: (Possible to flip back on the branch if this breaks things)
Reviewers: kadircet
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D83790
Summary:
We only support Build/Skip for now, but with 'Load' or similar as an
option for future (load existing shards but don't build new ones).
This requires creating the config for each TU on startup. In LLVM, this
is 4000 occurrences for a total of 800ms on my machine.
But together with caching from D83755 it is only 25ms.
Reviewers: kadircet
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D83768
Summary:
This is motivated by:
- code completion: nice to do no i/o on the request path
- background index: deciding whether to enqueue each file would stat the config
file thousands of times in quick succession.
Currently it's applied uniformly to all requests though.
This gives up on performing stat() outside the lock, all this achieves is
letting multiple threads stat concurrently (and thus finish without contention
for nonexistent files).
The ability to finish without IO (just mutex lock + integer check) should
outweigh this, and is less sensitive to platform IO characteristics.
Reviewers: kadircet
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D83755
Summary:
This is designed for tweaking compile commands by specifying flags to add/remove
in a config file. Something like:
CompileFlags: { Remove: -fcolor-diagnostics }
Having users tweak raw argv (e.g. with a regex) is going to end in tears: bugs
around clang-cl, xclang, aliases, joined-vs-separate args etc are inevitable.
This isn't in tooling because of the performance choices: build a big table
up-front to make subsequent actions fast. Maybe it should be though.
Reviewers: adamcz, hokein
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D81958
Summary:
This patch introduces basic textDocument/foldingRange support. It relies on
textDocument/documentSymbols to collect all symbols and uses takes ranges
to create folds.
The next steps for textDocument/foldingRange support would be:
* Implementing FoldingRangeClientCapabilities and respecting respect client
preferences
* Specifying folding range kind
* Migrating from DocumentSymbol implementation to custom RecursiveASTVisitor flow that will allow more flexibility
* Supporting more folding range types: comments, PP conditional regions, includes and other code regions (e.g. public/private/protected sections of classes, control flow statement bodies)
Tested: (Neo)Vim (coc-clangd) and VSCode.
Related issue: https://github.com/clangd/clangd/issues/310
Reviewers: sammccall
Reviewed By: sammccall
Subscribers: nridge, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D82436
Summary:
DocumentSymbol ranges were not previously tested and, as a result, had invalid
end location. This patch addresses the issue.
Reviewers: sammccall
Reviewed By: sammccall
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D83668
Summary:
Build log:
```
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp: In member function ‘virtual void clang::clangd::{anonymous}::PreamblePatchTest_Define_Test::TestBody()’:
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:267:3: error: could not convert ‘(const char*)"\012 #define BAR\012 [[BAR]]"’ from ‘const char*’ to ‘llvm::StringLitera ’
};
^
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:267:3: error: could not convert ‘(const char*)"#line 0 \".*main.cpp\"\012#line 2\012#define BAR\012"’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:267:3: error: could not convert ‘(const char*)"\012 #define BAR \\\012\012 [[BAR]]"’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:267:3: error: could not convert ‘(const char*)"#line 0 \".*main.cpp\"\012#line 2\012#define BAR\012"’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:267:3: error: could not convert ‘(const char*)"\012 #define \\\012 BAR\012 [[BAR]]"’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:267:3: error: could not convert ‘(const char*)"#line 0 \".*main.cpp\"\012#line 3\012#define BAR\012"’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp: In member function ‘virtual void clang::clangd::{anonymous}::PreamblePatchTest_LocateMacroAtWorks_Test::TestBody()’:
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)""’ from ‘const char*’ to ‘llvm::StringLiteral’
};
^
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)"\012 #define $def^FOO\012 $use^FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)""’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)"\012 #define $def^FOO\012 #undef $use^FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)""’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)"\012 #define $def^FOO\012 #undef FOO\012 $use^FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)""’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)"\012 #define \\\012 $def^FOO\012 $use^FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)""’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)"\012 #\\\012 define /* FOO */\\\012 /* FOO */ $def^FOO\012 $use^FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)"#define FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)"\012 #define BAR\012 #define $def^FOO\012 $use^FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp: In member function ‘virtual void clang::clangd::{anonymous}::PreamblePatchTest_RefsToMacros_Test::TestBody()’:
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:445:3: error: could not convert ‘(const char*)""’ from ‘const char*’ to ‘llvm::StringLiteral’
};
^
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:445:3: error: could not convert ‘(const char*)"\012 #define ^FOO\012 ^[[FOO]]"’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:445:3: error: could not convert ‘(const char*)"#define FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:445:3: error: could not convert ‘(const char*)"\012 #define BAR\012 #define ^FOO\012 ^[[FOO]]"’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:445:3: error: could not convert ‘(const char*)""’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:445:3: error: could not convert ‘(const char*)"\012 #define ^FOO\012 #undef ^FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp: In member function ‘virtual void clang::clangd::{anonymous}::PreamblePatch_ModifiedBounds_Test::TestBody()’:
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:512:3: error: could not convert ‘(const char*)""’ from ‘const char*’ to ‘llvm::StringLiteral’
};
^
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:512:3: error: could not convert ‘(const char*)"\012 #define FOO\012 FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:512:3: error: could not convert ‘(const char*)"#define FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:512:3: error: could not convert ‘(const char*)"#define BAR"’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:512:3: error: could not convert ‘(const char*)"\012 #define FOO\012 #undef FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’
llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:512:3: error: could not convert ‘(const char*)"#define FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’
```
Patch by @ArcsinX !
Reviewers: kadircet, sammccall
Reviewed By: kadircet
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D83548
This implements the default(firstprivate) clause as defined in OpenMP
Technical Report 8 (2.22.4).
Reviewed By: jdoerfert, ABataev
Differential Revision: https://reviews.llvm.org/D75591
Reland b9306fd after fixing the issue causing mac builds to fail unittests.
Following on from D77085, I was never happy with the passing a mapping to the option get/store functions. This patch addresses this by using explicit specializations to handle the serializing and deserializing of enum options.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D82188
The check assumed the matched function call has 3 arguments, but the
matcher didn't guaranteed that.
Differential Revision: https://reviews.llvm.org/D83301
Summary:
Two helpers are introduced:
* Some of the logic previously in TargetFinder::Visit*() methods is
factored out into resolveDependentExprToDecls().
* Some of the logic in getMembersReferencedViaDependentName() is
factored out into resolveTypeToRecordDecl().
D82739 will build on this and use these functions in new ways.
Reviewers: hokein
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D83371
Summary:
We've been testing this internally for a couple weeks now and it seems
to be stable enough. Let's flip the flag before branch cut to increase testing
coverage and have enough time to revert if need be.
Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D83290
Summary:
A few things were broken:
- use of Document::parseBlockNode() is incorrect and prevents moving to the
next doc in error cases. Use getRoot() instead.
- bailing out in the middle of iterating over a list/dict isn't allowed,
unless you are going to throw away the parser: the next skip() asserts.
Always consume all items.
- There were two concepts of fatal errors: error-diagnostics and drop-fragment.
(The latter is the "return false" case in the parser). They didn't coincide.
Now, parser errors and explicitly emitted error diagnostics are fatal.
Fixes https://github.com/clangd/clangd/issues/452
Reviewers: hokein
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D83436
The block arguments in dispatch_async() and dispatch_after() are
guaranteed to escape. If those blocks capture any pointers with the
noescape attribute then it is an error.