Commit Graph

1813 Commits

Author SHA1 Message Date
Dmitri Gribenko f717148b3a Enhance abseil-faster-strsplit-delimiter to handle other non-printable characters.
Summary:
Currently it fails on cases like '\001'.

Note: Since `StringLiteral::outputString` dumps most nonprintable
characters in octal value, the exact string literal format isn't preserved,
e.g. `"\x01"` becomes `'\001'`.

Reviewers: gribozavr

Reviewed By: gribozavr

Subscribers: lebedev.ri, Eugene.Zelenko, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D64151

Patch by Xiaoyi Zhang.

llvm-svn: 365463
2019-07-09 11:04:04 +00:00
Jian Cai 967aa5745d A test commit following 'Obtaining Commit Access' (https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access)
llvm-svn: 365380
2019-07-08 19:53:22 +00:00
Dmitri Gribenko e6020f5c62 [clang-tidy] new check: bugprone-posix-return
Summary:
Checks if any calls to posix functions (except posix_openpt) expect negative return values.
These functions return either 0 on success or an errno on failure, which is positive only.

Reviewers: JonasToth, gribozavr, alexfh, hokein

Reviewed By: gribozavr

Subscribers: Eugene.Zelenko, lebedev.ri, llozano, george.burgess.iv, xazax.hun, srhines, mgorny, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D63623

Patch by Jian Cai.

llvm-svn: 365007
2019-07-03 09:20:18 +00:00
Douglas Yung c900c46d77 [NFC] Marking test added in r363975 as unsupported on Windows.
This test references a path that does not exist on Windows causing
it to emit different output from what was expected leading to a
failure when run on Windows.

llvm-svn: 364120
2019-06-22 01:09:00 +00:00
Matthias Gehre eeb3f99d23 [clang-tidy] misc-unused-parameters: don't comment out parameter name for C code
Summary: The fixit `int square(int /*num*/)` yields `error: parameter name omitted` for C code. Enable it only for C++ code.

Reviewers: klimek, ilya-biryukov, lebedev.ri, aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D63088

llvm-svn: 364106
2019-06-21 21:30:25 +00:00
Reid Kleckner b250a62a51 Quote path to Python executable in case it has spaces
These days Python 3 is typically installed into C:/Program Files, so
cope with that.

Similar to r364077 in compiler-rt.

llvm-svn: 364087
2019-06-21 18:17:04 +00:00
Kadir Cetinkaya b9b1aaf07d [clang-tidy] Move test files of rL363975 into Inputs directory
llvm-svn: 364008
2019-06-21 07:54:27 +00:00
Serge Guelton 60ca31a7dd [clang-tidy] Fail gracefully upon empty database fields
Fix bz#42281

Differential Revision: https://reviews.llvm.org/D63613

llvm-svn: 363975
2019-06-20 20:25:59 +00:00
Aaron Puchert 44940048dd Fix more tests after r363749
Apparently -Wmissing-prototypes is used for quite a few integration
tests.

llvm-svn: 363760
2019-06-19 01:54:05 +00:00
Julie Hockett d9b3d08a9a [clang-tidy] Split fuchsia-default-arguments
Splits fuchsia-default-arguments check into two checks. fuchsia-default-arguments-calls warns if a function or method is called with default arguments. fuchsia-default-arguments-declarations warns if a function or method is declared with default parameters.

Committed on behalf of @diegoast (Diego Astiazarán).

Resolves b38051.

Differential Revision: https://reviews.llvm.org/D62437

llvm-svn: 363712
2019-06-18 18:07:33 +00:00
Dmitri Gribenko 558369b549 [clang-tidy] Made abseil-faster-strsplit-delimiter tests pass on C++17
Reviewers: hokein, gribozavr

Reviewed By: hokein, gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D63253

Patch by Johan Vikström.

llvm-svn: 363273
2019-06-13 15:16:44 +00:00
Dmitri Gribenko 0030306555 [clang-tidy] Fixed abseil-time-subtraction to work on C++17
Summary: Fixed abseil-time-subtraction to work on C++17

Reviewers: hokein, gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D63261

Patch by Johan Vikström.

