Changed `ClangTidyOptions::mergeWith` to operate on the instance instead of returning a copy. The old mergeWith method has been renamed to merge and marked as nodiscard, to aid in disambiguating which one is which.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D91184
- Add verbose logging of payloads
- Add public logging of request summaries
- fix non-logging of messages in request scopes (oops!)
- add test for public/non-public logging, extending pipeline_helper a bit.
We've accumulated quite a lot of duplication in the request handlers by now.
I should factor that out, but not in this patch...
Differential Revision: https://reviews.llvm.org/D90654
Avoid requiring an actual MemoryBuffer in ComputePreambleBounds, when
a MemoryBufferRef will do just fine.
Differential Revision: https://reviews.llvm.org/D90890
Previously a corrupted index shard could cause us to resize arrays to an
arbitrary int32. This tends to be a huge number, and can render the
system unresponsive.
Instead, cap this at the amount of data that might reasonably be read
(e.g. the #bytes in the file). If the specified length is more than that,
assume the data is corrupt.
Differential Revision: https://reviews.llvm.org/D91258
This is a try to improve clangd-indexer tool performance:
- avoid processing already processed files.
- use different mutexes for different entities (e.g. do not block insertion of references while symbols are inserted)
Results for LLVM project indexing:
- before: ~30 minutes
- after: ~10 minutes
Reviewed By: kadircet
Differential Revision: https://reviews.llvm.org/D91051
By iterating backwards over the globs we can exit the loop as soon as we find a match.
While we're here:
- Regex doesn't need to be mutable.
- We can reserve the amount of Globs needed ahead of time.
- Using a SmallVector with size 0 is slightly more space efficient than a std::vector.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D91033
https://reviews.llvm.org/D89670 changed the Ref structure, we need to
bump the version to invalidate all stored stale data, otherwise we will
get ` Error while reading shard: malformed or truncated refs` when
building the background index.
Differential Revision: https://reviews.llvm.org/D91131
* Even though remote index is still somewhat experimental, it can now be
used withing clangd itself: this should be the primary way of trying
it out
* Remove `protobuf-compiler` from list of needed Debian packages as it
`protobuf-compiler-grpc` already depends on it
* Bump recommended gRPC version to 1.32.3
We plan to eliminate error-prone and obsolete Clang-Rename API from Clangd. To
do that, we will introduce Decl canonicalization rules that will make renaming
code simpler and easier to maintain (D71880).
To ensure smooth transition to the new implementation, many Clang-Rename tests
will be adopted in Clangd to prevent any possible regressions. This patch is
the first in the chain of test migration patches. It improves existing tests
and adopts tests from Clang-Rename's alias, class and enum testing files.
Reviewed By: hokein
Differential Revision: https://reviews.llvm.org/D91102
With this patch, we reject the rename if the new name would conflict with
any other decls in the decl context of the renamed decl.
Differential Revision: https://reviews.llvm.org/D89790
There is not reason to check `std::make_unique<...>(..)` return value,
but `clangd::clang::loadIndex()` returns `nullptr` if an index file could not be loaded (e.g. incorrect version).
Reviewed By: kadircet
Differential Revision: https://reviews.llvm.org/D91049
The altera kernel name restriction check finds kernel files and include
directives whose filename is "kernel.cl", "Verilog.cl", or "VHDL.cl".
Such kernel file names cause the Altera Offline Compiler to generate
intermediate design files that have the same names as certain internal
files, which leads to a compilation error.
As per the "Guidelines for Naming the Kernel" section in the "Intel FPGA
SDK for OpenCL Pro Edition: Programming Guide."
This reverts the reversion from 43a38a6523.
If an enum has different names for the same constant, make sure only the first one declared gets added into the switch. Failing to do so results in a compiler error as 2 case labels can't represent the same value.
```
lang=c
enum Numbers{
One,
Un = One,
Two,
Deux = Two,
Three,
Trois = Three
};
// Old behaviour
switch (<Number>) {
case One:
case Un:
case Two:
case Duex:
case Three:
case Trois: break;
}
// New behaviour
switch (<Number>) {
case One:
case Two:
case Three: break;
}
```
Reviewed By: sammccall
Differential Revision: https://reviews.llvm.org/D90555
While here, clean up ParsedAST::build a bit:
- remove FIXMEs that were fixed long ago by ReplayPreamble
- remove redundant if, ClangTidyContext is not actually optional
Differential Revision: https://reviews.llvm.org/D90975
The config providers that look for configuration files currently take a pointer to a FileSystem in the constructor.
For some reason this isn't actually used when trying to read those configuration files, Essentially it just follows the behaviour of the real filesystem.
Using clang-tidy standalone this doesn't cause any issue.
But if its used as a library and the user wishes to use say an `InMemoryFileSystem` it will try to read the files from the disc instead.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D90992
Probably not essential as afaik only one check uses this field. but still good to have consistent behaviour.
Reviewed By: sammccall
Differential Revision: https://reviews.llvm.org/D90552
Add IgnoreMainLikeFunctions to the per file config. This can be extended for new options added to the check easily.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D90832
RemoteIndexClient implementations only depends on clangdSupport for
logging functionality and has no dependence on clangDeamon itself. This clears
out that link time dependency and enables depending on it in clangDeamon itself,
so that we can have other index implementations that makes use of the
RemoteIndex.
Differential Revision: https://reviews.llvm.org/D90746
SIG30-C. Call only asynchronous-safe functions within signal handlers
First version of this check, only minimal list of functions is allowed
("strictly conforming" case), for C only.
Differential Revision: https://reviews.llvm.org/D87449
This enables using the arrow operator to access members of the contained item.
```lang=c++
Located<std::string> X;
const char* CStr = X->c_str();
```
This is inline with how classes like `Optional` handle the arrow operator.
Reviewed By: kadircet
Differential Revision: https://reviews.llvm.org/D90682
This introduces a mechanism for providers to interpret paths specified
in a fragment either as absolute or relative to fragment location.
This information should be used during compile stage to handle blocks correctly.
Differential Revision: https://reviews.llvm.org/D90270
Let clang-tidy to read config from specified file.
Example:
$ clang-tidy --config-file=/some/path/myTidyConfig --list-checks --
...this will read config from '/some/path/myTidyConfig'.
ClangTidyMain.cpp reads ConfigFile into string and then assigned read data to 'Config' i.e. makes like '--config' code flow internally.
May speed-up tidy runtime since now it will just look-up <file-path>
instead of searching ".clang-tidy" in parent-dir(s).
Directly specifying config path helps setting build dependencies.
Thanks to @DmitryPolukhin for valuable suggestion. This patch now propose
change only in ClangTidyMain.cpp.
Reviewed By: DmitryPolukhin
Differential Revision: https://reviews.llvm.org/D89936
The index server has access to potentially-sensitive information, e.g. a
sequence of fuzzyFind requests reveals details about code completions in the
editor which in turn reveals details about the code being edited.
This information is necessary to provide the service, and our intention[1] is it
should never be retained beyond the scope of the request (e.g. not logged).
At the same time, some log messages should be exposed:
- server startup/index reloads etc that don't pertain to a user request
- basic request logs (method, latency, #results, error code) for monitoring
- errors while handling requests, without request-specific data
The -log=public design accommodates these by allowing three types of logs:
- those not associated with any user RPC request (via context-propagation)
- those explicitly tagged as [public] in the log line
- logging of format strings only, with no interpolated data (error level only)
[1] Specifically: Google is likely to run public instances of this server
for LLVM and potentially other projects, they will run in this configuration.
The details agreed in a Google-internal privacy review.
As clangd developers, we'd encourage others to use this configuration for public
instances too.
Differential Revision: https://reviews.llvm.org/D90526
- pass required=False to use_clang(), as we don't need it
- fix required=False (which was unused and rotted):
- make derived substitutions conditional on it
- add a feature so we can disable tests that need it
- conditionally disable our one test that depends on %resource_dir.
This doesn't seem right from first principles, but isn't a big deal.
Differential Revision: https://reviews.llvm.org/D90528
The vendor will be prefixed to the "clangd" and can be an arbitrary
string, so account for it in the test.
Reviewed By: sammccall
Differential Revision: https://reviews.llvm.org/D90517
The altera kernel name restriction check finds kernel files and include
directives whose filename is "kernel.cl", "Verilog.cl", or "VHDL.cl".
Such kernel file names cause the Altera Offline Compiler to generate
intermediate design files that have the same names as certain internal
files, which leads to a compilation error.
As per the "Guidelines for Naming the Kernel" section in the "Intel FPGA
SDK for OpenCL Pro Edition: Programming Guide."
Now that clang-tidy supports the --use-color command line option, it's
a better user experience to use --use-color in run-clang-tidy.py and
preserving the colored output.
We were default initializing SymbolIDs before, which would leave
indeterminate values in underlying std::array.
This patch updates the underlying data initalization to be value-init and adds a
way to check for validness of a SymbolID.
Differential Revision: https://reviews.llvm.org/D90397
Introduce a separate thread that will kill `clangd-index-server` after 10 seconds regardless. This helps shut down the test if the server hangs and `stderr.readline()` does not contain inititalizatiton message. It prevents "necessary" waiting delay for the server warm-up and only introduces additional delay if the test fails.
It also makes use of `subprocess.Popen.kill()` which is a portable way of handling process shutdown and avoids using signals.
Reviewed By: kadircet
Differential Revision: https://reviews.llvm.org/D90590
Google test matcher `DeclKind` uses `NamedDecl::getDeclKindName()` to compare its result with expected declaration name.
Both, returned value of this function and the expected kind name argument have type `const char *`, so this matcher effectively
compares two pointers instead of the respective strings.
The test was passing on most platforms because compilers mostly were able to coalesce these string literals.
Patch By: Ilya Golovenko
Reviewed By: hokein
Differential Revision: https://reviews.llvm.org/D90384
On Windows the --use-color option cannot be used for its originally
intended purpose of forcing color when piping stdout, since Windows
does not use ANSI escape codes by default. This change turns on ANSI
escape codes on Windows when forcing color to a non-displayed stdout
(e.g. piped).