clang-tools 22.0.0git
AnonymousNamespaceInHeaderCheck.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_ANONYMOUSNAMESPACEINHEADERCHECK_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_ANONYMOUSNAMESPACEINHEADERCHECK_H
11
12#include "../ClangTidyCheck.h"
13
14namespace clang::tidy::misc {
15
16/// Finds anonymous namespaces in headers.
17///
18/// https://google.github.io/styleguide/cppguide.html#Namespaces
19///
20/// Corresponding cpplint.py check name: 'build/namespaces'.
21///
22/// For the user-facing documentation see:
23/// https://clang.llvm.org/extra/clang-tidy/checks/misc/anonymous-namespace-in-header.html
25public:
26 AnonymousNamespaceInHeaderCheck(StringRef Name, ClangTidyContext *Context);
27 bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
28 return LangOpts.CPlusPlus;
29 }
30 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
31 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
32
33private:
34 FileExtensionsSet HeaderFileExtensions;
35};
36
37} // namespace clang::tidy::misc
38
39#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_ANONYMOUSNAMESPACEINHEADERCHECK_H
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
AnonymousNamespaceInHeaderCheck(StringRef Name, ClangTidyContext *Context)
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
llvm::SmallSet< llvm::StringRef, 5 > FileExtensionsSet