aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-06-08[clang-tidy][NFC] fix formatting of `namespace-comment-check` (#143305)Baranov Victor1-9/+11
Fixed formatting and codestyle issues in `namespace-comment-check` Follow up to https://github.com/llvm/llvm-project/pull/124265.
2025-06-08added option ↵Thorsten Klein1-1/+11
`google-readability-namespace-comments.AllowNoNamespaceComments` (#124265) New option AllowNoNamespaceComments for `google-readability-namespace-comments.AllowNoNamespaceComments` is added. When true, the check will allow that no namespace comment is present. If a namespace comment is added but it is not matching, the check will fail. Default is `false` Fixes #124264
2025-05-25[clang-tidy] Remove unused includes (NFC) (#141420)Kazu Hirata1-1/+0
These are identified by misc-include-cleaner. I've filtered out those that break builds. Also, I'm staying away from llvm-config.h, config.h, and Compiler.h, which likely cause platform- or compiler-specific build failures.
2023-12-13[clang-tidy] Use StringRef::{starts,ends}_with (NFC)Kazu Hirata1-2/+2
This patch replaces uses of StringRef::{starts,ends}with with StringRef::{starts,ends}_with for consistency with std::{string,string_view}::{starts,ends}_with in C++20. I'm planning to deprecate and eventually remove StringRef::{starts,ends}with.
2023-08-27[clang-tidy][NFC] Fix readability-uppercase-literal-suffix findingsPiotr Zegar1-2/+2
Fix issues found by clang-tidy in clang-tidy source directory.
2023-08-05[clang-tidy] Fix inline namespaces in llvm-namespace-commentPiotr Zegar1-4/+7
Provide fixes for inline namespaces in the same format as clang-format. Fixes: #56804 Reviewed By: carlosgalvezp Differential Revision: https://reviews.llvm.org/D157178
2023-01-14[clang-tidy][NFC] Use C++17 nested namespaces in the clang-tidy folderCarlos Galvez1-6/+2
Fix applied by running: run-clang-tidy.py -checks=-*,modernize-concat-nested-namespaces Differential Revision: https://reviews.llvm.org/D141770
2023-01-07[clang-tools-extra] Use std::optional instead of llvm::Optional (NFC)Kazu Hirata1-3/+3
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-03[clang-tidy] Use std::nullopt instead of None (NFC)Kazu Hirata1-1/+1
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
2020-04-05[clang-tools-extra] NFC: Fix trivial typo in documents and commentsKazuaki Ishizaki1-1/+1
Differential Revision: https://reviews.llvm.org/D77458
2020-03-03[clang-tidy] Change checks to use new isLanguageVersionSupported restrictionNathan James1-4/+1
Summary: Modifies all checks that are language version dependent to use `isLanguageVersionSupported` Reviewers: jdoerfert, lebedev.ri, aaron.ballman, gribozavr2, Eugene.Zelenko Reviewed By: gribozavr2 Subscribers: wuzish, nemanjai, xazax.hun, hiraditya, kbarton, steven_wu, dexonsmith, arphaman, lebedev.ri, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D75340
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer1-1/+1
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2019-12-06[clang-tidy] Fix PR26274Alexander Kornienko1-64/+70
Summary: This commit fixes http://llvm.org/PR26274 in a simpler and more correct way than 4736d63f752f8d13f4c6a9afd558565c32119718 did. See https://reviews.llvm.org/D69855#1767089 for details. Reviewers: gribozavr, aaron.ballman, gribozavr2 Reviewed By: aaron.ballman, gribozavr2 Subscribers: gribozavr2, merge_guards_bot, xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70974
2019-12-03Revert "Fix llvm-namespace-comment for macro expansions"Alexander Kornienko1-120/+13
This reverts commit 4736d63f752f8d13f4c6a9afd558565c32119718. This commit introduces a ton of false positives and incorrect fixes. See https://reviews.llvm.org/D69855#1767089 for details.
2019-11-23Fix llvm-namespace-comment for macro expansionsMarcin Twardak1-13/+120
If a namespace is a macro name, it should be allowed to close the namespace with the same name.
2019-07-17[clang-tidy] Adjust location of namespace comment diagnosticIlya Biryukov1-1/+8
Summary: If there is no comment, place it at the closing brace of a namespace definition. Previously it was placed at the next character after the closing brace. The new position produces a better location for highlighting in clangd and does not seem to make matters worse for clang-tidy. Reviewers: alexfh, hokein Reviewed By: alexfh, hokein Subscribers: xazax.hun, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64861 llvm-svn: 366337
2019-04-23Re-apply r357823 "[Lexer] NFC: Fix an off-by-one bug in getAsCharRange()."Artem Dergachev1-1/+4
It now comes with a follow-up fix for the clients of this API in clangd and clang-tidy. Differential Revision: https://reviews.llvm.org/D59977 llvm-svn: 359035
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-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
2018-08-09Port getLocStart -> getBeginLocStephen Kelly1-2/+2
Reviewers: javed.absar Subscribers: nemanjai, kbarton, ilya-biryukov, ioeric, jkorous, arphaman, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50354 llvm-svn: 339400
2018-01-11[clang-tidy] Fix google-readability-namespace-comments handling of C++17 ↵Alexander Kornienko1-10/+59
nested namespaces Summary: Fixes bug 34701 When we encounter a namespace find the location of the left bracket. Then if the text between the name and the left bracket contains a ':' then it's a C++17 nested namespace. Reviewers: #clang-tools-extra, alexfh, aaron.ballman Reviewed By: aaron.ballman Subscribers: curdeius, cfe-commits, krasimir, JonasToth, JDevlieghere, xazax.hun Tags: #clang-tools-extra Patch by Alexandru Octavian Buțiu! Differential Revision: https://reviews.llvm.org/D38284 llvm-svn: 322274
2017-10-12Revert "Fix nested namespaces in google-readability-nested-namespace-comments."Alexander Kornienko1-53/+10
This reverts r315057. The revision introduces assertion failures: assertion failed at llvm/tools/clang/include/clang/Basic/SourceManager.h:428 in const clang::SrcMgr::ExpansionInfo &clang::SrcMgr::SLocEntry::getExpansion() const: isExpansion() && "Not a macro expansion SLocEntry!" Stack trace: __assert_fail clang::SrcMgr::SLocEntry::getExpansion() clang::SourceManager::getExpansionLocSlowCase() clang::SourceManager::getExpansionLoc() clang::Lexer::getRawToken() clang::tidy::readability::NamespaceCommentCheck::check() clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::MatchVisitor::visitMatch() clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches() clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchWithFilter() clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchDispatch() clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl() clang::RecursiveASTVisitor<>::TraverseDeclContextHelper() clang::RecursiveASTVisitor<>::TraverseDecl() clang::RecursiveASTVisitor<>::TraverseDeclContextHelper() clang::RecursiveASTVisitor<>::TraverseDecl() clang::RecursiveASTVisitor<>::TraverseDeclContextHelper() clang::RecursiveASTVisitor<>::TraverseDecl() clang::ast_matchers::MatchFinder::matchAST() clang::MultiplexConsumer::HandleTranslationUnit() clang::ParseAST() clang::FrontendAction::Execute() clang::CompilerInstance::ExecuteAction() clang::tooling::FrontendActionFactory::runInvocation() clang::tooling::ToolInvocation::runInvocation() clang::tooling::ToolInvocation::run() Still working on an isolated test case. llvm-svn: 315580
2017-10-06Fix nested namespaces in google-readability-nested-namespace-comments.Aaron Ballman1-10/+53
Fixes PR34701. Patch by Alexandru Octavian Buțiu. llvm-svn: 315057
2016-12-14modernize-use-auto NFC fixesPiotr Padlewski1-1/+1
llvm-svn: 289656
2016-11-08[clang-tools-extra] Format sources with clang-format. NFC.Mandeep Singh Grang1-1/+2
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
2016-09-24[clang-tidy] Cleaning up language options.Gabor Horvath1-1/+1
Differential Revision: https://reviews.llvm.org/D24881 llvm-svn: 282319
2015-12-16[clang-tidy] google-readability-namespace-comments: ignore stray semicolonsAlexander Kornienko1-1/+2
llvm-svn: 255772
2015-09-02Disable clang-tidy readability checkers when not compiling in C++ mode. None ↵Aaron Ballman1-1/+4
of the checkers require additional testing as the tests will not compile for other languages or modes, or the checkers would never match a valid construct. llvm-svn: 246661
2015-04-08[clang-tidy] Fix for http://llvm.org/PR23130Alexander Kornienko1-3/+3
NamespaceCommentCheck: Don't remove the token placed immediately after the namespace closing brace. llvm-svn: 234403
2015-03-23Make helpers static. clang-tools edition.Benjamin Kramer1-3/+4
Also purge dead code found by it. NFC. llvm-svn: 232948
2015-03-05Use std::string instead of StringRef to prevent use-after-free.Daniel Jasper1-1/+1
Discovered by asan. llvm-svn: 231421
2015-03-05[clang-tidy] Replace unrecognized namespace ending comments.Alexander Kornienko1-17/+22
Summary: Replace unrecognized namespace ending comments. This will help in particular when a namespace ending comment is mistyped or doesn't fit the regexp for other reason, e.g.: namespace a { namespace b { namespace { } // anoynmous namespace } // b } // namesapce a Reviewers: djasper Reviewed By: djasper Subscribers: curdeius, cfe-commits Differential Revision: http://reviews.llvm.org/D8078 llvm-svn: 231369
2014-11-17[clang-tidy] Move the missing namespace comment warnings to the closing braceAlexander Kornienko1-1/+9
Summary: The google-readability-namespace-comments/llvm-namespace-comment warnings are quite confusing when they appear at the beginning of a long namespace and the closing brace is not in sight. For convenience added notes pointing to the start of the namespace. Reviewers: klimek Reviewed By: klimek Subscribers: curdeius, cfe-commits Differential Revision: http://reviews.llvm.org/D6251 llvm-svn: 222145
2014-10-16[clang-tidy] Minor fixes for the NamespaceCommentCheck.Alexander Kornienko1-4/+6
* Make SmallVector size enough for all groups. * Allow trailing period in the comment. * Fix "// anonymous namespace qqq". llvm-svn: 219926
2014-10-16[clang-tidy] Default options in modules.Alexander Kornienko1-2/+1
Summary: This patch allows modules to specify default options for the checks defined in them. This way a sufficiently configurable check can be registered in multiple modules with different default options. E.g. the SpacesBeforeComments option may be set to 1 for the "llvm-namespace-comments" check and to 2 for the "google-readability-namespace-comment" check without modifying or extending the check code. This patch also registers the google-readability-braces-around-statements check with suitable defaults. Reviewers: djasper Reviewed By: djasper Subscribers: curdeius, cfe-commits Differential Revision: http://reviews.llvm.org/D5798 llvm-svn: 219923
2014-09-22Add NamespaceCommentCheck to the Google module.Alexander Kornienko1-0/+127
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