summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/plugin
Commit message (Collapse)AuthorAgeFilesLines
* clang-tidy: Don't repeat list of all checks in three places.Nico Weber2019-09-271-26/+1
| | | | | | | | | | | | Instead, put all checks in a cmake variable and reference this. Also, make clangd use the the ClangTidyForceLinker.h header instead of duplicating the list of modules -- the duplicate copy was missing the new "darwin" checker added in r373065. Differential Revision: https://reviews.llvm.org/D68132 llvm-svn: 373082
* [clang-tidy] New check to warn when storing dispatch_once_t in non-static, ↵Dmitri Gribenko2019-09-271-0/+1
| | | | | | | | | | | | | | | | | | | | | non-global storage. Summary: Creates a new darwin ClangTidy module and adds the darwin-dispatch-once-nonstatic check that warns about dispatch_once_t variables not in static or global storage. This catches a missing static for local variables in e.g. singleton initialization behavior, and also warns on storing dispatch_once_t values in Objective-C instance variables. C/C++ struct/class instances may potentially live in static/global storage, and are ignored for this check. The osx.API static analysis checker can find the non-static storage use of dispatch_once_t; I thought it useful to also catch this issue in clang-tidy when possible. This is a re-land of https://reviews.llvm.org/D67567 Reviewers: thakis, gribozavr, stephanemoore Subscribers: Eugene.Zelenko, mgorny, xazax.hun, jkorous, arphaman, kadircet, usaxena95 Tags: #clang-tools-extra, #clang, #llvm Differential Revision: https://reviews.llvm.org/D68109 llvm-svn: 373065
* Revert "[clang-tidy] New check to warn when storing dispatch_once_t in ↵Dmitri Gribenko2019-09-261-1/+0
| | | | | | | | non-static, non-global storage" This reverts commit r373028, because the new test fails on Linux. llvm-svn: 373032
* [clang-tidy] New check to warn when storing dispatch_once_t in non-static, ↵Stephane Moore2019-09-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | non-global storage Summary: Creates a new darwin ClangTidy module and adds the darwin-dispatch-once-nonstatic check that warns about dispatch_once_t variables not in static or global storage. This catches a missing static for local variables in e.g. singleton initialization behavior, and also warns on storing dispatch_once_t values in Objective-C instance variables. C/C++ struct/class instances may potentially live in static/global storage, and are ignored for this check. The osx.API static analysis checker can find the non-static storage use of dispatch_once_t; I thought it useful to also catch this issue in clang-tidy when possible. Contributed By: mwyman Reviewers: benhamilton, hokein, stephanemoore, aaron.ballman, gribozavr Reviewed By: stephanemoore, gribozavr Subscribers: jkorous, arphaman, kadircet, usaxena95, NoQ, xazax.hun, lebedev.ri, mgorny, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D67567 llvm-svn: 373028
* [clang-tools-extra] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-4/+4
| | | | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368944
* [clang-tidy] Add a module for the Linux kernel.Tom Roeder2019-07-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Now that clang is going to be able to build the Linux kernel again on x86, and we have gen_compile_commands.py upstream for generating compile_commands.json, clang-tidy can be used on the Linux kernel source. To that end, this commit adds a new clang-tidy module to be used for checks specific to Linux kernel source. The Linux kernel follows its own style of C, and it will be useful to separate those checks into their own module. This also adds an initial check that makes sure that return values from the kernel error functions like PTR_ERR and ERR_PTR are checked. It also makes sure that any functions that directly return values from these functions are checked. Subscribers: xazax.hun, gribozavr, Eugene.Zelenko, lebedev.ri, mgorny, jdoerfert, cfe-commits Tags: #clang, #clang-tools-extra Reviewers: aaron.ballman, alexfh, hokein, JonasToth Differential Revision: https://reviews.llvm.org/D59963 llvm-svn: 367071
* [clang-tidy] Make the plugin honor NOLINTNikolai Kosjar2019-06-061-6/+17
| | | | | | | | | | | | | | | | | 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
* [clang-tidy] A new OpenMP moduleRoman Lebedev2019-03-221-0/+1
| | | | | | | | | | | | | | | | | | 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
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [clang-tidy] Remove extra config.h includesIvan Donchevskii2018-12-141-1/+0
| | | | | | | | | It's included in a new header ClangTidyForceLinker.h and should not be included the second time. Follow up for the https://reviews.llvm.org/D55595 llvm-svn: 349132
* [clang-tidy] Share the forced linking code between clang-tidy tool and pluginIvan Donchevskii2018-12-141-93/+1
| | | | | | | | | Extract code that forces linking to the separate header and include it in both plugin and standalone tool. Try 2: missing header guard and "clang/Config/config.h" are added to the new header. Differential Revision: https://reviews.llvm.org/D55595 llvm-svn: 349131
* Revert "[clang-tidy] Share the forced linking code between clang-tidy tool ↵Douglas Yung2018-12-141-1/+93
| | | | | | | | | | | and plugin" This reverts commit r349038 as it was causing test failures: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/22185 http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/40886 llvm-svn: 349121
* [clang-tidy] Share the forced linking code between clang-tidy tool and pluginIvan Donchevskii2018-12-131-93/+1
| | | | | | | | Extract code that forces linking to the separate header and include it in both plugin and standalone tool Differential Revision: https://reviews.llvm.org/D55595 llvm-svn: 349038
* [clang-tidy] Untangle layering in ClangTidyDiagnosticConsumer somewhat. NFCSam McCall2018-11-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Summary: Clang's hierarchy is CompilerInstance -> DiagnosticsEngine -> DiagnosticConsumer. (Ownership is optional/shared, but this structure is fairly clear). Currently ClangTidyDiagnosticConsumer *owns* the DiagnosticsEngine: - this inverts the hierarchy, which is confusing - this means ClangTidyDiagnosticConsumer() mutates the passed-in context, which is both surprising and limits flexibility - it's not possible to use a different DiagnosticsEngine with ClangTidy This means a little bit more code in the places ClangTidy is used standalone, but more flexibility in using ClangTidy with other diagnostics configurations. Reviewers: hokein Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D54033 llvm-svn: 346418
* [clang-tidy] Remove false decoupling in ClangTidyContext. NFCSam McCall2018-10-311-1/+1
| | | | | | | These getters/setters don't encapsulate any behavior, and can only be called by friends. llvm-svn: 345716
* [clang-tidy] Build it even without static analyzerStephen Kelly2018-10-012-1/+9
| | | | | | | | | | | | | | | | | | | | | | 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
* Reverting r343415 as it breaks at least one of the bots.Aaron Ballman2018-09-302-8/+1
| | | | | | http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/37336 llvm-svn: 343418
* Allow clang-tidy to be built without a dependency on the clang static analyzer.Aaron Ballman2018-09-302-1/+8
| | | | | | Patch by Stephen Kelly. llvm-svn: 343415
* [clang-tidy] add all clang-tidy modules to pluginJonas Toth2018-07-312-11/+45
| | | | | | | | | | | | | | | | Summary: This patch addresses PR38359 and adds all existing clang-tidy modules to the plugin that can be used together with libclang. Reviewers: alexfh, aaron.ballman, hokein, ilya-biryukov Reviewed By: alexfh Subscribers: srhines, mgorny, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D50060 llvm-svn: 338393
* [clang-tidy] Add check: replace string::find(...) == 0 with absl::StartsWithHaojian Wu2018-03-091-0/+1
| | | | | | | | | | | | Patch by Niko Weh! Reviewers: hokein Subscribers: klimek, cfe-commits, ioeric, ilya-biryukov, ahedberg Differential Revision: https://reviews.llvm.org/D43847 llvm-svn: 327111
* [clang-tidy] Add "portability" module and rename readability-simd-intrinsics ↵Fangrui Song2018-03-072-0/+6
| | | | | | | | | | | | 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
* [clang-tidy ObjC] [1/3] New module `objc` for Objective-C checksHaojian Wu2017-10-262-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* [clang-tidy][Part1] Add a new module Android and three new checks.Yan Wang2017-06-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* [clang-tidy] fix missing anchor for MPI ModulePiotr Padlewski2016-12-161-0/+5
| | | | | | | | | | | | Summary: MPIModule was not linked to plugins Reviewers: alexfh, Alexander_Droste, hokein Subscribers: JDevlieghere, cfe-commits Differential Revision: https://reviews.llvm.org/D27813 llvm-svn: 289930
* [clang-tidy] MPITypeMismatchCheckAlexander Kornienko2016-08-021-0/+1
| | | | | | | | | | | | | | | | This check verifies if buffer type and MPI (Message Passing Interface) datatype pairs match. All MPI datatypes defined by the MPI standard (3.1) are verified by this check. User defined typedefs, custom MPI datatypes and null pointer constants are skipped, in the course of verification. Instructions on how to apply the check can be found at: https://github.com/0ax1/MPI-Checker/tree/master/examples Patch by Alexander Droste! Differential revision: https://reviews.llvm.org/D21962 llvm-svn: 277516
* Revert "MPITypeMismatchCheck for Clang-Tidy"Alexander Kornienko2016-07-251-1/+0
| | | | | | This reverts commit r276640. Breaks multiple buildbots. llvm-svn: 276651
* MPITypeMismatchCheck for Clang-TidyAlexander Kornienko2016-07-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | Summary: This check verifies if buffer type and MPI (Message Passing Interface) datatype pairs match. All MPI datatypes defined by the MPI standard (3.1) are verified by this check. User defined typedefs, custom MPI datatypes and null pointer constants are skipped, in the course of verification. Instructions on how to apply the check can be found at: https://github.com/0ax1/MPI-Checker/tree/master/examples Reviewers: alexfh Subscribers: cfe-commits Projects: #clang-tools-extra Patch by Alexander Droste! Differential Revision: https://reviews.llvm.org/D21962 llvm-svn: 276640
* Add boost-use-to-stringPiotr Padlewski2016-04-291-0/+1
| | | | | | http://reviews.llvm.org/D18136 llvm-svn: 268079
* [clang-tidy] Add "clang-tidy as a clang plugin" skeleton.Benjamin Kramer2016-03-032-0/+142
This doesn't really do much at the moment. You can load it via libclang and set the -checks via an extra command line argument as illustrated in the test case. Support for other options (including headers check) is currently missing. Also when using this with libclang some checks may not work with the precompiled preamble in place. This can be used to easily show clang-tidy warnings in an editor integration as all that's needed is adding command line flags that are passed into libclang. Warnings and FixIts are exposed via the existing CXDiagnostic machinery. Differential Revision: http://reviews.llvm.org/D17807 llvm-svn: 262595
OpenPOWER on IntegriCloud