summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/unittests/clang-tidy
Commit message (Collapse)AuthorAgeFilesLines
...
* [CMake] Use PRIVATE in target_link_libraries for executablesShoaib Meenai2017-12-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently use target_link_libraries without an explicit scope specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables. Dependencies added in this way apply to both the target and its dependencies, i.e. they become part of the executable's link interface and are transitive. Transitive dependencies generally don't make sense for executables, since you wouldn't normally be linking against an executable. This also causes issues for generating install export files when using LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM library dependencies, which are currently added as interface dependencies. If clang is in the distribution components but the LLVM libraries it depends on aren't (which is a perfectly legitimate use case if the LLVM libraries are being built static and there are therefore no run-time dependencies on them), CMake will complain about the LLVM libraries not being in export set when attempting to generate the install export file for clang. This is reasonable behavior on CMake's part, and the right thing is for LLVM's build system to explicitly use PRIVATE dependencies for executables. Unfortunately, CMake doesn't allow you to mix and match the keyword and non-keyword target_link_libraries signatures for a single target; i.e., if a single call to target_link_libraries for a particular target uses one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must also be updated to use those keywords. This means we must do this change in a single shot. I also fully expect to have missed some instances; I tested by enabling all the projects in the monorepo (except dragonegg), and configuring both with and without shared libraries, on both Darwin and Linux, but I'm planning to rely on the buildbots for other configurations (since it should be pretty easy to fix those). Even after this change, we still have a lot of target_link_libraries calls that don't specify a scope keyword, mostly for shared libraries. I'm thinking about addressing those in a follow-up, but that's a separate change IMO. Differential Revision: https://reviews.llvm.org/D40823 llvm-svn: 319840
* [clang-tidy] rename_check.py misc-argument-comment bugprone-argument-commentAlexander Kornienko2017-11-232-41/+0
| | | | | | | | | | | | | | Summary: + manually convert the unit test to lit test. Reviewers: hokein Reviewed By: hokein Subscribers: mgorny, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D40392 llvm-svn: 318926
* [clang-tidy ObjC] [3/3] New check objc-forbidden-subclassingHaojian Wu2017-10-271-1/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is part 3 of 3 of a series of changes to improve Objective-C linting in clang-tidy. This adds a new clang-tidy check `objc-forbidden-subclassing` which ensures clients do not create subclasses of Objective-C classes which are not designed to be subclassed. (Note that for code under your control, you should use __attribute__((objc_subclassing_restricted)) instead -- this is intended for third-party APIs which cannot be modified.) By default, the following classes (which are publicly documented as not supporting subclassing) are forbidden from subclassing: ABNewPersonViewController ABPeoplePickerNavigationController ABPersonViewController ABUnknownPersonViewController NSHashTable NSMapTable NSPointerArray NSPointerFunctions NSTimer UIActionSheet UIAlertView UIImagePickerController UITextInputMode UIWebView Clients can set a CheckOption `objc-forbidden-subclassing.ClassNames` to a semicolon-separated list of class names, which overrides this list. Test Plan: `ninja check-clang-tools` Patch by Ben Hamilton! Reviewers: hokein, alexfh Reviewed By: hokein Subscribers: saidinwot, Wizard, srhines, mgorny, xazax.hun Differential Revision: https://reviews.llvm.org/D39142 llvm-svn: 316744
* [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
* [clang-tidy ObjC] [1/3] New module `objc` for Objective-C checksHaojian Wu2017-10-262-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | 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] Add a test.Alexander Kornienko2017-08-101-3/+9
| | | | llvm-svn: 310586
* [clang-tidy] Ignore newlines in checks listAlexander Kornienko2017-08-091-1/+1
| | | | | | | This is a follow up to https://reviews.llvm.org/D30567 where I overlooked that LLVM YAML parser doesn't support multiline literal folding. llvm-svn: 310491
* [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 treating non-space whitespaces in checks list.Marek Kurdej2017-03-231-87/+94
| | | | | | | | | | | | | | | | Summary: This furtherly improves r295303: [clang-tidy] Ignore spaces between globs in the Checks option. Trims all whitespaces and not only spaces and correctly computes the offset of the checks list (taking the size before trimming). Reviewers: alexfh Reviewed By: alexfh Subscribers: cfe-commits, JDevlieghere Differential Revision: https://reviews.llvm.org/D30567 llvm-svn: 298621
* [clang-tidy] Reword the "code outside header guard" warning.Benjamin Kramer2017-02-211-59/+89
| | | | | | | | | | | | The check doesn't really know if the code it is warning about came before or after the header guard, so phrase it more neutral instead of complaining about code before the header guard. The location for the warning is still not optimal, but I don't think fixing that is worth the effort, the preprocessor doesn't give us a better location. Differential Revision: https://reviews.llvm.org/D30191 llvm-svn: 295715
* [clang-tidy] Ignore spaces between globs in the Checks option.Alexander Kornienko2017-02-161-1/+1
| | | | llvm-svn: 295303
* Correctly classify main file includes if there is a prefix addedAlexander Kornienko2017-01-121-0/+83
| | | | | | | | | | | | | | | | | Summary: Prevents misclassifying includes based on the command-line filename (e.g. if a project is in a subdirectory). This is slightly more robust than the additional duplicate detection, however the current classification scheme is still kind of brittle for a lot of code. Reviewers: hokein, alexfh Subscribers: cfe-commits, #clang-tools-extra Patch by Julian Bangert! Differential Revision: https://reviews.llvm.org/D26015 llvm-svn: 291767
* modernize-use-auto NFC fixesPiotr Padlewski2016-12-143-5/+3
| | | | llvm-svn: 289656
* Remove deprecated methods ast_matchers::BoundNodes::{getStmtAs,getDeclAs}Alexander Kornienko2016-12-131-1/+1
| | | | llvm-svn: 289542
* Fix signed/unsigned comparison warningsSimon Pilgrim2016-10-182-2/+2
| | | | llvm-svn: 284476
* Fix windows buildbot error.Haojian Wu2016-10-172-4/+5
| | | | llvm-svn: 284370
* Recommit "[ClangTidy] Add UsingInserter and NamespaceAliaser"Haojian Wu2016-10-173-0/+240
| | | | | | | | | | | | | | Summary: This adds helper classes to add using declaractions and namespace aliases to function bodies. These help making function calls to deeply nested functions concise (e.g. when calling helpers in a refactoring) Patch by Julian Bangert! Reviewers: alexfh, hokein Subscribers: beanz, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D24997 llvm-svn: 284368
* [clang-tidy] Fix readability-braces-around-statements false positiveMarek Kurdej2016-10-141-16/+30
| | | | | | | | | | | | | | | | | Summary: This fixes a false-positive e.g. when string literals are returned from if statement. This patch includes as well a small fix to includes and renames of the test suite that collided with the name of the check. Reviewers: alexfh, hokein Subscribers: hokein Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D25558 llvm-svn: 284212
* Revert "[ClangTidy] Add UsingInserter and NamespaceAliaser"Haojian Wu2016-10-122-239/+0
| | | | | | This reverts commit r283981. This patch breaks the buildbot. llvm-svn: 283985
* [ClangTidy] Add UsingInserter and NamespaceAliaserHaojian Wu2016-10-122-0/+239
| | | | | | | | | | | | | | | | Summary: This adds helper classes to add using declaractions and namespace aliases to function bodies. These help making function calls to deeply nested functions concise (e.g. when calling helpers in a refactoring) Patch by Julian Bangert! Reviewers: alexfh, hokein Subscribers: cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D24997 llvm-svn: 283981
* [clang-tidy] Merge ExtraArgs(Before) instead of overriding them.Alexander Kornienko2016-08-231-0/+33
| | | | | | Added proper tests. llvm-svn: 279519
* 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
* [clang-tidy] misc-argument-comment non-strict modeAlexander Kornienko2016-08-041-2/+2
| | | | | | | | | | | | | | | | | Summary: The misc-argument-comment check now ignores leading and trailing underscores and case. The new `StrictMode` local/global option can be used to switch back to strict checking. Add getLocalOrGlobal version for integral types, minor cleanups. Reviewers: hokein, aaron.ballman Subscribers: aaron.ballman, Prazek, cfe-commits Differential Revision: https://reviews.llvm.org/D23135 llvm-svn: 277729
* 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
* [clang-tidy] Cleanup namespace in utils folder.Etienne Bergeron2016-05-031-4/+5
| | | | | | | | | | | | | | Summary: This is a step forward cleaning up the namespaces in clang-tidy/utils. There is no behavior change. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19819 llvm-svn: 268356
* Fix Clang-tidy modernize-use-override warning in ↵Eugene Zelenko2016-01-261-2/+1
| | | | | | | | unittests/clang-tidy/IncludeInserterTest.cpp; other minor fixes. Differential revision: http://reviews.llvm.org/D16566 llvm-svn: 258870
* Remove autoconf supportChris Bieneman2016-01-261-30/+0
| | | | | | | | | | | | | | | | Summary: This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html "Now I am become Death, the destroyer of worlds." -J. Robert Oppenheimer Reviewers: chandlerc, grosbach, bob.wilson, echristo Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D16475 llvm-svn: 258864
* Revert "Apply modernize-use-default to clang-tools-extra."David Blaikie2015-10-201-1/+1
| | | | | | | | | Breaks the build in GCC 4.7.2 (see http://lab.llvm.org:8011/builders/perf-x86_64-penryn-O3 for example) This reverts commit r250824. llvm-svn: 250862
* Apply modernize-use-default to clang-tools-extra.Angel Garcia Gomez2015-10-201-1/+1
| | | | | | | | | | | | Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: klimek Subscribers: alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13889 llvm-svn: 250824
* Fix overlapping replacements in clang-tidy.Angel Garcia Gomez2015-10-161-43/+73
| | | | | | | | | | | | Summary: Prevent clang-tidy from applying fixes to errors that overlap with other errors' fixes, with one exception: if one fix is completely contained inside another one, then we can apply the big one. Reviewers: bkramer, klimek Subscribers: djasper, cfe-commits, alexfh Differential Revision: http://reviews.llvm.org/D13516 llvm-svn: 250509
* [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-064-9/+413
| | | | | | | | | | | | Summary: No changes in clang-tidy yet. Reviewers: klimek Subscribers: alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13469 llvm-svn: 249402
* [clang-tidy] Fix PR22785.Alexander Kornienko2015-09-091-0/+21
| | | | | | | | | | | Fix http://llvm.org/PR22785. Bug 22785 - readability-braces-around-statements doesn't work well with macros. http://reviews.llvm.org/D12729 Patch by Marek Kurdej! llvm-svn: 247163
* 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
* Remove empty destructors added in r245500. I got confused by myDaniel Jasper2015-08-191-4/+0
| | | | | | | YouCompleteMe setup which apparently doesn't find the base classes and thus doesn't understand that there is an implicit virtual destructor. llvm-svn: 245510
* Fix IncludeInserter to allow for more than one added header per file.Daniel Jasper2015-08-191-46/+83
| | | | | | | | Also adapt tests a bit to make it possible to test this. Removed checking the number of errors reported per test. It was never actually checked and doesn't seem particularly relevant to the test itself. llvm-svn: 245500
* [clang-tidy] Move IncludeSorter.* and IncludeInserter.* to clang-tidy/utils/Alexander Kornienko2015-08-141-1/+1
| | | | | | | This is better structurally and it also fixes a linker error in the configure build. llvm-svn: 245052
* [clang-tidy] Don't use delegating constructors.Alexander Kornienko2015-08-141-2/+3
| | | | llvm-svn: 245046
* [clang-tidy] Fix IncludeInserter/IncludeSorter bug.Alexander Kornienko2015-08-141-0/+73
| | | | | | | | | | | If there weren't any includes in the file, or all of them had 'IncludeKind' greater than the desired one, then 'CreateIncludeInsertion' didn't work. http://reviews.llvm.org/D12017 Patch by Angel Garcia! llvm-svn: 245042
* 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-112-34/+54
| | | | | | | | 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
* Also ClangTidyTests requires clangLex.NAKAMURA Takumi2015-08-111-0/+1
| | | | llvm-svn: 244599
* Do not use inheriting constructors.Manuel Klimek2015-08-111-3/+6
| | | | llvm-svn: 244597
* Default initialize from explicitly constructed object.Manuel Klimek2015-08-111-2/+3
| | | | llvm-svn: 244596
* Add an IncludeInserter to clang-tidy.Manuel Klimek2015-08-113-1/+416
| | | | | | 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
* [clang-tidy] Force braces around leaf 'else if' for consistency.Samuel Benzaquen2015-06-041-0/+13
| | | | | | | | | | | | | | Summary: Force braces around leaf 'else if' for consistency. This complements r233697. Reviewers: alexfh Subscribers: curdeius, cfe-commits Differential Revision: http://reviews.llvm.org/D10245 llvm-svn: 239054
OpenPOWER on IntegriCloud