Created new module bugprone and placed the check in that.
Finds memset() calls with potential mistakes in their arguments.
Replaces and extends the existing google-runtime-memset-zero-length check.
Cases covered:
* Fill value is a character '0'. Integer 0 might have been intended.
* Fill value is out of char range and gets truncated.
* Byte count is zero. Potentially swapped with the fill value argument.
Patch by: Reka Nikolett Kovacs
Differential Revision: https://reviews.llvm.org/D32700
llvm-svn: 308020
Summary:
To get properly integration Clang-Tidy with CLion IDE, next things were implemented:
* Preserve `Message`, `FileOffset`, `FilePath` in the clang-tidy output.
* Export all diagnostics, not just the ones with fixes
* Test-cases
Reviewers: alexfh, ilya-biryukov
Subscribers: mgorny, JDevlieghere, xazax.hun, cfe-commits
Tags: #clang-tools-extra
Patch by Vladimir Plyashkun!
Differential Revision: https://reviews.llvm.org/D35349
llvm-svn: 308015
Tests would go flaky if;
1. Using %T (not %t)
2. Put a file with common name like header.h into %T
3. Other tests (eg. misc-unused-parameters.cpp) are doing as well
We should avoid using %T unless it really makes sense.
llvm-svn: 307876
Summary: socket() is better to include SOCK_CLOEXEC in its type argument to avoid the file descriptor leakage.
Reviewers: chh, Eugene.Zelenko, alexfh, hokein, aaron.ballman
Reviewed By: chh, alexfh
Subscribers: srhines, mgorny, JDevlieghere, xazax.hun, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D34913
llvm-svn: 307818
Summary:
The URI conversion logic was returning 'undefined' when going from server to
VSCode which broke the Go to Definition functionality.
Reviewers: krasimir
Reviewed By: krasimir
Subscribers: cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D35215
llvm-svn: 307715
* test that no diagnostics are redirected to stderr
* test that a file-based compilation database is not picked up when the
command line after -- contains an error
llvm-svn: 307661
Summary: In this case, users currently get a confusing type error. Make the error message more obvious.
Reviewers: klimek
Reviewed By: klimek
Differential Revision: https://reviews.llvm.org/D35197
llvm-svn: 307535
Summary:
For the following code: `modernize-use-override` generates a replacement with incorrect location.
```
struct IntPair
{
int first, second;
};
struct A
{
virtual void il(IntPair);
};
struct B : A
{
void il(IntPair p = {1, (2 + 3)}) {};
// Generated Fixit: void il(IntPair p = override {1, (2 + 3)}) {};
// Should be: void il(IntPair p = {1, (2 + 3)}) override {};
};
```
This fixes that and adds a unit test.
Reviewers: alexfh, aaron.ballman, hokein
Reviewed By: alexfh
Subscribers: JDevlieghere, xazax.hun, cfe-commits
Tags: #clang-tools-extra
Patch by Victor Gao!
Differential Revision: https://reviews.llvm.org/D35078
llvm-svn: 307379
Summary:
This patch adds the ability to specify user-defined extra flags per opened file
through the LSP layer. This is a non-standard extension to the protocol.
I've already created a feature request about it for upstream lsp:
https://github.com/Microsoft/language-server-protocol/issues/255
The particular use-case is ycmd, which has a python script for figuring out
extra flags per file:
https://github.com/Valloric/ycmd#flagsforfile-filename-kwargs-
Reviewers: ilya-biryukov, klimek, bkramer
Reviewed By: ilya-biryukov
Subscribers: cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D34947
llvm-svn: 307241
This is a short-term fix for PR33650 aimed to get the modules build bots green again.
Remove all the places where we use the LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR
macros to try to locally specialize a global template for a global type. That's
not how C++ works.
Instead, we now centrally define how to format vectors of fundamental types and
of string (std::string and StringRef). We use flow formatting for the former
cases, since that's the obvious right thing to do; in the latter case, it's
less clear what the right choice is, but flow formatting is really bad for some
cases (due to very long strings), so we pick block formatting. (Many of the
cases that were using flow formatting for strings are improved by this change.)
Other than the flow -> block formatting change for some vectors of strings,
this should result in no functionality change.
Differential Revision: https://reviews.llvm.org/D34907
Corresponding LLVM change is r306878.
llvm-svn: 306879
clang-apply-replacements tests
The ClassReplacements.cpp test in the clang-rename tests uses
clang-apply-replacements. I moved it back to the clang-tools-extra repository
for now to ensure that the clang-rename tests can pass when clang is compiled
without clang-tools-extra.
llvm-svn: 306843
Summary:
1. Rename android-file-open-flag to android-cloexec-open.
2. Handle a case when the function is passed as an argument of a function-like macro.
Reviewers: chh
Reviewed By: chh
Subscribers: srhines, mgorny, JDevlieghere, xazax.hun, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D34633
llvm-svn: 306728
Summary:
A follow-up on D34449:
* add `-std=c++11` to `.hpp` file by default.
* add constexpr function to test and doc.
Reviewers: alexfh
Reviewed By: alexfh
Subscribers: JDevlieghere, xazax.hun, cfe-commits
Differential Revision: https://reviews.llvm.org/D34771
llvm-svn: 306650
* Enforce 80 characters limit where appropriate
* Use slightly more descriptive names for searched locations
* Update docs to reflect D34269, which adds "Go To Declaration" functionality
llvm-svn: 306598
Summary: This change allows to navigate to most identifiers' declarations in code. This is a first step towards implementing "Go to Definition". It reuses clangIndex in order to detect which occurrences corresponds to the position requested. The occurrences' Decls are then used to generate locations suitable for navigating to the declarations.
Reviewers: krasimir, bkramer, ilya-biryukov
Reviewed By: ilya-biryukov
Subscribers: cfe-commits, mgorny
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D34269
llvm-svn: 306558
D31709 [NFC] Refactor DiagnosticRenderer to use FullSourceLoc was committed
in r305684 and reverted in 305688 as clang-tidy and clang-query failed to
build. This change updates the extra tools to use the new interface.
Reviewers: christof, rnk, rsmith, rovka, alexfh
Reviewed By: alexfh
Differential Revision: https://reviews.llvm.org/D34513
llvm-svn: 306385
Summary:
If the class being created in unique_ptr is in anonymous nampespace, the
anonymous namespace will be included in the apply-fixes. This patch fix
this.
```
namespace {
class Foo {};
}
std::unique_ptr<Foo> f;
f.reset(new Foo());
// Before the change: f = std::make_unique<(annonymous namespace)::Foo>();
// After the change: f = std::make_unique<Foo>();
```
Reviewers: alexfh
Reviewed By: alexfh
Subscribers: JDevlieghere, xazax.hun, cfe-commits
Differential Revision: https://reviews.llvm.org/D34286
llvm-svn: 306378
Summary:
A common source of security bugs is code that opens a file descriptors without using the O_CLOEXEC flag. (Without that flag, an opened sensitive file would remain open across a fork+exec to a lower-privileged SELinux domain, leaking that sensitive data.).
Add a new Android module and one checks in clang-tidy.
-- open(), openat(), and open64() should include O_CLOEXEC in their flags argument. [android-file-open-flag]
Links to part2 and part3:
https://reviews.llvm.org/D33745https://reviews.llvm.org/D33747
Reviewers: chh, alexfh, aaron.ballman, hokein
Reviewed By: alexfh, hokein
Subscribers: jbcoe, joerg, malcolm.parsons, Eugene.Zelenko, srhines, mgorny, xazax.hun, cfe-commits, krytarowski
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D33304
llvm-svn: 306165
Summary:
The FP happens when a casting nullptr expression is used within a NULL-default-arguemnt cxx constructor.
Before the fix, the check will give a warning on nullptr when running
with the test case, which should not happen:
```
G(g(static_cast<char*>(nullptr)));
^~~~~~~~~~~
nullptr
```
Reviewers: alexfh
Reviewed By: alexfh
Subscribers: cfe-commits, xazax.hun
Differential Revision: https://reviews.llvm.org/D34524
llvm-svn: 306091
Summary:
A followup for D32942.
Malcolm Parsons has provided a valid testcase that the initial version of the check complained about nested `if`'s.
As it turns out, the culprit is the **partially** un-intentional `switch` fallthrough.
So rewrite the NestingThreshold logic without ab-using+mis-using that switch with fallthrough, and add testcases with nested `if`' where there should be a warning and shouldn't be a warning. This results in a cleaner, simpler code, too.
I guess, now it would be actually possible to pick some reasonable default for `NestingThreshold` setting.
Fixes PR33454.
Reviewers: malcolm.parsons, alexfh
Reviewed By: malcolm.parsons
Subscribers: sbenza, xazax.hun, cfe-commits, aaron.ballman
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D34202
llvm-svn: 305554
Summary:
This patch adds the priority of a completion item to the sort text of the
returned LSP result.
Reviewers: ilya-biryukov
Reviewed By: ilya-biryukov
Subscribers: cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D34137
llvm-svn: 305454