- removed unnessacary namespaces
- added option to print warning in macros
- no fix for typedef with array
- removed "void" word from functions with 0 parameters
Differential Revision: https://reviews.llvm.org/D29262
llvm-svn: 299340
Catch trivially true statements of the form a != 1 || a != 3. Statements like
these are likely errors. They are particularly easy to miss when handling enums:
enum State {
RUNNING,
STOPPED,
STARTING,
ENDING
}
...
if (state != RUNNING || state != STARTING)
...
Patch by Blaise Watson!
Differential revision: https://reviews.llvm.org/D29858
llvm-svn: 298607
This commit renames all of the safety functionality to be hicpp, adds an appropriate LICENSE.TXT, and updates the documentation accordingly.
llvm-svn: 298229
Summary:
There is no need for triggering warning when noexcept specifier in move constructor or move-assignment operator is neither evaluated nor uninstantiated.
This fixes bug reported here: bugs.llvm.org/show_bug.cgi?id=24712
Reviewers: alexfh
Reviewed By: alexfh
Subscribers: JonasToth, JDevlieghere, cfe-commits
Tags: #clang-tools-extra
Patch by Marek Jenda!
Differential Revision: https://reviews.llvm.org/D31049
llvm-svn: 298101
Use the LLVM_UTILS_PROVIDED variable to determine whether test tool
dependencies should be exposed for clang-tools-extra tests. If clang is
being built stand-alone and LLVM test tools (FileCheck, count and not)
are installed, the top-level CMakeLists.txt of clang sets this variable
to indicate that they will not be built as a part of this build,
and therefore no dependencies should be emitted for them. This fixes
the dependency errors when building clang stand-alone with tests
enabled.
Differential Revision: https://reviews.llvm.org/D29851
llvm-svn: 297806
Summary:
Add fuzzy SymbolIndex, where identifier needn't match exactly.
The purpose for this is global autocomplete in clangd. The query will be a
partial identifier up to the cursor, and the results will be suggestions.
It's in include-fixer because:
- it handles SymbolInfos, actually SymbolIndex is exactly the right interface
- it's a good harness for lit testing the fuzzy YAML index
- (Laziness: we can't unit test clangd until reorganizing with a tool/ dir)
Other questionable choices:
- FuzzySymbolIndex, which just refines the contract of SymbolIndex. This is
an interface to allow extension to large monorepos (*cough*)
- an always-true safety check that Identifier == Name is removed from
SymbolIndexManager, as it's not true for fuzzy matching
- exposing -db=fuzzyYaml from include-fixer is not a very useful feature, and
a non-orthogonal ui (fuzziness vs data source). -db=fixed is similar though.
Reviewers: bkramer
Subscribers: cfe-commits, mgorny
Differential Revision: https://reviews.llvm.org/D30720
llvm-svn: 297630
Summary:
Remove line number from Symbol identity.
For our purposes (include-fixer and clangd autocomplete), function overloads
within the same header should mostly be treated as a single combined symbol.
We may want to track individual occurrences (line number, full type info)
and aggregate this during mapreduce, but that's not done here.
Reviewers: hokein, bkramer
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D30685
llvm-svn: 297371
Summary:
I've added a test case that (without the fix) triggers the assertion,
which happens when a move happens in an implicitly called conversion
operator.
This patch also fixes nondeterministic behavior in the source code
location reported for the move when the move is constained in an init list;
this was causing buildbot failures in the previous attempt to submit
this patch (see D30569 and rL297004).
Reviewers: alexfh
Reviewed By: alexfh
Subscribers: Eugene.Zelenko, JDevlieghere, cfe-commits
Differential Revision: https://reviews.llvm.org/D30650
llvm-svn: 297272
Summary:
I've added a test case that (without the fix) triggers the assertion,
which happens when a move happens in an implicitly called conversion
operator.
Reviewers: alexfh
Reviewed By: alexfh
Subscribers: JDevlieghere, cfe-commits
Differential Revision: https://reviews.llvm.org/D30569
llvm-svn: 297004
* suggest static_cast instead of reinterpret_cast for casts from void*
* top-level const doesn't need a const_cast
* don't emit a separate "possibly redundant cast" warning, instead suggest
static_cast (in C++ only) and add a little hint to consider removing the cast
llvm-svn: 296753
Summary:
Hello everybody,
this is an incremental patch for the NoMalloc-Checker I wrote. It allows to configure the memory-management functions, that are checked,
This might be helpful for a code base with custom functions in use, or non-standard functionality, like posix_memalign.
Reviewers: aaron.ballman, hokein, alexfh
Reviewed By: aaron.ballman, alexfh
Subscribers: sbenza, nemanjai, JDevlieghere
Tags: #clang-tools-extra
Patch by Jonas Toth!
Differential Revision: https://reviews.llvm.org/D28239
llvm-svn: 296734
Summary:
This uses CodeActions to show 'apply fix' actions when code actions are
requested for a location. The actions themselves make use of a
clangd.applyFix command which has to be implemented on the editor side. I
included an implementation for vscode.
This also adds a -run-synchronously flag which runs everything on the main
thread. This is useful for testing.
Reviewers: krasimir
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D30498
llvm-svn: 296636
Summary:
Add an option to function-size to warn about high parameter counts.
This might be relevant for cppcoreguidelines and the safety module as well. Since the safety module is not landed in master already, i did not create an alias, but that can be done later as well.
Reviewers: sbenza, alexfh, hokein
Reviewed By: alexfh, hokein
Subscribers: JDevlieghere
Patch by Jonas Toth!
Differential Revision: https://reviews.llvm.org/D29561
llvm-svn: 296599
Summary:
Fix generated by modernize-use-override caused syntax error when method
used try-statement as a body. `override` keyword was inserted after last
declaration token which happened to be a `try` keyword.
This fixes PR27119.
Reviewers: ehsan, djasper, alexfh
Reviewed By: alexfh
Subscribers: JDevlieghere, cfe-commits
Tags: #clang-tools-extra
Patch by Paweł Żukowski!
Differential Revision: https://reviews.llvm.org/D30002
llvm-svn: 296598
Summary:
Add usage count to find-all-symbols.
FindAllSymbols now finds (most!) main-file usages of the discovered symbols.
The per-TU map output has NumUses=0 or 1 (only one use per file is counted).
The reducer aggregates these to find the number of files that use a symbol.
The NumOccurrences is now set to 1 in the mapper rather than being inferred by
the reducer, for consistency.
The idea here is to use NumUses for ranking: intuitively number of files that
use a symbol is more meaningful than number of files that include the header.
Reviewers: hokein, bkramer
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D30210
llvm-svn: 296446
Summary:
This flag allows specifying a custom path for the compilation
database. Unfortunately we can't use the -p flag like other
clang-tidy tools because it's already taken.
Reviewers: alexfh
Subscribers: JDevlieghere, cfe-commits
Differential Revision: https://reviews.llvm.org/D29806
llvm-svn: 295482
Summary:
This patch adds onTypeFormatting to clangd.
The trigger character is '}' and it works by scanning for the matching '{' and formatting the range in-between.
There are problems with ';' as a trigger character, the cursor position is before the `|`:
```
int main() {
int i;|
}
```
becomes:
```
int main() { int i;| }
```
which is not likely what the user intended.
Also formatting at semicolon in a non-properly closed scope puts the following tokens in the same unwrapped line, which doesn't reformat nicely.
Reviewers: bkramer
Reviewed By: bkramer
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D29990
llvm-svn: 295304
Summary:
Replaces explicit calls to the constructor in a return with a braced
initializer list. This way the return type is not needlessly duplicated in the
return type and the return statement.
```
Foo bar() {
Baz baz;
return Foo(baz);
}
// transforms to:
Foo bar() {
Baz baz;
return {baz};
}
```
Reviewers: hokein, Prazek, aaron.ballman, alexfh
Reviewed By: Prazek, aaron.ballman, alexfh
Subscribers: malcolm.parsons, mgorny, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D28768
llvm-svn: 295199
Summary:
This requires an accessible compilation database. The parsing is done
asynchronously on a separate thread.
Reviewers: klimek, krasimir
Subscribers: cfe-commits, mgorny
Differential Revision: https://reviews.llvm.org/D29886
llvm-svn: 295180
Summary:
The misc-unconventional-assign-operator check had a false positive
warning when the 'operator*' in 'return *this' was unresolved.
Change matcher to allow calls to unresolved operator.
Fixes PR31531.
Reviewers: alexfh, aaron.ballman
Subscribers: JDevlieghere, cfe-commits
Differential Revision: https://reviews.llvm.org/D29393
llvm-svn: 295176
Summary:
Users might get confused easily when they see the check's message on
full template function speciliations.
Add a note to the output message, which mentions these kind of function
specializations are treated as regular functions.
Reviewers: alexfh
Reviewed By: alexfh
Subscribers: JDevlieghere, cfe-commits
Differential Revision: https://reviews.llvm.org/D29928
llvm-svn: 295048
I have made a small fix for readability-delete-null-pointer check so it also checks for class members.
Example of case that it fixes
```
struct A {
void foo() {
if(mp)
delete mp;
}
int *mp;
};
```
Reviewers: JDevlieghere, aaron.ballman, alexfh, malcolm.parsons
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D29726
llvm-svn: 294912
Summary:
This new flag instructs clang-tidy to not output anything
except for errors and warnings. This makes it easier to
script clang-tidy to run as part of external build systems.
Reviewers: bkramer, alexfh, klimek
Subscribers: JDevlieghere, cfe-commits
Differential Revision: https://reviews.llvm.org/D29661
llvm-svn: 294607
clangd is a language server protocol implementation based on clang. It's
supposed to provide editor integration while not suffering from the
confined ABI of libclang.
This implementation is limited to the bare minimum functionality of
doing (whole-document) formatting and rangeFormatting. The JSON parsing
is based on LLVM's YAMLParser but yet most of the code of clangd is
currently dealing with JSON serialization and deserialization.
This was only tested with VS Code so far, mileage with other LSP clients
may vary.
Differential Revision: https://reviews.llvm.org/D29451
llvm-svn: 294291
Now for real. The use case supported previously is used by approximately nobody.
What's needed is support for matching argument comments in EXPECT_xxx calls to
the names of parameters of the mocked methods.
llvm-svn: 294193
Fixes PR30964. The old behavior can be achieved using a setting.
Patch by: Andras Leitereg!
Differential Revision: https://reviews.llvm.org/D28667
llvm-svn: 292938
Summary:
Test cases I've added in review D26218 were too brittle and weren't working properly.
This patch fixes this.
Reviewers: alexfh
Reviewed By: alexfh
Subscribers: cfe-commits
Patch by Nikita Kakuev!
Differential Revision: https://reviews.llvm.org/D26466
llvm-svn: 292926
Summary:
The performance-unnecessary-value-param check mangled inherited
constructors, as the constructors' parameters do not have useful source
locations. Fix this by ignoring implicit functions.
Fixes PR31684.
Reviewers: flx, alexfh, aaron.ballman
Subscribers: madsravn, JDevlieghere, cfe-commits
Differential Revision: https://reviews.llvm.org/D29018
llvm-svn: 292786
Summary:
Also ignore helpers which are defined in macro. Currently clang-move doesn't
handle macro well enough, especiall for complex macros. This patch will ignore
declarations in macros to make the behavior of clang-move more correct.
Reviewers: ioeric
Reviewed By: ioeric
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D28774
llvm-svn: 292207
Summary:
rL270567 excluded trivially copyable types from being moved by
modernize-pass-by-value, but it didn't exclude references to them.
Change types used in the tests to not be trivially copyable.
Reviewers: madsravn, aaron.ballman, alexfh
Subscribers: JDevlieghere, cfe-commits
Differential Revision: https://reviews.llvm.org/D28614
llvm-svn: 291796
Instead of just using popularity, we also take into account how similar the
path of the current file is to the path of the header.
Our first approach is to get popularity into a reasonably small scale by taking
log2 (which is roughly intuitive to how humans would bucket popularity), and
multiply that with the number of matching prefix path fragments of the included
header with the current file.
Note that currently we do not take special care for unclean paths containing
"../" or "./".
Differential Revision: https://reviews.llvm.org/D28548
llvm-svn: 291664
Summary:
Default member initializers cannot refer to constructor parameters, but modernize-default-member-init was trying to when the default constructor had default arguments.
Change the check to ignore default arguments to the default constructor.
Fixes PR31524.
Reviewers: alexfh, aaron.ballman
Subscribers: cfe-commits, JDevlieghere, Eugene.Zelenko
Differential Revision: https://reviews.llvm.org/D28287
llvm-svn: 290972
Add a field indicating the associated check for every replacement to the YAML
report generated with the '-export-fixes' option. Update
clang-apply-replacements to handle the new format.
Patch by Alpha Abdoulaye!
Differential revision: https://reviews.llvm.org/D26137
llvm-svn: 290893
Summary:
Instead of moving all the helper declarations blindly, this patch
implements an AST-based call graph solution to make clang-move only move used
helper decls to new.cc and remove unused decls in old.cc.
Depends on D27674.
Reviewers: ioeric
Subscribers: mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D27673
llvm-svn: 290873
This check detects and fixes redundant null checks before deletes.
Patch by: Gergely Angeli!
Differential Revision: https://reviews.llvm.org/D21298
llvm-svn: 290784
I have a created a new check for clang tidy: misc-string-compare. This will check for incorrect usage of std::string::compare when used to check equality or inequality of string instead of the string equality or inequality operators.
Example:
```
std::string str1, str2;
if (str1.compare(str2)) {
}
```
Reviewers: hokein, aaron.ballman, alexfh, malcolm.parsons
Subscribers: xazax.hun, Eugene.Zelenko, cfe-commits, malcolm.parsons, Prazek, mgorny, JDevlieghere
Differential Revision: https://reviews.llvm.org/D27210
llvm-svn: 290747
The checker detects various cases when an enum is probably misused
(as a bitmask).
Patch by: Peter Szecsi!
Differential Revision: https://reviews.llvm.org/D22507
llvm-svn: 290600