Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:18

0001 //===--- LambdaFunctionNameCheck.h - clang-tidy------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_LAMBDAFUNCTIONNAMECHECK_H
0010 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_LAMBDAFUNCTIONNAMECHECK_H
0011 
0012 #include "../ClangTidyCheck.h"
0013 
0014 namespace clang::tidy::bugprone {
0015 
0016 /// Detect when __func__ or __FUNCTION__ is being used from within a lambda. In
0017 /// that context, those expressions expand to the name of the call operator
0018 /// (i.e., `operator()`).
0019 ///
0020 /// For the user-facing documentation see:
0021 /// http://clang.llvm.org/extra/clang-tidy/checks/bugprone/lambda-function-name.html
0022 class LambdaFunctionNameCheck : public ClangTidyCheck {
0023 public:
0024   struct SourceRangeLessThan {
0025     bool operator()(const SourceRange &L, const SourceRange &R) const {
0026       if (L.getBegin() == R.getBegin()) {
0027         return L.getEnd() < R.getEnd();
0028       }
0029       return L.getBegin() < R.getBegin();
0030     }
0031   };
0032   using SourceRangeSet = std::set<SourceRange, SourceRangeLessThan>;
0033 
0034   LambdaFunctionNameCheck(StringRef Name, ClangTidyContext *Context);
0035 
0036   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
0037   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
0038   void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
0039                            Preprocessor *ModuleExpanderPP) override;
0040   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
0041 
0042 private:
0043   SourceRangeSet SuppressMacroExpansions;
0044   bool IgnoreMacros;
0045 };
0046 
0047 } // namespace clang::tidy::bugprone
0048 
0049 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_LAMBDAFUNCTIONNAMECHECK_H