Summary:
This patch makes modernize-use-emplace remove unnecessary make_ calls from push_back calls and turn them into emplace_back -- the same way make_pair calls are handled.
Custom make_ calls can be removed for custom tuple-like types -- two new options that control that are `TupleTypes` and `TupleMakeFunctions`. By default, the check removes calls to `std::make_pair` and `std::make_tuple`.
Eq.
```
std::vector<std::tuple<int, char, bool>> v;
v.push_back(std::make_tuple(1, 'A', true)); // --> v.emplace_back(1, 'A', true);
```
Reviewers: alexfh, aaron.ballman, Prazek, hokein
Reviewed By: Prazek
Subscribers: JDevlieghere, xazax.hun, JonasToth, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D32690
llvm-svn: 303145
Summary:
This patch makes modernize-use-emplace remove unnecessary make_ calls from push_back calls and turn them into emplace_back -- the same way make_pair calls are handled.
Custom make_ calls can be removed for custom tuple-like types -- two new options that control that are `TupleTypes` and `TupleMakeFunctions`. By default, the check removes calls to `std::make_pair` and `std::make_tuple`.
Eq.
```
std::vector<std::tuple<int, char, bool>> v;
v.push_back(std::make_tuple(1, 'A', true)); // --> v.emplace_back(1, 'A', true);
```
Reviewers: alexfh, aaron.ballman, Prazek, hokein
Reviewed By: Prazek
Subscribers: JDevlieghere, xazax.hun, JonasToth, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D32690
llvm-svn: 303139
This check flags postfix operator++/-- declarations,
where the return type is not a const object.
Differential Revision: https://reviews.llvm.org/D32743
llvm-svn: 302637
Summary:
And also enable it by default to be consistent with e.g.
modernize-use-using.
This helps e.g. when running this check on cppunit client code where the
macro is provided by the system, so there is no easy way to modify it.
Reviewers: alexfh, malcolm.parsons
Reviewed By: malcolm.parsons
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D32945
llvm-svn: 302429
Summary:
Add a simple documentation page for Clangd.
This will be useful for interested users and contributors to get basic information about how
to get started and the progress of Clangd.
Reviewers: krasimir, bkramer
Reviewed By: krasimir
Subscribers: Prazek, jbcoe, JDevlieghere, mgehre, JonasToth, kromanenkov, xazax.hun, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D31887
llvm-svn: 302191
Summary:
When there is a push_back with a call to make_pair, turn it into emplace_back and remove the unnecessary make_pair call.
Eg.
```
std::vector<std::pair<int, int>> v;
v.push_back(std::make_pair(1, 2)); // --> v.emplace_back(1, 2);
```
make_pair doesn't get removed when explicit template parameters are provided, because of potential problems with type conversions.
Reviewers: Prazek, aaron.ballman, hokein, alexfh
Reviewed By: Prazek, alexfh
Subscribers: JDevlieghere, JonasToth, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D32395
llvm-svn: 301651
This check will find occurrences of ``std::random_shuffle`` and replace it with ``std::shuffle``. In C++17 ``std::random_shuffle`` will no longer be available and thus we need to replace it.
Example of case that it fixes
```
std::vector<int> v;
// First example
std::random_shuffle(vec.begin(), vec.end());
```
Reviewers: hokein, aaron.ballman, alexfh, malcolm.parsons, mclow.lists
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D30158
llvm-svn: 301167
Summary:
The "performance-inefficient-vector-operation" check finds vector oprations in
for-loop statements which may cause multiple memory reallocations.
This is the first version, only detects typical for-loop:
```
std::vector<int> v;
for (int i = 0; i < n; ++i) {
v.push_back(i);
}
// or
for (int i = 0; i < v2.size(); ++i) {
v.push_back(v2[i]);
}
```
We can extend it to handle more cases like for-range loop in the future.
Reviewers: alexfh, aaron.ballman
Reviewed By: aaron.ballman
Subscribers: zaks.anna, Eugene.Zelenko, mgorny, cfe-commits, djasper
Differential Revision: https://reviews.llvm.org/D31757
llvm-svn: 300534
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:
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:
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
The 'Limitations' section in thedocumentation for
readability-misleading-indentation should be a subsection, as otherwise the link
to 'Limitations' isn't indented in the 'Clang-Tidy Checks' documentation page.
llvm-svn: 295471
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:
Docs for clang::Decl and clang::TemplateSpecializationType have
not been generated since LLVM_ALIGNAS was added to them.
Tell Doxygen to expand LLVM_ALIGNAS to nothing as described at
https://www.stack.nl/~dimitri/doxygen/manual/preprocessing.html
Reviewers: aaron.ballman, klimek, alexfh
Subscribers: ioeric, cfe-commits
Differential Revision: https://reviews.llvm.org/D28850
llvm-svn: 292484
Summary:
The documentation assumed expertise with FileCheck; many clang-tidy check
authors may not have significant exposure to FileCheck, and so it's worth
spending a few more words here to spell things out.
Reviewers: alexfh
Subscribers: cfe-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D28189
llvm-svn: 290838
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