Commit Graph

56 Commits

Author SHA1 Message Date
Alexander Kornienko b101c39f58 Fixed two issues in clang-tidy -help.
HeaderFilter -> HeaderFilterRegex

llvm-svn: 364837
2019-07-01 18:55:10 +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
Roman Lebedev 819bedf3a1 [clang-tidy] A new OpenMP module
Summary:
Just the empty skeleton.
Previously reviewed as part of D57113.

Reviewers: JonasToth, aaron.ballman, alexfh, xazax.hun, hokein, gribozavr

Reviewed By: JonasToth, gribozavr

Subscribers: jdoerfert, mgorny, rnkovacs, guansong, arphaman, cfe-commits

Tags: #clang-tools-extra, #openmp, #clang

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

llvm-svn: 356800
2019-03-22 19:46:01 +00:00
Alexander Kornienko 958837c640 [clang-tidy] Fix links in docs.
llvm-svn: 354266
2019-02-18 12:50:35 +00:00
Alexander Kornienko 68d5652380 [clang-tidy] Expand and clarify the NOLINT documentation a bit.
llvm-svn: 353382
2019-02-07 10:34:43 +00:00
Eugene Zelenko b272ec1347 [Documentation] Use HTTPS whenever possible.
Differential revision: https://reviews.llvm.org/D56926

llvm-svn: 351862
2019-01-22 19:19:48 +00:00
Alexander Kornienko 73eb326203 [clang-tidy] Fix whitespace in docs. NFC
Actually, just testing commits via monorepo ;)

llvm-svn: 351814
2019-01-22 12:59:34 +00:00
Eugene Zelenko fb877cb9f2 [Documentation] Add a chapter about Clang-tidy integrations.
Patch by Marina Kalashina.

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

llvm-svn: 351463
2019-01-17 18:31:34 +00:00
Alexander Kornienko 3885b49b8e [clang-tidy] Add a separate section for NOLINT(NEXTLINE)? doc.
llvm-svn: 345049
2018-10-23 16:48:16 +00:00
Zinovy Nis 7ce9334ad7 [clang-tidy][docs] Update docs for `--check-suffixes`
Differential Revision: https://reviews.llvm.org/D52971

llvm-svn: 344016
2018-10-09 05:48:57 +00:00
Stephen Kelly a3c4206e41 [clang-tidy] Build it even without static analyzer
Conditionally compile the parts of clang-tidy which depend on the static
analyzer.

Funnily enough, I made the patch to exclude this from the build in 2013,
and it was committed with the comment that the tool should not be fully
excluded, but only the parts of it which depend on the analyzer should
be excluded.

 http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20130617/081797.html

This commit implements that idea.

Reviewed By: aaron.ballman

Tags: #clang-tools-extra

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

llvm-svn: 343528
2018-10-01 20:24:22 +00:00
Aaron Ballman 873a50901b Reverting r343415 as it breaks at least one of the bots.
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/37336

llvm-svn: 343418
2018-09-30 17:39:39 +00:00
Aaron Ballman bc70c26ef4 Allow clang-tidy to be built without a dependency on the clang static analyzer.
Patch by Stephen Kelly.

llvm-svn: 343415
2018-09-30 17:22:58 +00:00
Haojian Wu 3425cdc69b [clang-tidy] Add Abseil prefix to documentation
Summary: Adds the Abseil prefix to the list of prefixes in the documentation

Patch by Deanna Garcia!

Reviewers: aaron.ballman, hokein

Reviewed By: hokein

