9 Commits

Author SHA1 Message Date
Carlos Galvez
cc38cd856d
[clang-tidy] Remove check-specific HeaderFileExtensions and Implement… (#80333)
…ationFileExtensions

Deprecated since clang-tidy 17. Use the corresponding global options
instead.

Fixes #61947

---------

Co-authored-by: Carlos Gálvez <carlos.galvez@zenseact.com>
2024-02-02 21:48:21 +01:00
Carlos Galvez
5b37cddff8 [clang-tidy] Introduce HeaderFileExtensions and ImplementationFileExtensions options
Re-introduce the patch that was reverted previously.
In the first attempt, the checks would not be able to
read from the global option, since getLocalOrGlobal
only works with string types. Additional logic is needed
in order to support both use cases in the transition
period. All that logic will be removed when the local
options are fully removed.

We have a number of checks designed to analyze problems
in header files only, for example:

bugprone-suspicious-include
google-build-namespaces
llvm-header-guard
misc-definitions-in-header
...

All these checks duplicate the same logic and options
to determine whether a location is placed in the main
source file or in the header. More checks are coming
up with similar requirements.

Thus, to remove duplication, let's move this option
to the top-level configuration of clang-tidy (since
it's something all checks should share).

Add a deprecation notice for all checks that use the
local option, prompting to update to the global option.

Differential Revision: https://reviews.llvm.org/D142655
2023-02-19 13:44:11 +00:00
Carlos Galvez
7d2ea6c422 [clang-tidy][NFC] Use C++17 nested namespaces in the clang-tidy folder
Fix applied by running:

run-clang-tidy.py -checks=-*,modernize-concat-nested-namespaces

Differential Revision: https://reviews.llvm.org/D141770
2023-01-14 18:51:39 +00:00
Carlos Galvez
e82dd5b37c [clang-tidy][NFC] Remove custom isInAnonymousNamespace matchers
Since now the same matcher exists in ASTMatchers.
2022-12-23 08:54:48 +00:00
Carlos Galvez
bf452f9b34 [clang-tidy][NFC] Replace custom isStatic matcher with the existing isStaticStorageClass 2022-12-19 15:23:50 +00:00
Carlos Galvez
35d9f873e3 [clang-tidy] Fix a couple additional cases in misc-use-anonymous-namespace only
- Do not analyze header files, since we don't want to promote
  using anonymous namespaces there.

- Do not warn about const/constexpr variables, those are implicitly
  static in C++ and they don't need to be moved to an anonymous
  namespace. Warning about redundant static in general could be
  implemented as a standalone check, moving away some of the
  functionality from this check.

This check has been introduced in the current release, thus
no mention of this change is needed in the Release Notes.

Differential Revision: https://reviews.llvm.org/D139113
2022-12-12 15:26:14 +00:00
Carlos Galvez
d3c3de63ce [clang-tidy][NFC] Simply match processing in misc-use-anonymous-namespace
No need for the templated function "processMatch", since
we can infer the type with llvm:isa.
2022-12-12 14:05:19 +00:00
Carlos Galvez
7fd8387917 [clang-tidy] Do not warn about redundant static in misc-use-anonymous-namespace
The same functionality is already implemented in the
readability-static-definition-in-anonymous-namespace
check, including automatic fixes.

Differential Revision: https://reviews.llvm.org/D139197
2022-12-08 11:40:50 +00:00
Carlos Galvez
65d6d67fc9 [clang-tidy] Add misc-use-anonymous-namespace check
Differential Revision: https://reviews.llvm.org/D137340
2022-12-01 07:19:30 +00:00