summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
Commit message (Collapse)AuthorAgeFilesLines
* [clang-tidy] quickfix: add -fno-delayed-template-parsing as default argument ↵Jonas Toth2020-01-031-0/+1
| | | | for runCheckOnCode unit-tests to unbreak windows
* [Tooling] Migrated APIs that take ownership of objects to unique_ptrDmitri Gribenko2019-08-301-1/+3
| | | | | | | | | | Subscribers: jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66960 llvm-svn: 370451
* [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
* [clang-tidy] Fix ClangTidyTest to initialize context before checks.Yitzhak Mandelbaum2019-06-261-21/+27
| | | | | | | | | | | | | | | | | | | | | Summary: Currently, `clang::tidy::test::runCheckOnCode()` constructs the check instances *before* initializing the ClangTidyContext. This ordering causes problems when the check's constructor accesses the context, for example, through `getLangOpts()`. This revision moves the construction to after the context initialization, which follows the pattern used in the clang tidy tool itself. Reviewers: gribozavr Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63784 llvm-svn: 364435
* [clang-tidy] Add fix descriptions to clang-tidy checks.Haojian Wu2019-04-171-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Motivation/Context: in the code review system integrating with clang-tidy, clang-tidy doesn't provide a human-readable description of the fix. Usually developers have to preview a code diff (before vs after apply the fix) to understand what the fix does before applying a fix. This patch proposes that each clang-tidy check provides a short and actional fix description that can be shown in the UI, so that users can know what the fix does without previewing diff. This patch extends clang-tidy framework to support fix descriptions (will add implementations for existing checks in the future). Fix descriptions and fixes are emitted via diagnostic::Note (rather than attaching the main warning diagnostic). Before this patch: ``` void MyCheck::check(...) { ... diag(loc, "my check warning") << FixtItHint::CreateReplacement(...); } ``` After: ``` void MyCheck::check(...) { ... diag(loc, "my check warning"); // Emit a check warning diag(loc, "fix description", DiagnosticIDs::Note) << FixtItHint::CreateReplacement(...); // Emit a diagnostic note and a fix } ``` Reviewers: sammccall, alexfh Reviewed By: alexfh Subscribers: MyDeveloperDay, Eugene.Zelenko, aaron.ballman, JonasToth, xazax.hun, jdoerfert, cfe-commits Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D59932 llvm-svn: 358576
* [clang-tidy] Remove the old ClangTidyCheck::registerPPCallbacks methodAlexander Kornienko2019-04-031-1/+0
| | | | | | | | | | | | | | | | | | Summary: All in-tree clang-tidy checks have been migrated to the new ClangTidyCheck::registerPPCallbacks method. Time to drop the old one. Reviewers: sammccall, hokein Reviewed By: hokein Subscribers: xazax.hun, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60197 llvm-svn: 357582
* [clang-tidy] Move all checks to the new registerPPCallbacks APIAlexander Kornienko2019-03-221-0/+2
| | | | llvm-svn: 356796
* 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] Untangle layering in ClangTidyDiagnosticConsumer somewhat. NFCSam McCall2018-11-081-0/+3
| | | | | | | | | | | | | | | | | | | | | | | 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] 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
* Lift VFS from clang to llvm (NFC)Jonas Devlieghere2018-10-101-2/+2
| | | | | | | | | | | | | | | | | | | This patch moves the virtual file system form clang to llvm so it can be used by more projects. Concretely the patch: - Moves VirtualFileSystem.{h|cpp} from clang/Basic to llvm/Support. - Moves the corresponding unit test from clang to llvm. - Moves the vfs namespace from clang::vfs to llvm::vfs. - Formats the lines affected by this change, mostly this is the result of the added llvm namespace. RFC on the mailing list: http://lists.llvm.org/pipermail/llvm-dev/2018-October/126657.html Differential revision: https://reviews.llvm.org/D52783 llvm-svn: 344140
* Revert "[Tooling] [1/1] Refactor FrontendActionFactory::create() to return ↵Roman Lebedev2018-02-271-2/+1
| | | | | | | | | | | | std::unique_ptr<>" This reverts commit rL326202 This broke gcc4.8 builds, compiler just segfaults: http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/14909 http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/22673 llvm-svn: 326203
* [Tooling] [1/1] Refactor FrontendActionFactory::create() to return ↵Roman Lebedev2018-02-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | std::unique_ptr<> Summary: I'm not sure whether there are any principal reasons why it returns raw owning pointer, or it is just a old code that was not updated post-C++11. I'm not too sure what testing i should do, because `check-all` is not error clean here for some reason, but it does not //appear// asif those failures are related to these changes. This is Clang-tools-extra part. Clang part is D43779. Reviewers: klimek, bkramer, alexfh, pcc Reviewed By: alexfh Subscribers: ioeric, jkorous-apple, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D43780 llvm-svn: 326202
* [clang-tidy ObjC] [2/3] Support non-C++ files in ClangTidyTestHaojian Wu2017-10-261-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is part 2 of 3 of a series of changes to improve Objective-C linting in clang-tidy. Currently, `clang::tidy::test::runCheckOnCode()` assumes all files are C++ and unconditionally adds `-std=c++11` to the list of `clang-tidy` options. This updates the logic to check the extension of the source file and only add `-std=c++11` if the extension indicates C++ or Objective-C++. Depends On D39188 Test Plan: ninja ClangTidyTests && \ ./tools/clang/tools/extra/unittests/clang-tidy/ClangTidyTests Patch by Ben Hamilton! Reviewers: hokein, alexfh Reviewed By: hokein Subscribers: Wizard Differential Revision: https://reviews.llvm.org/D39189 llvm-svn: 316645
* Fix clang-tidy crash when a single fix is applied on multiple files.Eric Liu2016-08-091-7/+10
| | | | | | | | | | | | | | | Summary: tooling::Replacements only holds replacements for a single file, so this patch makes Fix a map from file paths to tooling::Replacements so that it can be applied on multiple files. Reviewers: hokein, alexfh Subscribers: Prazek, cfe-commits Differential Revision: https://reviews.llvm.org/D23257 llvm-svn: 278101
* Changes related to new implementation of tooling::Replacements as class.Eric Liu2016-08-011-1/+8
| | | | | | | | | | | | Summary: See http://reviews.llvm.org/D21748 for details. Reviewers: djasper, klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D21749 llvm-svn: 277336
* Changes related to tooling::applyAllReplacements interface change in D21601.Eric Liu2016-07-111-1/+8
| | | | | | | | | | | | | | | Summary: this patch contains changes related to the interface change from http://reviews.llvm.org/D21601. Only submit this patch after D21601 is submitted. Reviewers: djasper, klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D21602 llvm-svn: 275063
* [VFS] Switch clang-tidy tests to use an in-memory fs.Benjamin Kramer2015-10-071-4/+8
| | | | | | | Again, this is both cleaner and completely removes any depedency on the host file system. llvm-svn: 249526
* Create interfaces and tests for the overlapping replacements fix in clang-tidy.Angel Garcia Gomez2015-10-061-8/+32
| | | | | | | | | | | | Summary: No changes in clang-tidy yet. Reviewers: klimek Subscribers: alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13469 llvm-svn: 249402
* Move some more functionality into the AST consumer creation factory ↵Aaron Ballman2015-09-021-3/+6
| | | | | | function, before registering matchers with the MatchFinder object. This allows us to set the language options for the ClangTidyContext object appropriately so that they can be used from registerMatchers(), and more closely models the way the clang-tidy tool works. llvm-svn: 246660
* Fix formatting.Manuel Klimek2015-08-131-1/+1
| | | | llvm-svn: 244876
* Reinstantiate better diagnostic, this time with a fatal error so we don't ↵Manuel Klimek2015-08-121-2/+7
| | | | | | add a dependency onto gtest from the header. llvm-svn: 244722
* Revert the diagnostic improvements in r244602 as they introduced a ↵David Blaikie2015-08-111-9/+1
| | | | | | | | | | problematic dependency Seems we had some internal uses that include ClangTidyTest.h and weren't ready for a gtest dependency. Reverting to give Manuel some time to look into it. llvm-svn: 244658
* 1. Disable tests that currently cannot work on windows due to missing path ↵Manuel Klimek2015-08-111-1/+9
| | | | | | | | canonicalization in the file manager. 2. Add better output when a clang-tidy unit test fails so it's clear what the error is. llvm-svn: 244602
* Default initialize from explicitly constructed object.Manuel Klimek2015-08-111-2/+3
| | | | llvm-svn: 244596
* Add an IncludeInserter to clang-tidy.Manuel Klimek2015-08-111-1/+8
| | | | | | Will be used to allow checks to insert includes at the right position. llvm-svn: 244586
* [clang-tidy] Set current main file name in tests.Alexander Kornienko2015-07-271-0/+1
| | | | llvm-svn: 243272
* Force braces on the else branch if they are being added to the if branch.Samuel Benzaquen2015-03-311-5/+6
| | | | | | | | | | | | | | Summary: Force braces on the else branch if they are being added to the if branch. This ensures consistency in the transformed code. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D8708 llvm-svn: 233697
* [clang-tidy] Fixed header guards using clang-tidy llvm-header-guard check. NFC.Alexander Kornienko2015-03-091-3/+3
| | | | | | | | | | The patch was generated using this command: $ clang-tidy/tool/run-clang-tidy.py -header-filter=.*clang-tidy.* -fix \ -checks=-*,llvm-header-guard clang-tidy.* $ svn revert --recursive clangt-tidy/llvm/ (to revert a few buggy fixes) llvm-svn: 231669
* [clang-tidy] Organized clang-tidy unit tests. NFC.Alexander Kornienko2015-03-021-0/+3
| | | | | | | | | * Moved unit tests for BracesAroundStatementsCheck to ReadabilityModuleTest.cpp. * Moved EXPECT_NO_CHANGES macro to ClangTidyTest.h to avoid defining it three times. llvm-svn: 230947
* Small cleanups from review comments.Manuel Klimek2014-10-091-5/+3
| | | | llvm-svn: 219409
* Make clang-tidy's runCheckOnCode actually use the DiagnosticConsumer.Manuel Klimek2014-10-071-18/+26
| | | | | | | | | A precondition of that was to run both the preprocessor checks and AST checks from the same FrontendAction, otherwise we'd have needed to duplicate all involved objects in order to not have any references to a deleted source manager. llvm-svn: 219212
* Implemented clang-tidy-check-specific options.Alexander Kornienko2014-09-121-2/+1
| | | | | | | | | | | | | | | | | Summary: Each check can implement readOptions and storeOptions methods to read and store custom options. Each check's options are stored in a local namespace to avoid name collisions and provide some sort of context to the user. Reviewers: bkramer, klimek Reviewed By: klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5296 llvm-svn: 217661
* Implemented clang-tidy configurability via .clang-tidy files.Alexander Kornienko2014-09-041-2/+4
| | | | | | | | | | | | | | | | | Summary: This adds a support for the .clang-tidy file reading using FileOptionsProvider, -dump-config option, and changes tests to not depend on default checks set. Reviewers: klimek, bkramer, djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5186 llvm-svn: 217155
* Allow specifying file names and extra arguments when running clang-tidy unit ↵Benjamin Kramer2014-08-121-3/+7
| | | | | | | | tests. Will become useful soon. llvm-svn: 215438
* Allow per-file clang-tidy options.Alexander Kornienko2014-06-051-2/+2
| | | | | | | | | | | | | | | | | | Summary: This patch makes it possible for clang-tidy clients to provide different options for different translation units. The option, which doesn't make sense to be file-dependent, was moved to a separate ClangTidyGlobalOptions struct. Added parsing of ClangTidyOptions. Reviewers: klimek Reviewed By: klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3979 llvm-svn: 210260
* Store Errors inside ClangTidyContext instead of just pointer to an externalAlexander Kornienko2014-05-091-8/+6
| | | | | | | | | | | | | | | array. This simplifies usage of ClangTidyContext a bit and seems to be more consistent. Reviewers: klimek Reviewed By: klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3685 llvm-svn: 208407
* Add ClangTidyOptions to encapsulate all clang-tidy options.Alexander Kornienko2014-04-291-5/+3
| | | | | | | | | | | | Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3544 llvm-svn: 207532
* Output clang-tidy errors in a consistent order.Alexander Kornienko2014-04-081-2/+8
| | | | | | | | | | | | | | Summary: Sort errors by path, file offset and message. Reviewers: djasper, klimek Reviewed By: djasper CC: cfe-commits Differential Revision: http://reviews.llvm.org/D3314 llvm-svn: 205759
* ClangTidyTest.h: Don't use initializer list. msc17 doesn't recognize one.NAKAMURA Takumi2014-03-201-2/+3
| | | | llvm-svn: 204332
* Post-filter clang-tidy diagnostic messages.Alexander Kornienko2014-03-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch implements filtering of clang-tidy diagnostic messages by the check name, so that "clang-tidy -checks=^llvm-" won't output any clang warnings, for example. This is also helpful to run specific static-analyzer checks: static analyzer always needs core checks to be enabled, but the user may be interested only in the checks he asked for. This patch also exposes warning option names for built-in diagnostics. We need to have a namespace for these names to avoid collisions and to allow convenient filtering, so I prefix them with "-W". I'm not sure it's the best thing to do, and maybe "W" or "clang-diagnostic-" or something like this would be better. Reviewers: klimek Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D3121 llvm-svn: 204321
* clang-tidy explicit constructors check: don't warn on deleted constructors.Alexander Kornienko2014-03-191-2/+3
| | | | | | | | | | | | Reviewers: klimek Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D3116 llvm-svn: 204226
* [C++11] Replace OwningPtr with std::unique_ptr.Ahmed Charles2014-03-091-1/+1
| | | | | | | | This removes all references to OwningPtr, which should be fairly undisruptive to out-of-tree projects since they are unlikely to use clang-tools-extra as a library instead of a set of tools. llvm-svn: 203382
* [C++11] Replace LLVM_OVERRIDE with 'override'Craig Topper2014-03-021-1/+1
| | | | llvm-svn: 202632
* Made the ClangTidyTest helper class independent of the testing framework.Alexander Kornienko2014-02-271-43/+37
| | | | | | | | | | | | Reviewers: klimek Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2895 llvm-svn: 202399
* Make clang's static analyzer checks available through clang-tidy.Manuel Klimek2013-11-141-0/+1
| | | | | | | | | | | | | This is implemented in a way that the current static analyzer architecture allows, in the future we might want to revisit this. With this change static analyzer checks are available from clang-tidy by specifying -checks=clang-analyzer-<name>. This change also fixes the use of the compilation database to allow clang-tidy to be used like any other clang tool. llvm-svn: 194707
* Initial architecture for clang-tidy.Daniel Jasper2013-07-291-0/+75
This is the first version of a possible clang-tidy architecture. The purpose of clang-tidy is to detect errors in adhering to common coding patterns, e.g. described in the LLVM Coding Standards. This is still heavily in flux. Review: http://llvm-reviews.chandlerc.com/D884 llvm-svn: 187345
OpenPOWER on IntegriCloud