#include "clang/Analysis/Analyses/CalledOnceCheck.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclBase.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprObjC.h"
#include "clang/AST/OperationKinds.h"
#include "clang/AST/ParentMap.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/AST/Stmt.h"
#include "clang/AST/StmtObjC.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/AST/Type.h"
#include "clang/Analysis/AnalysisDeclContext.h"
#include "clang/Analysis/CFG.h"
#include "clang/Analysis/FlowSensitive/DataflowWorklist.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/BitmaskEnum.h"
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Sequence.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include <memory>
#include <optional>
usingnamespaceclang;
namespace {
static constexpr unsigned EXPECTED_MAX_NUMBER_OF_PARAMS = …;
ParamSizedVector;
static constexpr unsigned EXPECTED_NUMBER_OF_BASIC_BLOCKS = …;
CFGSizedVector;
constexpr llvm::StringLiteral CONVENTIONAL_NAMES[] = …;
constexpr llvm::StringLiteral CONVENTIONAL_SUFFIXES[] = …;
constexpr llvm::StringLiteral CONVENTIONAL_CONDITIONS[] = …;
struct KnownCalledOnceParameter { … };
constexpr KnownCalledOnceParameter KNOWN_CALLED_ONCE_PARAMETERS[] = …;
class ParameterStatus { … };
class State { … };
class DeclRefFinder
: public ConstStmtVisitor<DeclRefFinder, const DeclRefExpr *> { … };
const DeclRefExpr *findDeclRefExpr(const Expr *In,
bool ShouldRetrieveFromComparisons = false) { … }
const ParmVarDecl *
findReferencedParmVarDecl(const Expr *In,
bool ShouldRetrieveFromComparisons = false) { … }
const Expr *getCondition(const Stmt *S) { … }
class NamesCollector : public RecursiveASTVisitor<NamesCollector> { … };
bool mentionsAnyOfConventionalNames(const Expr *E) { … }
struct Clarification { … };
class NotCalledClarifier
: public ConstStmtVisitor<NotCalledClarifier,
std::optional<Clarification>> { … };
class CalledOnceChecker : public ConstStmtVisitor<CalledOnceChecker> { … };
}
namespace clang {
void checkCalledOnceParameters(AnalysisDeclContext &AC,
CalledOnceCheckHandler &Handler,
bool CheckConventionalParameters) { … }
}