llvm-svn: 363272
2019-06-13 15:11:02 +00:00
Dmitri Gribenko 93f96b2be9 [clang-tidy] Made abseil-upgrade-duration-conversions tests pass on c++17
Summary: Made abseil-upgrade-duration-conversions tests pass on c++17

Reviewers: hokein, gribozavr

Reviewed By: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D63262

Patch by Johan Vikström.

llvm-svn: 363270
2019-06-13 14:27:54 +00:00
Dmitri Gribenko ab240c5eee [clang-tidy] Fixed abseil-duration-unnecessary-conversion tests for c++17
Summary: Fixed abseil-duration-unnecessary-conversion tests for c++17

Reviewers: hokein, gribozavr

Reviewed By: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D63263

Patch by Johan Vikström.

llvm-svn: 363263
2019-06-13 13:52:45 +00:00
Dmitri Gribenko cf7d768351 Fixed a crash in misc-redundant-expression ClangTidy checker
Summary: It was trying to pass a dependent expression into constant evaluator.

Reviewers: ilya-biryukov

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D63188

llvm-svn: 363133
2019-06-12 08:40:53 +00:00
Clement Courbet f63feaf3c2 [clang-tidy] Fix typo in bugprone-string-constructor.
s/bigger then/bigger than/

llvm-svn: 363053
2019-06-11 12:12:06 +00:00
Dmitri Gribenko be20daa8eb Fixed google-readability-casting test to work in c++17
Summary: Fixed google-readability-casting.cpp to get tests working in c++17

Reviewers: gribozavr, hokein

Reviewed By: gribozavr

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D63128

Patch by Shaurya Gupta.

llvm-svn: 363047
2019-06-11 10:59:22 +00:00
Nikolai Kosjar 60e1296a9a [clang-tidy] Make the plugin honor NOLINT
Instantiate a ClangTidyDiagnosticConsumer also for the plugin case and
let it forward the diagnostics to the external diagnostic engine that is
already in place.

One minor difference to the clang-tidy executable case is that the
compiler checks/diagnostics are referred to with their original name.
For example, for -Wunused-variable the plugin will refer to the check as
"-Wunused-variable" while the clang-tidy executable will refer to that
as "clang-diagnostic- unused-variable". This is because the compiler
diagnostics never reach ClangTidyDiagnosticConsumer.

Differential Revision: https://reviews.llvm.org/D61487

llvm-svn: 362702
2019-06-06 13:13:27 +00:00
Haojian Wu df95e6109e [clang-tidy] Fix an assertion failure in misc-redundant-expression.
Summary:
The assertion "isIntegerConstantExpr" is triggered in the
isIntegerConstantExpr(), we should not call it if the expression is value
dependent.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D62947

llvm-svn: 362701
2019-06-06 12:58:48 +00:00
Haojian Wu 448acbc06f [clang-tidy] Fix make-unique tests on C++2a.
Summary:
These test cases are illgal in C++2a ("new Foo{}" needs to see the
default constructor), so move them to the C++14-only tests.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D62845

llvm-svn: 362679
2019-06-06 07:48:55 +00:00
George Burgess IV 5b2a85d0de android: add a close-on-exec check on pipe()
On Android, pipe() is better to be replaced by pipe2() with O_CLOEXEC
flag to avoid file descriptor leakage.

Patch by Jian Cai!

Differential Revision: https://reviews.llvm.org/D61967

llvm-svn: 362673
2019-06-06 05:21:45 +00:00
George Burgess IV 3da331b456 android: add a close-on-exec check on pipe2()
On Android, pipe2() is better to set O_CLOEXEC flag to avoid file
descriptor leakage.

Patch by Jian Cai!

Differential Revision: https://reviews.llvm.org/D62049

llvm-svn: 362672
2019-06-06 05:21:39 +00:00
Haojian Wu ceb0cc54f9 [clang-tidy] Fix make-unique check to work in C++17 mode.
Summary:
Previously, we intended to omit the check fix to the case when constructor has
any braced-init-list argument. But the HasListInitializedArgument was not
correct to handle all cases (Foo(Bar{1, 2}) will return false in C++14
mode).

This patch fixes it, corrects the tests, and makes the check to run at C++17 mode.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D62736

llvm-svn: 362361
2019-06-03 08:14:15 +00:00
Stephane Moore ec1982f07f Revise the google-objc-global-variable-declaration check to match the style guide.
Summary:
Revise the google-objc-global-variable-declaration check to match the style guide.

