NoRecursionCheck.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //===--- NoRecursionCheck.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. //===----------------------------------------------------------------------===//
  8. #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NORECURSIONCHECK_H
  9. #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NORECURSIONCHECK_H
  10. #include "../ClangTidyCheck.h"
  11. namespace clang {
  12. class CallGraphNode;
  13. namespace tidy::misc {
  14. /// Finds strongly connected functions (by analyzing call graph for SCC's
  15. /// that are loops), diagnoses each function in the cycle,
  16. /// and displays one example of possible call graph loop (recursion).
  17. ///
  18. /// For the user-facing documentation see:
  19. /// http://clang.llvm.org/extra/clang-tidy/checks/misc/no-recursion.html
  20. class NoRecursionCheck : public ClangTidyCheck {
  21. public:
  22. NoRecursionCheck(StringRef Name, ClangTidyContext *Context)
  23. : ClangTidyCheck(Name, Context) {}
  24. void registerMatchers(ast_matchers::MatchFinder *Finder) override;
  25. void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
  26. private:
  27. void handleSCC(ArrayRef<CallGraphNode *> SCC);
  28. };
  29. } // namespace tidy::misc
  30. } // namespace clang
  31. #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NORECURSIONCHECK_H