clang-tools 22.0.0git
LambdaFunctionNameCheck.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_BUGPRONE_LAMBDAFUNCTIONNAMECHECK_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_LAMBDAFUNCTIONNAMECHECK_H
11
12#include "../ClangTidyCheck.h"
13
14namespace clang::tidy::bugprone {
15
16/// Detect when __func__ or __FUNCTION__ is being used from within a lambda. In
17/// that context, those expressions expand to the name of the call operator
18/// (i.e., `operator()`).
19///
20/// For the user-facing documentation see:
21/// https://clang.llvm.org/extra/clang-tidy/checks/bugprone/lambda-function-name.html
23public:
24 LambdaFunctionNameCheck(StringRef Name, ClangTidyContext *Context);
25 bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
26 return LangOpts.CPlusPlus11;
27 }
28
29 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
30 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
31 void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
32 Preprocessor *ModuleExpanderPP) override;
33 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
34
35private:
36 llvm::DenseSet<SourceRange> SuppressMacroExpansions;
37 bool IgnoreMacros;
38};
39
40} // namespace clang::tidy::bugprone
41
42#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_LAMBDAFUNCTIONNAMECHECK_H
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) override
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
LambdaFunctionNameCheck(StringRef Name, ClangTidyContext *Context)
llvm::StringMap< ClangTidyValue > OptionMap