This commit updates the check as follows:
(1) Do not emit fixes for extern global constants.
(2) Allow the second character of prefixes for constants to be numeric (the new guideline is that global constants should generally be named with a prefix that begins with a capital letter followed by one or more capital letters or numbers).

https://google.github.io/styleguide/objcguide.html#prefixes

This is an amended re-submission of https://reviews.llvm.org/rG12e3726fadb0b2a4d8aeed0a2817b5159f9d029d.

Contributed By: yaqiji

Reviewers: Wizard, benhamilton, stephanemoore

Reviewed By: benhamilton, stephanemoore

Subscribers: mgorny, cfe-commits, yaqiji

Tags: #clang

Differential Revision: https://reviews.llvm.org/D62045

llvm-svn: 362279
2019-05-31 23:41:15 +00:00
Stephane Moore 9ac757bf09 Rollback "Revise the google-objc-global-variable-declaration check to match the style guide." 💥
The change introduced new test failures.

Phabricator URL of original commit: https://reviews.llvm.org/rG12e3726fadb0b2a4d8aeed0a2817b5159f9d029d

llvm-svn: 361914
2019-05-29 02:23:32 +00:00
Stephane Moore 12e3726fad Revise the google-objc-global-variable-declaration check to match the style guide.
Summary:
Revise the google-objc-global-variable-declaration check to match the style guide.

This commit updates the check as follows:
(1) Do not emit fixes for extern global constants.
(2) Allow the second character of prefixes for constants to be numeric (the new guideline is that global constants should generally be named with a prefix that begins with a capital letter followed by one or more capital letters or numbers).

https://google.github.io/styleguide/objcguide.html#prefixes

Contributed by yaqiji.

Reviewers: Wizard, benhamilton, stephanemoore

Reviewed By: benhamilton, stephanemoore

Subscribers: mgorny, cfe-commits, yaqiji

Tags: #clang

Differential Revision: https://reviews.llvm.org/D62045

llvm-svn: 361907
2019-05-29 01:36:23 +00:00
Joel E. Denny 91f8066d1d [OpenMP] Set pragma start loc to `#pragma` loc
This patch adjusts `PragmaOpenMPHandler` to set the location of
`tok::annot_pragma_openmp` to the `#pragma` location instead of the
`omp` location so that the former becomes the start location of the
OpenMP AST node.  This can be useful when, for example, rewriting a
directive using Clang's Rewrite facility.  Most of this patch updates
tests for changes to locations in diagnostics and `-ast-dump` output.

Reviewed By: ABataev, lebedev.ri, Meinersbur, aaron.ballman

Differential Revision: https://reviews.llvm.org/D61509

llvm-svn: 361867
2019-05-28 19:27:19 +00:00
Haojian Wu eb006d3268 [clang-tidy] Fix description for misc-definitions-in-headers.
Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D62524

llvm-svn: 361834
2019-05-28 14:50:42 +00:00
Haojian Wu dfc0ca0c80 [clang-tidy] Verify fix description for misc-unused-using-decl.
Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D62522

llvm-svn: 361833
2019-05-28 14:47:39 +00:00
Haojian Wu 2255b31cec [clang-tidy] Fix null pointer dereference in readability-identifier-naming
Summary:
readability-identifier-naming causes a null pointer dereference when checking an identifier introduced by a structured binding whose right hand side is an undeclared identifier.

Running the check on a file that is just the following results in a crash:
```
auto [left] = right;
```

Patch by Mark Stegeman!

Reviewers: alexfh, hokein, aaron.ballman, JonasToth

Reviewed By: hokein, aaron.ballman

Subscribers: madsravn, xazax.hun, cfe-commits

Tags: #clang-tools-extra, #clang

Differential Revision: https://reviews.llvm.org/D62404

llvm-svn: 361809
2019-05-28 11:54:01 +00:00
Mads Ravn bd324fa227 DeleteNullPointerCheck now deletes until the end brace of the condition.
Patch by Jonathan Camilleri

Differential Revision https://reviews.llvm.org/D61861