Subscribers: xazax.hun, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 340412
2018-08-22 14:03:30 +00:00
Roman Lebedev 70fcafc096 [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
Summary:
Currently, there is two configured prefixes: `CHECK-FIXES` and `CHECK-MESSAGES`
`CHECK-MESSAGES` checks that there are no test output lines with `warning:|error:`, which are not explicitly handled in lit tests.
However there does not seem to be a nice way to enforce for all the `note:` to be checked.
This was useful for me when developing D36836.

Reviewers: alexfh, klimek, aaron.ballman, hokein

Reviewed By: alexfh, aaron.ballman

Subscribers: JonasToth, JDevlieghere, xazax.hun, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 339437
2018-08-10 15:05:46 +00:00
Roman Lebedev a87f1d04ce [clang-tidy] Store checks profiling info as JSON files
Summary:
Continuation of D46504.

Example output:
```
  $ clang-tidy -enable-check-profile -store-check-profile=. -checks=-*,readability-function-size source.cpp
  $ # Note that there won't be timings table printed to the console.
  $ cat *.json
  {
  "file": "/path/to/source.cpp",
  "timestamp": "2018-05-16 16:13:18.717446360",
  "profile": {
    "time.clang-tidy.readability-function-size.wall": 1.0421266555786133e+00,
    "time.clang-tidy.readability-function-size.user": 9.2088400000005421e-01,
    "time.clang-tidy.readability-function-size.sys": 1.2418899999999974e-01
  }
  }
```

There are two arguments that control profile storage:

* `-store-check-profile=<prefix>`

  By default reports are printed in tabulated format to stderr. When this option
  is passed, these per-TU profiles are instead stored as JSON.
  If the prefix is not an absolute path, it is considered to be relative to the
  directory from where you have run :program:`clang-tidy`. All `.` and `..`
  patterns in the path are collapsed, and symlinks are resolved.

  Example:
  Let's suppose you have a source file named `example.cpp`, located in
  `/source` directory.

  * If you specify `-store-check-profile=/tmp`, then the profile will be saved
    to `/tmp/<timestamp>-example.cpp.json`

  * If you run :program:`clang-tidy` from within `/foo` directory, and specify
    `-store-check-profile=.`, then the profile will still be saved to
    `/foo/<timestamp>-example.cpp.json`

Reviewers: alexfh, sbenza, george.karpenkov, NoQ, aaron.ballman

Reviewed By: alexfh, george.karpenkov, aaron.ballman

Subscribers: Quuxplusone, JonasToth, aaron.ballman, llvm-commits, rja, Eugene.Zelenko, xazax.hun, mgrang, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 334101
2018-06-06 15:07:51 +00:00
Alexander Kornienko 8d4bc72788 [clang-tidy] Remove AnalyzeTemporaryDtors option.
Remove the `AnalyzeTemporaryDtors` option, since the corresponding
`cfg-temporary-dtors` option of the Static Analyzer defaults to `true` since
r326461.

llvm-svn: 331456
2018-05-03 14:40:37 +00:00
Zinovy Nis eba2857bed [clang-tidy] Customize FileCheck prefix in check_clang-tidy.py
The patch introduces a new command line option '-check-suffix' for check_clang_tidy.py 
to allow multiple %check_clang_tidy% in a single test file.

Sample:

// RUN: %check_clang_tidy -check-suffix=FLAG-1 %s misc-unused-using-decls %t -- -- <options-set-1>
// RUN: %check_clang_tidy -check-suffix=FLAG-2 %s misc-unused-using-decls %t -- -- <options-set-2> 
...
+// CHECK-MESSAGES-FLAG-1: :[[@LINE-4]]:10: warning: using decl 'B' is unused [misc-unused-using-decls]
+// CHECK-MESSAGES-FLAG-2: :[[@LINE-7]]:10: warning: using decl 'A' is unused [misc-unused-using-decls]
+// CHECK-FIXES-FLAG-1-NOT: using a::A;$
+// CHECK-FIXES-FLAG-2-NOT: using a::B;$

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

llvm-svn: 330511
2018-04-21 15:23:56 +00:00
Julie Hockett b6f7c934ac [clang-tidy] Add Zircon module to clang-tidy
Adding a Zircon module to clang-tidy for checks specific to the Zircon
kernel, and adding a checker to fuchsia-zx (for zircon) to flag instances
where specific objects are temporarily created.

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

llvm-svn: 327590
2018-03-14 23:47:50 +00:00
Fangrui Song c0e768df90 [clang-tidy] Add "portability" module and rename readability-simd-intrinsics to portability-simd-intrinsics
Reviewers: alexfh

Subscribers: klimek, nemanjai, mgorny, xazax.hun, kbarton, cfe-commits

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

llvm-svn: 326909
2018-03-07 16:57:42 +00:00
Aaron Ballman 3d161ab6f4 Add support for NOLINT and NOLINTNEXTLINE comments mentioning specific check names.
Supports a comma-separated list of check names to be disabled on the given line. Also supports * as a wildcard to disable all lint diagnostic messages on that line.

Patch by Anton (xgsa).

llvm-svn: 320713
2017-12-14 16:13:57 +00:00
Aaron Ballman d3d78b903a Add a new clang-tidy module for Fuchsia as an umbrella to diagnose issues with the Fuschia and Zircon coding guidelines (https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md). Adds the first of such checkers, which detects when default arguments are declared in a function declaration or when default arguments are used at call sites.
Patch by Julie Hockett

llvm-svn: 319225
2017-11-28 21:09:25 +00:00
Haojian Wu abcd64ccbf [clang-tidy ObjC] [1/3] New module `objc` for Objective-C checks
Summary:
This is part 1 of 3 of a series of changes to improve Objective-C
linting in clang-tidy.

This introduces a new clang-tidy module, `objc`, specifically for
Objective-C / Objective-C++ checks.

The module is currently empty; D39142 adds the first check.

Test Plan: `ninja check-clang-tools`

Patch by Ben Hamilton!

Reviewers: hokein, alexfh

Reviewed By: hokein

Subscribers: Wizard, mgorny

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

llvm-svn: 316643
2017-10-26 08:23:20 +00:00
Gabor Horvath 829e75a037 [clang-tidy] Add bugprone-suspicious-memset-usage check
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
2017-07-14 12:15:55 +00:00
Yan Wang 36206206cd [clang-tidy][Part1] Add a new module Android and three new checks.
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/D33745
https://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
2017-06-23 21:37:29 +00:00
Eugene Zelenko eed5f028ee [Documentation] Mention hicpp check group in Clang-tidy main document.
llvm-svn: 303884
2017-05-25 17:22:29 +00:00
Alexander Kornienko 215604c252 [clang-tidy] Update docs and help message
llvm-svn: 299651
2017-04-06 14:27:00 +00:00
Alexander Kornienko 17a4b2344e [clang-tidy] Format code around applied fixes
Summary:
Add -format option (disabled by default for now) to trigger formatting
of replacements.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: kimgr, malcolm.parsons, JDevlieghere, cfe-commits

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

llvm-svn: 296864
2017-03-03 11:16:34 +00:00
David L. Jones dc54df9ca2 Adds the commandline need to run clang-tidy tests.
Patch by Jorge Gorbe (lethalantidote)

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

llvm-svn: 294689
2017-02-10 01:48:43 +00:00
Eugene Zelenko 834bb0e3b5 [Clang-tidy documentation] Consistency (fix-it); 80 characters per line.
llvm-svn: 293234
2017-01-26 23:58:21 +00:00
James Dennett e772e06686 Extend documentation of how to test clang-tidy checks.
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
2017-01-02 21:45:34 +00:00
Alexander Kornienko 1647f3855f Remove trailing whitespace in docs and clang-tidy sources.
llvm-svn: 289547
2016-12-13 16:38:45 +00:00
Jonas Devlieghere 7319184946 [clang-tidy] Make format style customizable
Summary: I came across an outstanding FIXME to make the format style customizable. Inspired by the include fixer, I added an new option `-style` to configure the fallback style in case no clang-format configuration file is found. The default remains "llvm". 

Reviewers: Prazek, aaron.ballman, hokein, alexfh

Subscribers: cfe-commits, malcolm.parsons

Tags: #clang-tools-extra

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

llvm-svn: 288258
2016-11-30 18:06:42 +00:00
Malcolm Parsons 5831a00634 [docs] Remove doubled spaces
Reviewers: aaron.ballman

Subscribers: nemanjai, cfe-commits

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

llvm-svn: 287226
2016-11-17 14:26:45 +00:00
Alexander Kornienko a6a52b2d63 [clang-tidy docs] Minor formatting changes.
llvm-svn: 286404
2016-11-09 22:31:07 +00:00
Alexander Kornienko 967f753e10 [clang-tidy docs] Recommend using add_new_check.py more
llvm-svn: 286390
2016-11-09 20:03:30 +00:00
Alexander Kornienko ed999fe0b2 Remove mentions of clang-analyzer-alpha
llvm-svn: 286257
2016-11-08 18:12:56 +00:00
Haojian Wu e5555e217c [clang-tidy] Add doc for `explain-config` option.
llvm-svn: 282158
2016-09-22 14:36:43 +00:00
Alexander Kornienko 76eae751b5 [clang-tidy docs] Fix build errors on Sphinx 1.4.5
llvm-svn: 279049
2016-08-18 11:06:09 +00:00
Eugene Zelenko c139a1c252 [Documentation] Remove duplicated checks groups descriptions from clang-tidy/index.rst.
Differential revision: https://reviews.llvm.org/D23596

llvm-svn: 279006
2016-08-17 23:20:00 +00:00
Eugene Zelenko d09a44a220 [Documentation] Improve checks groups descriptions in clang-tidy/index.rst
Use table to avoid tautology. List all existing checks groups. Use alphabetical order.

Differential revision: https://reviews.llvm.org/D23471

llvm-svn: 278686
2016-08-15 17:44:29 +00:00
Eugene Zelenko 7fa868b31d [Documentation] Fix grammar mistakes in docs/clang-tidy/index.rst spotted by Alexander Kornienko.
llvm-svn: 278255
2016-08-10 18:02:15 +00:00
Eugene Zelenko b614148024 [Documentation] Fix spelling mistakes in docs/clang-tidy/index.rst.
llvm-svn: 278198
2016-08-10 01:55:51 +00:00
Piotr Padlewski 5625f65667 Add boost-use-to-string
http://reviews.llvm.org/D18136

llvm-svn: 268079
2016-04-29 17:58:29 +00:00
Alexander Kornienko 5d84978251 [clang-tidy] Minor change in the doc
llvm-svn: 261998
2016-02-26 10:24:29 +00:00
Alexander Kornienko 6bb4b88216 [clang-tidy] Updated docs on testing clang-tidy checks.
llvm-svn: 261622
2016-02-23 09:30:20 +00:00
Alexander Kornienko 10f3cf54cb [clang-tidy] Describe modules, link to LLVM development docs, other minor updates
llvm-svn: 261431
2016-02-20 11:42:13 +00:00
Alexander Kornienko c1587dcf4d [clang-tidy] Reshuffled paragraphs a bit, added contents.
llvm-svn: 260100
2016-02-08 15:09:39 +00:00