[TargetVersion] Only enable on RISC-V and AArch64 (#115991)
[llvm-project.git] / clang-tools-extra / clang-tidy / bugprone / LambdaFunctionNameCheck.h
blobdab64f74aa6ca0762a0f27dfa66293a751ec7ae6
1 //===--- LambdaFunctionNameCheck.h - clang-tidy------------------*- C++ -*-===//
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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_LAMBDAFUNCTIONNAMECHECK_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_LAMBDAFUNCTIONNAMECHECK_H
12 #include "../ClangTidyCheck.h"
14 namespace clang::tidy::bugprone {
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 /// http://clang.llvm.org/extra/clang-tidy/checks/bugprone/lambda-function-name.html
22 class LambdaFunctionNameCheck : public ClangTidyCheck {
23 public:
24 struct SourceRangeLessThan {
25 bool operator()(const SourceRange &L, const SourceRange &R) const {
26 if (L.getBegin() == R.getBegin()) {
27 return L.getEnd() < R.getEnd();
29 return L.getBegin() < R.getBegin();
32 using SourceRangeSet = std::set<SourceRange, SourceRangeLessThan>;
34 LambdaFunctionNameCheck(StringRef Name, ClangTidyContext *Context);
36 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
37 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
38 void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
39 Preprocessor *ModuleExpanderPP) override;
40 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
42 private:
43 SourceRangeSet SuppressMacroExpansions;
44 bool IgnoreMacros;
47 } // namespace clang::tidy::bugprone
49 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_LAMBDAFUNCTIONNAMECHECK_H