llvm-svn: 361735
2019-05-26 17:00:38 +00:00
Dmitri Gribenko b7f2a2b4c0 Make cppcoreguidelines-pro-type-member-init-use-assignment.cpp pass on platforms where char is unsigned
The other options are to completely specify the triple (reduces test
coverage), or to specify a regex that allows either '0' or '0U' for char
initializers, however, that relaxes the test.

llvm-svn: 361629
2019-05-24 10:50:15 +00:00
Dmitri Gribenko f2d5b7a4fa Made cppcoreguidelines-pro-type-member-init-use-assignment run in all language modes
llvm-svn: 361628
2019-05-24 10:39:00 +00:00
Matthias Gehre b087129b5d [clang-tidy] Add option "LiteralInitializers" to cppcoreguidelines-pro-type-member-init
Differential Revision: D24892

llvm-svn: 361601
2019-05-24 05:46:57 +00:00
Tamas Zolnai dab31924e9 [clang-tidy]: Add cert-oop54-cpp alias for bugprone-unhandled-self-assignment
Summary:
Added WarnOnlyIfThisHasSuspiciousField option to allow
to catch any copy assignment operator independently from
the container class's fields.
Added the cert alias using this option.

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: mgorny, Eugene.Zelenko, xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D62192

llvm-svn: 361550
2019-05-23 20:29:04 +00:00
Dmitri Gribenko 1520dafa20 [clang-tidy] New check calling out uses of +new in Objective-C code
Summary:
Google's Objective-C style guide forbids calling or overriding +new to instantiate objects. This check warns on violations.

Style guide reference: https://google.github.io/styleguide/objcguide.html#do-not-use-new

Patch by Michael Wyman.

Reviewers: benhamilton, aaron.ballman, JonasToth, gribozavr, ilya-biryukov, stephanemoore, mwyman

Reviewed By: aaron.ballman, gribozavr, stephanemoore, mwyman

Subscribers: stephanemoore, xazax.hun, Eugene.Zelenko, mgorny, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D61350

llvm-svn: 361487
2019-05-23 12:01:26 +00:00
Dmitri Gribenko 1e593f342f Disable the modernize-use-trailing-return-type.cpp test in C++2a mode
It is performing a use-of-uninitialized-value, as detected by MSan.

llvm-svn: 361163
2019-05-20 15:12:12 +00:00
Dmitri Gribenko cb18647b19 Run ClangTidy tests in all C++ language modes
Summary:
I inspected every test and did one of the following:

- changed the test to run in all language modes,

- added a comment explaining why the test is only applicable in a
  certain mode,

- limited the test to language modes where it passes and added a FIXME
  to fix the checker or the test.

Reviewers: alexfh, lebedev.ri

Subscribers: nemanjai, kbarton, arphaman, jdoerfert, lebedev.ri, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D62125

llvm-svn: 361131
2019-05-20 09:26:47 +00:00
Jonas Toth 792dc04166 [clang-tidy] Handle member variables in readability-simplify-boolean-expr
- Add readability-simplify-boolean-expr test cases for member variables
Fixes PR40179

Patch by LegalizeAdulthood.

Reviewers: alexfh, hokein, aaron.ballman, JonasToth

Reviewed By: JonasToth

Subscribers: jdoerfert, xazax.hun, cfe-commits

Differential Revision: https://reviews.llvm.org/D56323

llvm-svn: 360882
2019-05-16 12:35:00 +00:00
Don Hinton 4c50e64fc5 [clang-tidy] Recommit r360785 "modernize-loop-convert: impl const cast iter" with correct attribution
Summary:
modernize-loop-convert was not detecting implicit casts to
const_iterator as convertible to range-based loops:

    std::vector<int> vec{1,2,3,4}
    for(std::vector<int>::const_iterator i = vec.begin();
        i != vec.end();
        ++i) { }

Thanks to Don Hinton for advice.

As well, this change adds a note for this check's applicability to code
targeting OpenMP prior version 5 as this check will continue breaking
compilation with `-fopenmp`. Thanks to Roman Lebedev for pointing this
out.

Fixes PR#35082

Patch by Torbjörn Klatt!

Reviewed By: hintonda

Tags: #clang-tools-extra, #clang

Differential Revision: https://reviews.llvm.org/D61827

llvm-svn: 360788
2019-05-15 17:47:51 +00:00
Don Hinton 4ecb581188 Revert [clang-tidy] modernize-loop-convert: impl const cast iter
This reverts r360785 (git commit 42d28be802)

