summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Use InitLLVM in clang-tidyRui Ueyama2019-11-281-1/+2
| | | | | | | | | | | | | Update clang-tidy to use InitLLVM, like several other llvm tools that were previously updated. On Windows, this allows clang-tidy to operate on arguments containing characters which cannot be represented in the system's ANSI code page such as filenames with Unicode characters. Fixes bugzilla bug 43751. Patch by Tristan Labelle. Differential Revision: https://reviews.llvm.org/D70694
* Revert "Use InitLLVM to setup a pretty stack printer"Nico Weber2019-11-251-2/+1
| | | | | | | This reverts commit 3f76260dc0674cc0acb25f550a0f0c594cf537ea. Breaks at least these tests on Windows: Clang :: Driver/clang-offload-bundler.c Clang :: Driver/clang-offload-wrapper.c
* Use InitLLVM to setup a pretty stack printerRui Ueyama2019-11-261-1/+2
| | | | | | | | | | | | | | InitLLVM does not only save a few lines from main() but also makes the commands do the right thing for multibyte character pathnames on Windows (i.e. canonicalize argv's to UTF-8) because of the code we have in this file: https://github.com/llvm/llvm-project/blob/master/llvm/lib/Support/InitLLVM.cpp#L32 For many LLVM commands, we already have calls of InitLLVM, but there are still remainings. Differential Revision: https://reviews.llvm.org/D70702
* Moved GlobList into a separate header fileDmitri Gribenko2019-08-261-0/+1
| | | | | | | | | | | | | | Summary: It is a separate abstraction that is used in more contexts than just a helper for ClangTidyDiagnosticConsumer. Subscribers: mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66747 llvm-svn: 369918
* [clang-tools-extra] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-2/+2
| | | | | | | | | | 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
* Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFCFangrui Song2019-08-051-1/+1
| | | | | | F_{None,Text,Append} are kept for compatibility since r334221. llvm-svn: 367800
* Fixed two issues in clang-tidy -help.Alexander Kornienko2019-07-011-2/+2
| | | | | | HeaderFilter -> HeaderFilterRegex llvm-svn: 364837
* [clang-tidy] Expand modular headers for PPCallbacksAlexander Kornienko2019-03-221-11/+14
| | | | | | | | | | | | | | | | | | | | | | Summary: Add a way to expand modular headers for PPCallbacks. Checks can opt-in for this expansion by overriding the new registerPPCallbacks virtual method and registering their PPCallbacks in the preprocessor created for this specific purpose. Use module expansion in the readability-identifier-naming check Reviewers: gribozavr, usaxena95, sammccall Reviewed By: gribozavr Subscribers: nemanjai, mgorny, xazax.hun, kbarton, jdoerfert, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D59528 llvm-svn: 356750
* 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-92/+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/+92
| | | | | | | | | | | 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-92/+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] PrintStackTraceOnErrorSignalAlexander Kornienko2018-11-261-0/+2
| | | | llvm-svn: 347546
* [clang-tidy] Get ClangTidyContext out of the business of storing ↵Sam McCall2018-11-021-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | diagnostics. NFC Summary: Currently ClangTidyContext::diag() sends the diagnostics to a DiagnosticsEngine, which probably delegates to a ClangTidyDiagnosticsConsumer, which is supposed to go back and populate ClangTidyContext::Errors. After this patch, the diagnostics are stored in the ClangTidyDiagnosticsConsumer itself and can be retrieved from there. Why? - the round-trip from context -> engine -> consumer -> context is confusing and makes it harder to establish layering between these things. - context does too many things, and makes it hard to use clang-tidy as a library - everyone who actually wants the diagnostics has access to the ClangTidyDiagnosticsConsumer The most natural implementation (ClangTidyDiagnosticsConsumer::take() finalizes diagnostics) causes a test failure: clang-tidy-run-with-database.cpp asserts that clang-tidy exits successfully when trying to process a file that doesn't exist. In clang-tidy today, this happens because finish() is never called, so the diagnostic is never flushed. This looks like a bug to me. For now, this patch carefully preserves that behavior, but I'll ping the authors to see whether it's deliberate and worth preserving. Reviewers: hokein Subscribers: xazax.hun, cfe-commits, alexfh Differential Revision: https://reviews.llvm.org/D53953 llvm-svn: 345961
* [clang-tidy] Build it even without static analyzerStephen Kelly2018-10-011-0/+3
| | | | | | | | | | | | | | | | | | | | | | 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-301-2/+0
| | | | | | 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-301-0/+2
| | | | | | Patch by Stephen Kelly. llvm-svn: 343415
* [clang-tidy] Store checks profiling info as JSON filesRoman Lebedev2018-06-061-6/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [clang-tidy] Add a flag to enable alpha checkersAlexander Kornienko2018-05-171-3/+14
| | | | | | | | | | | | | | | | Summary: The alpha checkers can already be enabled using the clang driver, this allows them to be enabled using the clang-tidy as well. This can make it easier to test the alpha checkers with projects which already support the compile_commands.json. It will also allow more people to give feedback and patches about the alpha checkers since they can run it as part of clang tidy checks. Reviewers: aaron.ballman, hokein, ilya-biryukov, alexfh, lebedev.ri, xbolva00 Reviewed By: aaron.ballman, alexfh, lebedev.ri, xbolva00 Subscribers: xbolva00, NoQ, dcoughlin, lebedev.ri, xazax.hun, cfe-commits Patch by Paul Fultz II! Differential Revision: https://reviews.llvm.org/D46159 llvm-svn: 332609
* [clang-tidy] Profile is a per-AST (per-TU) data.Roman Lebedev2018-05-081-44/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: As discussed in D45931, currently, profiling output of clang-tidy is somewhat not great. It outputs one profile at the end of the execution, and that profile contains the data from the last TU that was processed. So if the tool run on multiple TU's, the data is not accumulated, it is simply discarded. It would be nice to improve this. This differential is the first step - make this profiling info per-TU, and output it after the tool has finished processing each TU. In particular, when `ClangTidyASTConsumer` destructor runs. Next step will be to add a CSV (JSON?) printer to store said profiles under user-specified directory prefix. Reviewers: alexfh, sbenza Reviewed By: alexfh Subscribers: Eugene.Zelenko, mgorny, xazax.hun, mgrang, klimek, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D46504 llvm-svn: 331763
* [clang-tidy] Remove AnalyzeTemporaryDtors option.Alexander Kornienko2018-05-031-14/+0
| | | | | | | | Remove the `AnalyzeTemporaryDtors` option, since the corresponding `cfg-temporary-dtors` option of the Static Analyzer defaults to `true` since r326461. llvm-svn: 331456
* [clang-tidy] Fix clang-tidy doesn't read .clangtidy configuration file.Haojian Wu2018-04-181-9/+9
| | | | | | | | | | | | | | Summary: Fix https://bugs.llvm.org/show_bug.cgi?id=34900. Reviewers: alexfh Reviewed By: alexfh Subscribers: JonasToth, klimek, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D45697 llvm-svn: 330245
* [clang-tidy] Return non-zero exit code for clang errors.Alexander Kornienko2018-04-091-4/+16
| | | | | | | | | | | | | | | | Summary: Updated tests broken by this change. Fixes https://bugs.llvm.org/show_bug.cgi?id=27628 Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: klimek, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D45258 llvm-svn: 329579
* clang-tidy, modularize: return non-zero exit code on errorsAlexander Kornienko2018-03-221-2/+2
| | | | | | | When no inputs given, the tools should not only produce the help message, but also return a non-zero exit code. Fixed tests accordingly. llvm-svn: 328199
* [clang-tidy] Add Zircon module to clang-tidyJulie Hockett2018-03-141-0/+5
| | | | | | | | | | 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
* [clang-tidy] Fixing incorrect commentJulie Hockett2018-03-131-1/+1
| | | | llvm-svn: 327452
* [clang-tidy] Add check: replace string::find(...) == 0 with absl::StartsWithHaojian Wu2018-03-091-0/+5
| | | | | | | | | | | | 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-071-0/+5
| | | | | | | | | | | | 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] Add -vfsoverlay flagIlya Biryukov2018-01-231-2/+39
| | | | | | | | | | | | | | | | | | | | | Summary: It allows to remap and override files and directories on disk when running clang-tidy. The intended use case for the flag is running standalone clang-tidy binary for IDE and editor integration. Patch by Vladimir Plyashkun. Reviewers: alexfh, benlangmuir, ilya-biryukov Reviewed By: ilya-biryukov Subscribers: ilya-biryukov, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D41535 llvm-svn: 323196
* Add a new clang-tidy module for Fuchsia as an umbrella to diagnose issues ↵Aaron Ballman2017-11-281-0/+5
| | | | | | | | 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
* [clang-tidy ObjC] [1/3] New module `objc` for Objective-C checksHaojian Wu2017-10-261-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | 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] Don't error on MS-style inline assembly.Zachary Turner2017-10-201-0/+5
| | | | | | | | | | | To get MS-style inline assembly, we need to link in the various backends. Some other clang tools already do this, and this issue has been raised with clang-tidy several times, indicating there is sufficient desire to make this work. Differential Revision: https://reviews.llvm.org/D38549 llvm-svn: 316246
* Update for PrintHelpMessage not calling exit.Rafael Espindola2017-09-081-2/+2
| | | | llvm-svn: 312769
* [clang-tidy] Add bugprone-suspicious-memset-usage checkGabor Horvath2017-07-141-0/+5
| | | | | | | | | | | | | | | | | | 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
* [clang-tidy][Part1] Add a new module Android and three new checks.Yan Wang2017-06-231-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | 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] Update docs and help messageAlexander Kornienko2017-04-061-1/+4
| | | | llvm-svn: 299651
* [clang-tidy] Add FormatStyle configuration option.Alexander Kornienko2017-04-061-8/+11
| | | | llvm-svn: 299649
* Rename the clang-tidy safety module to be hicpp, for the High-Integrity C++ ↵Aaron Ballman2017-03-191-4/+4
| | | | | | | | coding standard from PRQA. This commit renames all of the safety functionality to be hicpp, adds an appropriate LICENSE.TXT, and updates the documentation accordingly. llvm-svn: 298229
* [clang-tidy] Format code around applied fixesAlexander Kornienko2017-03-031-7/+15
| | | | | | | | | | | | | | | | 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
* [clang-tidy] Add -quiet option to suppress extra outputEhsan Akhgari2017-02-091-8/+21
| | | | | | | | | | | | | | | Summary: This new flag instructs clang-tidy to not output anything except for errors and warnings. This makes it easier to script clang-tidy to run as part of external build systems. Reviewers: bkramer, alexfh, klimek Subscribers: JDevlieghere, cfe-commits Differential Revision: https://reviews.llvm.org/D29661 llvm-svn: 294607
* [clang-tidy] safety-no-assemblerJonathan Coe2017-02-061-0/+5
| | | | | | | | | | | | | | | | | | | Summary: Add a new clang-tidy module for safety-critical checks. Include a check for inline assembler. Reviewers: Prazek, dtarditi, malcolm.parsons, alexfh, aaron.ballman, idlecode Reviewed By: idlecode Subscribers: idlecode, JonasToth, Eugene.Zelenko, mgorny, JDevlieghere, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D29267 llvm-svn: 294255
* [clang-tidy] Add check name to YAML export (clang-tools-extra part)Alexander Kornienko2017-01-031-1/+1
| | | | | | | | | | | | Add a field indicating the associated check for every replacement to the YAML report generated with the '-export-fixes' option. Update clang-apply-replacements to handle the new format. Patch by Alpha Abdoulaye! Differential revision: https://reviews.llvm.org/D26137 llvm-svn: 290893
* [clang-tidy] Make format style customizableJonas Devlieghere2016-11-301-4/+12
| | | | | | | | | | | | | | 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
* [clang-tidy] clang-analyzer-alpha* checks are not registered, so there's no ↵Alexander Kornienko2016-11-081-3/+2
| | | | | | need to disable them llvm-svn: 286222
* [clang-tools-extra] Format sources with clang-format. NFC.Mandeep Singh Grang2016-11-081-9/+7
| | | | | | | | | | | | | | | | Summary: Ran clang-format on all .c/.cpp/.h files in clang-tools-extra. Excluded the test, unittests, clang-reorder-fields, include-fixer, modularize and pptrace directories. Reviewers: klimek, alexfh Subscribers: nemanjai Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D26329 llvm-svn: 286221
* [clang-tidy] Add doc for `explain-config` option.Haojian Wu2016-09-221-2/+3
| | | | llvm-svn: 282158
* minor header guards and help messages cleanupKirill Bobyrev2016-08-191-1/+1
| | | | llvm-svn: 279226
* [clang-tidy] MPITypeMismatchCheckAlexander Kornienko2016-08-021-0/+5
| | | | | | | | | | | | | | | | 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-5/+0
| | | | | | This reverts commit r276640. Breaks multiple buildbots. llvm-svn: 276651
OpenPOWER on IntegriCloud