aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp
AgeCommit message (Collapse)AuthorFilesLines
2023-01-07[clang-tools-extra] Use std::optional instead of llvm::Optional (NFC)Kazu Hirata1-5/+6
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to clean up the "using" declarations, #include "llvm/ADT/Optional.h", etc. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-07[clang-tools-extra] Add #include <optional> (NFC)Kazu Hirata1-0/+1
This patch adds #include <optional> to those files containing llvm::Optional<...> or Optional<...>. I'll post a separate patch to actually replace llvm::Optional with std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-05[clang-tools-extra] Use std::nullopt instead of llvm::None (NFC)Kazu Hirata1-6/+9
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-06-25[clang, clang-tools-extra] Don't use Optional::{hasValue,getValue} (NFC)Kazu Hirata1-1/+1
2022-05-05[clang-tidy] Make header-guard check a little looser on comment whitespaceSam McCall1-0/+8
Currently it rejects "// FOO_BAR_H" as an endif comment due to the extra space. A user complained that this is too picky, which seems fair enough. Differential Revision: https://reviews.llvm.org/D124955
2022-02-03[clang-tidy] Fix LLVM include order check policyKadir Cetinkaya1-14/+47
Clang-format LLVM style has a custom include category for gtest/ and gmock/ headers between regular includes and angled includes. Do the same here. Fixes https://github.com/llvm/llvm-project/issues/53525. Differential Revision: https://reviews.llvm.org/D118913
2021-11-30[clang-tidy] Fix pr48613: "llvm-header-guard uses a reserved identifier"Salman Javed1-0/+10
Fixes https://bugs.llvm.org/show_bug.cgi?id=48613. llvm-header-guard is suggesting header guards with leading underscores if the header file path begins with a '/' or similar special character. Only reserved identifiers should begin with an underscore. Differential Revision: https://reviews.llvm.org/D114149
2021-11-10[clang-tidy] Fix llvm-header-guard so that it works with Windows pathsSalman Javed1-3/+40
Fixes pr40372 (https://bugs.llvm.org/show_bug.cgi?id=40372). The llvm-header-guard check does not take into account that the path separator on Windows is `\`, not `/`. This means that instead of suggesting a header guard in the form of: LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FOO_H it incorrectly suggests: C:\LLVM_PROJECT\CLANG_TOOLS_EXTRA\CLANG_TIDY\FOO_H Differential Revision: https://reviews.llvm.org/D113450
2019-09-26[clang-tidy] Make llvm-header-guard work on llvm git monorepoHaojian Wu1-0/+9
Reviewers: gribozavr Reviewed By: gribozavr Subscribers: xazax.hun, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68026 llvm-svn: 372953
2019-05-10[clang-tidy] Change the namespace for llvm checkers from 'llvm' to 'llvm_check'Don Hinton1-1/+1
Summary: Change the namespace for llvm checkers from 'llvm' to 'llvm_check', and modify add_new_check.py and rename_check.py to support the new namespace. Checker, file, and directory names remain unchanged. Used new version of rename_check.py to make the change in existing llvm checkers, but had to fix LLVMTidyModule.cpp and LLVMModuleTest.cpp by hand. The changes made by rename_check.py are idempotent, so if accidentally run multiple times, it won't do anything. Reviewed By: aaron.ballman Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D60629 llvm-svn: 360450
2017-02-21[clang-tidy] Reword the "code outside header guard" warning.Benjamin Kramer1-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
2015-03-02[clang-tidy] Refactor: Move llvm clang-tidy checks to namespace ↵Alexander Kornienko1-0/+2
clang::tidy::llvm clang-tidy checks are organized into modules. This refactoring moves the llvm module checks to clang::tidy::llvm http://reviews.llvm.org/D7995 Patch by Richard Thomson! llvm-svn: 230952
2014-10-15Fix llvm-header-guard check.Alexander Kornienko1-3/+13
Summary: This patch makes the check work better for LLVM code: * always fix existing #endif comments * use one space before the comment (+allow customization for other styles) Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5795 llvm-svn: 219789
2014-10-15Reformatted code samples in the unit test. No functional changes.Alexander Kornienko1-64/+111
llvm-svn: 219788
2014-10-07Make clang-tidy's runCheckOnCode actually use the DiagnosticConsumer.Manuel Klimek1-1/+1
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
2014-09-22Add NamespaceCommentCheck to the Google module.Alexander Kornienko1-79/+0
Summary: This uses a bit hacky way to set the defaults for the spaces before comments, but it's also one of the simplest ways. Fixed a bug with how the SpacesBeforeComments option was used. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5410 llvm-svn: 218240
2014-09-17Rename unit test argument and add argument comments for clarity.Benjamin Kramer1-19/+28
NFC llvm-svn: 217947
2014-09-16[clang-tidy] When emitting header guard fixes bundle all fix-its into oneBenjamin Kramer1-11/+17
warning. Before we would emit two warnings if the header guard was wrong and the comment on a trailing #endif also needed fixing. llvm-svn: 217890
2014-09-12Implemented clang-tidy-check-specific options.Alexander Kornienko1-0/+2
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
2014-09-10[clang-tidy] Don't try to fix header guard #endif comments if there are escapedBenjamin Kramer1-0/+14
newlines involved. Getting that right is just not worth it. llvm-svn: 217480
2014-08-26[clang-tidy] If we're going to change the header guard in the #endif commentBenjamin Kramer1-0/+14
we can also fix the original header guard. We still allow an _ at the end of a header guard since it's so common, but remove it now when the #endif comment is changed. llvm-svn: 216462
2014-08-20[clang-tidy] Allow /**/ comments on #endifs when checking header guards.Benjamin Kramer1-0/+30
Turning block comments into line comments just creates unecessary churn. llvm-svn: 216072
2014-08-13ClangTidyTests: Suppress FixHeaderGuards on win32 for now.NAKAMURA Takumi1-0/+3
FIXME: It seems this might be incompatible to dos path. Investigating. llvm-svn: 215590
2014-08-13[clang-tidy] Add a generic header guard checker + LLVM implementation.Benjamin Kramer1-0/+41
The implementation is split into a generic part and a LLVM-specific part. Other codebases can implement it with their own style. The specific features supported are: - Verification (and fixing) of header guards against a style based on the file path - Automatic insertion of header guards for headers that are missing them - A warning when the header guard doesn't enable our fancy header guard optimization (e.g. when there's an include preceeding the guard) - Automatic insertion of a comment with the guard name after #endif. For the LLVM style we disable #endif comments for now, they're not very common in the codebase. We also only flag headers in the include directories, there doesn't seem to be a common style outside. Differential Revision: http://reviews.llvm.org/D4867 llvm-svn: 215548
2014-05-19Improved llvm-namespace-comment check.Alexander Kornienko1-1/+75
Summary: Handle various forms of existing namespace closing comments, fix existing comments with wrong namespace name, ignore short namespaces. The state of this check now seems to be enough to enable it by default to gather user feedback ;) Reviewers: klimek Reviewed By: klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3825 llvm-svn: 209141
2014-02-27Made the ClangTidyTest helper class independent of the testing framework.Alexander Kornienko1-4/+6
Reviewers: klimek Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2895 llvm-svn: 202399
2014-01-07Run llvm/utils/sort_includes.py over the Clang tools code. This doesn'tChandler Carruth1-1/+0
always produce as pretty of results as it does in LLVM and Clang, but I don't mind and the value of having a single canonical ordering is very high IMO. Let me know if you spot really serious problems here. llvm-svn: 198703
2013-07-29Initial architecture for clang-tidy.Daniel Jasper1-0/+15
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