llvm-svn: 360787
2019-05-15 17:36:54 +00:00
Don Hinton 42d28be802 [clang-tidy] modernize-loop-convert: impl const cast iter
Summary:
modernize-loop-convert was not detecting implicit casts to
const_iterator as convertible to range-based loops:

    std::vector<int> vec{1,2,3,4}
    for(std::vector<int>::const_iterator i = vec.begin();
        i != vec.end();
        ++i) { }

Thanks to Don Hinton for advice.

As well, this change adds a note for this check's applicability to code
targeting OpenMP prior to version 5 as this check will continue breaking
compilation with `-fopenmp`. Thanks to Roman Lebedev for pointing this
out.

Fixes PR#35082

Reviewed By: hintonda

Tags: #clang-tools-extra, #clang

Differential Revision: https://reviews.llvm.org/D61827

llvm-svn: 360785
2019-05-15 16:58:58 +00:00
Kristof Umann 7f7dd09001 [clang-tidy] new check: bugprone-branch-clone
Implement a check for detecting if/else if/else chains where two or more
branches are Type I clones of each other (that is, they contain identical code)
and for detecting switch statements where two or more consecutive branches are
Type I clones of each other.

Patch by Donát Nagy!

Differential Revision: https://reviews.llvm.org/D54757

llvm-svn: 360779
2019-05-15 15:06:25 +00:00
Matthias Gehre 094584cd52 [clang-tidy] Fix invalid fixit for readability-static-accessed-through-instance (bug 40544)
Summary:
Fixed https://bugs.llvm.org/show_bug.cgi?id=40544
Before, we would generate a fixit like `(anonymous namespace)::Foo::fun();` for
the added test case.

Reviewers: aaron.ballman, alexfh, xazax.hun

Subscribers: rnkovacs, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D61874

llvm-svn: 360698
2019-05-14 18:23:10 +00:00
Matthias Gehre 5f9afe953d [clang-tidy] readability-redundant-declaration: fix false positive with C "extern inline"
Summary:
readability-redundant-declaration was diagnosing a redundant declaration
on "extern inline void f();", which is needed in C code to force an external definition
of the inline function f. (This is different to how inline behaves in C++).

Reviewers: alexfh, danielmarjamaki

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D61700

llvm-svn: 360613
2019-05-13 19:21:57 +00:00
Tamas Zolnai de7a30cb0a [clang-tidy] new check: bugprone-unhandled-self-assignment
Summary:
This check searches for copy assignment operators which might not handle self-assignment properly. There are three patterns of
handling a self assignment situation: self check, copy-and-swap or the less common copy-and-move. The new check warns if none of
these patterns is found in a user defined implementation.

See also:
OOP54-CPP. Gracefully handle self-copy assignment
https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP54-CPP.+Gracefully+handle+self-copy+assignment

Reviewers: JonasToth, alexfh, hokein, aaron.ballman

Subscribers: riccibruno, Eugene.Zelenko, mgorny, xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D60507

llvm-svn: 360540
2019-05-12 12:23:56 +00:00
Aaron Ballman 61c0daa007 Recommit r360345 with fixes (was reverted in r360348).
Add the modernize-use-trailing-return check to rewrite function signatures to use trailing return types.

Patch by Bernhard Manfred Gruber.

llvm-svn: 360438
2019-05-10 16:24:28 +00:00
Dmitri Gribenko 4bf8632c45 check_clang_tidy.py now passes `-format-style=none` to clang_tidy
Summary:
If the test does not specify a formatting style, force "none"; otherwise
autodetection logic can discover a ".clang-tidy" file that is not
related to the test.

Reviewers: alexfh

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D61739

llvm-svn: 360358
2019-05-09 17:08:10 +00:00
Aaron Ballman 0268083329 Revert r360345 and r360346, as they are not passing the testbots.
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/48063/steps/test/logs/stdio

llvm-svn: 360348
2019-05-09 15:06:41 +00:00
Aaron Ballman 8e015b2e94 Add the modernize-use-trailing-return check to rewrite function signatures to use trailing return types.
Patch by Bernhard Manfred Gruber.

llvm-svn: 360345
2019-05-09 14:48:17 +00:00