//===--- NoRecursionCheck.cpp - clang-tidy --------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "NoRecursionCheck.h" #include "clang/AST/ASTContext.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/Analysis/CallGraph.h" #include "llvm/ADT/DenseMapInfo.h" #include "llvm/ADT/SCCIterator.h" usingnamespaceclang::ast_matchers; namespace clang::tidy::misc { namespace { /// Much like SmallSet, with two differences: /// 1. It can *only* be constructed from an ArrayRef<>. If the element count /// is small, there is no copy and said storage *must* outlive us. /// 2. it is immutable, the way it was constructed it will stay. template <typename T, unsigned SmallSize> class ImmutableSmallSet { … }; /// Much like SmallSetVector, but with one difference: /// when the size is \p SmallSize or less, when checking whether an element is /// already in the set or not, we perform linear search over the vector, /// but if the size is larger than \p SmallSize, we look in set. /// FIXME: upstream this into SetVector/SmallSetVector itself. template <typename T, unsigned SmallSize> class SmartSmallSetVector { … }; constexpr unsigned SmallCallStackSize = …; constexpr unsigned SmallSCCSize = …; CallStackTy; // In given SCC, find *some* call stack that will be cyclic. // This will only find *one* such stack, it might not be the smallest one, // and there may be other loops. CallStackTy pathfindSomeCycle(ArrayRef<CallGraphNode *> SCC) { … } } // namespace void NoRecursionCheck::registerMatchers(MatchFinder *Finder) { … } void NoRecursionCheck::handleSCC(ArrayRef<CallGraphNode *> SCC) { … } void NoRecursionCheck::check(const MatchFinder::MatchResult &Result) { … } } // namespace clang::tidy::misc