//== CheckerHelpers.h - Helper functions for checkers ------------*- 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 various utilities used by checkers. // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CHECKERHELPERS_H #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CHECKERHELPERS_H #include "ProgramState_Fwd.h" #include "SVals.h" #include "clang/AST/OperationKinds.h" #include "clang/AST/Stmt.h" #include "clang/Basic/OperatorKinds.h" #include <optional> #include <tuple> namespace clang { class Expr; class VarDecl; class QualType; class Preprocessor; namespace ento { bool containsMacro(const Stmt *S); bool containsEnum(const Stmt *S); bool containsStaticLocal(const Stmt *S); bool containsBuiltinOffsetOf(const Stmt *S); template <class T> bool containsStmt(const Stmt *S) { … } std::pair<const clang::VarDecl *, const clang::Expr *> parseAssignment(const Stmt *S); // Do not reorder! The getMostNullable method relies on the order. // Optimization: Most pointers expected to be unspecified. When a symbol has an // unspecified or nonnull type non of the rules would indicate any problem for // that symbol. For this reason only nullable and contradicted nullability are // stored for a symbol. When a symbol is already contradicted, it can not be // casted back to nullable. enum class Nullability : char { … }; /// Get nullability annotation for a given type. Nullability getNullabilityAnnotation(QualType Type); /// Try to parse the value of a defined preprocessor macro. We can only parse /// simple expressions that consist of an optional minus sign token and then a /// token for an integer. If we cannot parse the value then std::nullopt is /// returned. std::optional<int> tryExpandAsInteger(StringRef Macro, const Preprocessor &PP); class OperatorKind { … }; OperatorKind operationKindFromOverloadedOperator(OverloadedOperatorKind OOK, bool IsBinary); std::optional<SVal> getPointeeVal(SVal PtrSVal, ProgramStateRef State); /// Returns true if declaration \p D is in std namespace or any nested namespace /// or class scope. bool isWithinStdNamespace(const Decl *D); } // namespace ento } // namespace clang #endif