//===- CalledOnceCheck.h - Check 'called once' parameters -------*- C++ -*-===// // // 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 // //===----------------------------------------------------------------------===// // // This file defines a check for function-like parameters that should be // called exactly one time. // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_ANALYSIS_ANALYSES_CALLEDONCECHECK_H #define LLVM_CLANG_ANALYSIS_ANALYSES_CALLEDONCECHECK_H namespace clang { class AnalysisDeclContext; class BlockDecl; class CFG; class Decl; class Expr; class ParmVarDecl; class Stmt; /// Classification of situations when parameter is not called on every path. /// \enum IfThen -- then branch of the if statement has no call. /// \enum IfElse -- else branch of the if statement has no call. /// \enum Switch -- one of the switch cases doesn't have a call. /// \enum SwitchSkipped -- there is no call if none of the cases applies. /// \enum LoopEntered -- no call when the loop is entered. /// \enum LoopSkipped -- no call when the loop is not entered. /// \enum FallbackReason -- fallback case when we were not able to figure out /// the reason. enum class NeverCalledReason { … }; class CalledOnceCheckHandler { … }; /// Check given CFG for 'called once' parameter violations. /// /// It traverses the function and tracks how such parameters are used. /// It detects two main violations: /// * parameter is called twice /// * parameter is not called /// /// \param AC -- context. /// \param Handler -- a handler for found violations. /// \param CheckConventionalParameters -- true, if we want to check parameters /// not explicitly marked as 'called once', but having the same requirements /// according to conventions. void checkCalledOnceParameters(AnalysisDeclContext &AC, CalledOnceCheckHandler &Handler, bool CheckConventionalParameters); } // end namespace clang #endif /* LLVM_CLANG_ANALYSIS_ANALYSES_CALLEDONCECHECK_H */