summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/Inputs
Commit message (Collapse)AuthorAgeFilesLines
* [clang-tidy] bugprone-not-null-terminated-result: checker adjustments 4Csaba Dabis2019-10-131-1/+1
| | | | llvm-svn: 374715
* [clang-tidy] New checker for not null-terminated result caused by strlen(), ↵Csaba Dabis2019-10-132-0/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | size() or equal length Summary: New checker called bugprone-not-null-terminated-result. This checker finds function calls where it is possible to cause a not null-terminated result. Usually the proper length of a string is `strlen(src) + 1` or equal length of this expression, because the null terminator needs an extra space. Without the null terminator it can result in undefined behaviour when the string is read. The following and their respective `wchar_t` based functions are checked: `memcpy`, `memcpy_s`, `memchr`, `memmove`, `memmove_s`, `strerror_s`, `strncmp`, `strxfrm` The following is a real-world example where the programmer forgot to increase the passed third argument, which is `size_t length`. That is why the length of the allocated memory is not enough to hold the null terminator. ``` static char *stringCpy(const std::string &str) { char *result = reinterpret_cast<char *>(malloc(str.size())); memcpy(result, str.data(), str.size()); return result; } ``` In addition to issuing warnings, fix-it rewrites all the necessary code. It also tries to adjust the capacity of the destination array: ``` static char *stringCpy(const std::string &str) { char *result = reinterpret_cast<char *>(malloc(str.size() + 1)); strcpy(result, str.data()); return result; } ``` Note: It cannot guarantee to rewrite every of the path-sensitive memory allocations. Reviewed By: JonasToth, aaron.ballman, whisperity, alexfh Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D45050 llvm-svn: 374707
* [ClangTidy] Separate tests for infrastructure and checkersDmitri Gribenko2019-10-1194-1203/+0
| | | | | | | | | | | | | | | | | | | | Summary: This change moves tests for checkers and infrastructure into separate directories, making it easier to find infrastructure tests. Tests for checkers are already easy to find because they are named after the checker. Tests for infrastructure were difficult to find because they were outnumbered by tests for checkers. Now they are in a separate directory. Reviewers: jfb, jdoerfert, lebedev.ri Subscribers: srhines, nemanjai, aheejin, kbarton, christof, mgrang, arphaman, jfb, lebedev.ri, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68807 llvm-svn: 374540
* Revert "[clang-tidy] Fix relative path in header-filter."Dmitri Gribenko2019-09-233-5/+0
| | | | | | | This reverts commit r372388. It made '-header-filter' inconsistent with paths printed in diagnostics. llvm-svn: 372601
* [clang-tidy] Fix relative path in header-filter.Dmitri Gribenko2019-09-203-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Clang-tidy supports output diagnostics from header files if user specifies --header-filter. But it can't handle relative path well. For example, the folder structure of a project is: ``` // a.h is in /src/a/a.h // b.h is in /src/b/b.h ... // c.cpp is in /src/c.cpp ``` Now, we set --header-filter as --header-filter=/a/. That means we only want to check header files under /src/a/ path, and ignore header files uder /src/b/ path, but in current implementation, clang-tidy will check /src/b/b.h also, because the name of b.h used in clang-tidy is /src/a/../b/b.h. This change tries to fix this issue. Reviewers: alexfh, hokein, aaron.ballman, gribozavr Reviewed By: gribozavr Subscribers: MyDeveloperDay, xazax.hun, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D67501 Patch by Yubo Xie. llvm-svn: 372388
* [clang-tidy]: Google: new check 'google-upgrade-googletest-case'Eric Fiselier2019-07-294-0/+141
| | | | | | | | | | | Introduce a new check to upgrade user code based on API changes in Googletest. The check finds uses of old Googletest APIs with "case" in their name and replaces them with the new APIs named with "suite". Patch by Alex Strelnikov (strel@google.com) Reviewed as D62977. llvm-svn: 367263
* [clang-tidy] Move test files of rL363975 into Inputs directoryKadir Cetinkaya2019-06-211-0/+4
| | | | llvm-svn: 364008
* [clang-tidy] Expand modular headers for PPCallbacksAlexander Kornienko2019-03-224-0/+8
| | | | | | | | | | | | | | | | | | | | | | 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
* [clang-tidy] Add additional patterns to the ↵Hyrum Wright2019-03-141-0/+3
| | | | | | | | abseil-duration-unnecessary-conversion check. Differential Revision: https://reviews.llvm.org/D59183 llvm-svn: 356141
* [clang-tidy] Add the abseil-time-subtraction checkHyrum Wright2019-02-271-0/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D58137 llvm-svn: 355024
* [clang-tidy] Make google-objc-function-naming ignore implicit functions 🙈Stephane Moore2019-02-211-0/+18
| | | | | | | | | | | | | | | | | | | | | | Summary: Implicit functions are outside the control of source authors and should be exempt from style restrictions. Tested via running clang tools tests. This is an amended followup to https://reviews.llvm.org/D57207 Reviewers: aaron.ballman Reviewed By: aaron.ballman Subscribers: jdoerfert, xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58095 llvm-svn: 354534
* [clang-tidy] Add the abseil-duration-unnecessary-conversion checkHyrum Wright2019-02-041-0/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D57353 llvm-svn: 353079
* [clang-tidy] Add the abseil-duration-addition checkHyrum Wright2019-01-281-0/+13
| | | | | | Differential Revision: https://reviews.llvm.org/D57185 llvm-svn: 352362
* Fix clang-tidy test after r350714. NFCIlya Biryukov2019-01-091-0/+1
| | | | llvm-svn: 350715
* [clang-tidy] NFC Consolidate test absl::Time implementationJonas Toth2018-12-111-0/+72
| | | | | | | | | | | | | | | | Summary: Several tests re-implement these same prototypes (differently), so we can put them in a common location. Patch by hwright. Reviewers: JonasToth Reviewed By: JonasToth Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D55540 llvm-svn: 348840
* Move detection of libc++ include dirs to Driver on MacOSIlya Biryukov2018-12-051-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The intention is to make the tools replaying compilations from 'compile_commands.json' (clang-tidy, clangd, etc.) find the same standard library as the original compiler specified in 'compile_commands.json'. Previously, the library detection logic was in the frontend (InitHeaderSearch.cpp) and relied on the value of resource dir as an approximation of the compiler install dir. The new logic uses the actual compiler install dir and is performed in the driver. This is consistent with the C++ standard library detection on other platforms and allows to override the resource dir in the tools using the compile_commands.json without altering the standard library detection mechanism. The tools have to override the resource dir to make sure they use a consistent version of the builtin headers. There is still logic in InitHeaderSearch that attemps to add the absolute includes for the the C++ standard library, so we keep passing the -stdlib=libc++ from the driver to the frontend via cc1 args to avoid breaking that. In the long run, we should move this logic to the driver too, but it could potentially break the library detection on other systems, so we don't tackle it in this patch to keep its scope manageable. This is a second attempt to fix the issue, first one was commited in r346652 and reverted in r346675. The original fix relied on an ad-hoc propagation (bypassing the cc1 flags) of the install dir from the driver to the frontend's HeaderSearchOptions. Unsurpisingly, the propagation was incomplete, it broke the libc++ detection in clang itself, which caused LLDB tests to break. The LLDB tests pass with new fix. Reviewers: JDevlieghere, arphaman, EricWF Reviewed By: arphaman Subscribers: mclow.lists, ldionne, dexonsmith, ioeric, christof, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54630 llvm-svn: 348365
* Revert "Add a test checking clang-tidy can find libc++ on Mac"Jonas Toth2018-11-121-2/+0
| | | | | | This reverts commit r346653. llvm-svn: 346678
* Add a test checking clang-tidy can find libc++ on MacIlya Biryukov2018-11-121-0/+2
| | | | | | | | | | | | Reviewers: sammccall, arphaman, EricWF Reviewed By: sammccall Subscribers: christof, cfe-commits Differential Revision: https://reviews.llvm.org/D54311 llvm-svn: 346653
* [clang-tidy] Add a missing comma after "flags"Benjamin Kramer2018-09-112-2/+1
| | | | llvm-svn: 341925
* [clang-tidy] Abseil: Allow macros inside of absl to use internal absl thingsBenjamin Kramer2018-09-071-0/+2
| | | | llvm-svn: 341643
* [clang-tidy] Add abseil-no-internal-dependencies checkJonas Toth2018-08-292-2/+39
| | | | | | | | | | | Finds instances where the user depends on internal details and warns them against doing so. Should not be run on internal Abseil files or Abseil source code. Patch by hugoeg! Differential Revision: https://reviews.llvm.org/D50542 llvm-svn: 340928
* [clang-tidy] Abseil: no namepsace checkHaojian Wu2018-08-282-0/+2
| | | | | | | | | | This check ensures that users of Abseil do not open namespace absl in their code, as that violates our compatibility guidelines. AbseilMatcher.h written by Hugo Gonzalez. Patch by Deanna Garcia! llvm-svn: 340800
* Reland "[clang-tidy] Adding RestrictSystemIncludes check to Fuchsia module"Julie Hockett2018-05-119-0/+6
| | | | | | This relands r332125 with a fixed test. llvm-svn: 332141
* Revert "[clang-tidy] Adding RestrictSystemIncludes check to Fuchsia module"Julie Hockett2018-05-119-6/+0
| | | | | | This reverts commit r332125 for a failing test. llvm-svn: 332131
* [clang-tidy] Adding RestrictSystemIncludes check to Fuchsia moduleJulie Hockett2018-05-119-0/+6
| | | | | | | | | | Adding a check to restrict system includes to a whitelist. Given a list of includes that are explicitly allowed, the check issues a fixit to remove any system include not on that list from the source file. Differential Revision: https://reviews.llvm.org/D43778 llvm-svn: 332125
* Revert "[clang-tidy] Adding RestrictSystemIncludes check to Fuchsia module"Julie Hockett2018-05-097-6/+0
| | | | | | This reverts commit r331930, which was landed by accident. llvm-svn: 331934
* [clang-tidy] Adding RestrictSystemIncludes check to Fuchsia moduleJulie Hockett2018-05-097-0/+6
| | | | | | | | | | Adding a check to restrict system includes to a whitelist. Given a list of includes that are explicitly allowed, the check issues a fixit to remove any system include not on that list from the source file. Differential Revision: https://reviews.llvm.org/D43778 llvm-svn: 331930
* [clang-tidy] Add -vfsoverlay flagIlya Biryukov2018-01-232-0/+13
| | | | | | | | | | | | | | | | | | | | | 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
* [clang-tidy] Don't generate fix for argument constructed from ↵Haojian Wu2018-01-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | std::initializer_list. Summary: A follow-up fix of rL311652. The previous `vector` in our test is different with `std::vector`, so The check still generates fixes for std::vector (`auto p = std::unique_ptr<Foo>(new Foo({1,2,3}))`) in real world, the patch makes the vector behavior in test align with std::vector (both AST nodes are the same now). Reviewers: ilya-biryukov, alexfh Reviewed By: ilya-biryukov Subscribers: klimek, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D41852 llvm-svn: 322822
* Fix up clang-tidy after clang r314037.Richard Smith2017-09-221-10/+10
| | | | llvm-svn: 314047
* [clang-tidy] A follow-up fix of braced-init-list constructors in make-unique ↵Haojian Wu2017-08-241-0/+6
| | | | | | | | | | | | | | check. Reviewers: alexfh Reviewed By: alexfh Subscribers: JDevlieghere, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D37066 llvm-svn: 311652
* [clang-tidy] Support initializer-list constructor cases in ↵Haojian Wu2017-08-041-0/+25
| | | | | | | | | | | | | | modernize-make-unique. Reviewers: alexfh Reviewed By: alexfh Subscribers: malcolm.parsons, JDevlieghere, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D36016 llvm-svn: 310035
* [clang-tidy] add regression test to performance-unnecessary-value-paramChih-Hung Hsieh2017-07-122-0/+30
| | | | | | | | This test shows the problem in https://bugs.llvm.org/show_bug.cgi?id=33734 Differential Revision: https://reviews.llvm.org/D35225 llvm-svn: 307810
* [clang-tidy] Add "MakeSmartPtrFunction" option to ↵Haojian Wu2017-07-052-0/+52
| | | | | | | | | | | | | | modernize-make-shared/unique checks. Reviewers: alexfh, aaron.ballman Reviewed By: alexfh Subscribers: JDevlieghere, Eugene.Zelenko, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D34206 llvm-svn: 307130
* [clang-tidy] Add cert-dcl58-cpp (do not modify the 'std' namespace) check.Gabor Horvath2017-02-171-0/+24
| | | | | | Differential Revision: https://reviews.llvm.org/D23421 llvm-svn: 295435
* [clang-tidy] Fix check for trivially copyable types in modernize-pass-by-valueMalcolm Parsons2017-01-121-0/+3
| | | | | | | | | | | | | | | Summary: rL270567 excluded trivially copyable types from being moved by modernize-pass-by-value, but it didn't exclude references to them. Change types used in the tests to not be trivially copyable. Reviewers: madsravn, aaron.ballman, alexfh Subscribers: JDevlieghere, cfe-commits Differential Revision: https://reviews.llvm.org/D28614 llvm-svn: 291796
* [clang-tidy] Suppress notes for warnings that were ignoredMalcolm Parsons2016-11-021-0/+5
| | | | | | | | Fixes PR30565. Patch by Nikita Kakuev llvm-svn: 285861
* [clang-tidy] MPIBufferDerefCheck Alexander Droste2016-08-121-0/+2
| | | | | | | | | | | | | | | | | | ... This check verifies if a buffer passed to an MPI (Message Passing Interface) function is sufficiently dereferenced. Buffers should be passed as a single pointer or array. As MPI function signatures specify void * for their buffer types, insufficiently dereferenced buffers can be passed, like for example as double pointers or multidimensional arrays, without a compiler warning emitted. Instructions on how to apply the check can be found at: https://github.com/0ax1/MPI-Checker/tree/master/examples Reviewers: Haojian Wu Differential revision: https://reviews.llvm.org/D22729 llvm-svn: 278553
* Analyze include order on a per-file basis.Zachary Turner2016-08-123-0/+41
| | | | | | | | | | | | | | | | | | | The include order check would get notified of all include directives in a depth-first manner. This created the possibility of an include directive from a header file interfering with the sort order of a set of two distinct blocks from the top level cpp file, if that include directive was on just the right line. With this patch we bucket the include directives by the file in which they appear in and process one bucket at a time, so that directives from different files do not get mixed together into the same list. Reviewed By: alexfh Differential Revision: https://reviews.llvm.org/D23434 llvm-svn: 278546
* Fix clang-tidy crash when a single fix is applied on multiple files.Eric Liu2016-08-091-0/+8
| | | | | | | | | | | | | | | 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] MPITypeMismatchCheckAlexander Kornienko2016-08-021-0/+62
| | | | | | | | | | | | | | | | 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
* [clang-tidy] Fix an unused-using-decl false positive about template arguments inHaojian Wu2016-08-021-0/+11
| | | | | | | | | | | | | | | | function call expression. Summary: The check doesn't mark the template argument as used when the template argument is a template. Reviewers: djasper, alexfh Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D22803 llvm-svn: 277444
* Revert "MPITypeMismatchCheck for Clang-Tidy"Alexander Kornienko2016-07-251-62/+0
| | | | | | This reverts commit r276640. Breaks multiple buildbots. llvm-svn: 276651
* MPITypeMismatchCheck for Clang-TidyAlexander Kornienko2016-07-251-0/+62
| | | | | | | | | | | | | | | | | | | | | | 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
* [ClangTidy] Add an 'explain-checks' option to diagnose where each checks ↵Haojian Wu2016-04-271-0/+1
| | | | | | | | | | | | comes from. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18694 llvm-svn: 267683
* [clang-tidy] Make 'modernize-pass-by-value' fix work on header files.Haojian Wu2016-03-021-0/+7
| | | | | | | | | | Reviewers: alexfh Subscribers: jbcoe, cfe-commits Differential Revision: http://reviews.llvm.org/D17756 llvm-svn: 262470
* [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.Haojian Wu2016-02-261-0/+32
| | | | | | | | | | | | | | | | | | | | | Summary: The clang-tidy will trigger an assertion if it's not in the building directory. TEST: cd <llvm-repo>/ ./build/bin/clang-tidy --checks=-*,modernize-use-nullptr -p build tools/clang/tools/extra/clang-tidy/ClangTidy.cpp The crash issue is gone after applying this patch. Fixes PR24834, PR26241 Reviewers: bkramer, alexfh Subscribers: rizsotto.mailinglist, cfe-commits Differential Revision: http://reviews.llvm.org/D17335 llvm-svn: 261991
* [clang-tidy] Adding headers needed in modernize-deprecated-headers testsAlexander Kornienko2016-02-2526-0/+0
| | | | llvm-svn: 261893
* [clang-tidy] Fix assertion failure on `at` function in modernize-loop-convert.Haojian Wu2016-02-081-0/+1
| | | | | | | | | | Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D16926 llvm-svn: 260107
* Only copy small types in modernize-loop-convert.Angel Garcia Gomez2015-10-301-0/+5
| | | | | | | | | | | | Summary: If the size of the type is above a certain bound, we'll take a const reference. This bound can be set as an option. For now, the default value is 16 bytes. Reviewers: klimek Subscribers: alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D14176 llvm-svn: 251694
OpenPOWER on IntegriCloud