1 //== CheckerHelpers.h - Helper functions for checkers ------------*- C++ -*--=//
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
7 //===----------------------------------------------------------------------===//
9 // This file defines CheckerVisitor.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CHECKERHELPERS_H
14 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CHECKERHELPERS_H
16 #include "clang/AST/Stmt.h"
28 bool containsMacro(const Stmt *S);
29 bool containsEnum(const Stmt *S);
30 bool containsStaticLocal(const Stmt *S);
31 bool containsBuiltinOffsetOf(const Stmt *S);
32 template <class T> bool containsStmt(const Stmt *S) {
36 for (const Stmt *Child : S->children())
37 if (Child && containsStmt<T>(Child))
43 std::pair<const clang::VarDecl *, const clang::Expr *>
44 parseAssignment(const Stmt *S);
46 // Do not reorder! The getMostNullable method relies on the order.
47 // Optimization: Most pointers expected to be unspecified. When a symbol has an
48 // unspecified or nonnull type non of the rules would indicate any problem for
49 // that symbol. For this reason only nullable and contradicted nullability are
50 // stored for a symbol. When a symbol is already contradicted, it can not be
51 // casted back to nullable.
52 enum class Nullability : char {
53 Contradicted, // Tracked nullability is contradicted by an explicit cast. Do
54 // not report any nullability related issue for this symbol.
55 // This nullability is propagated aggressively to avoid false
56 // positive results. See the comment on getMostNullable method.
62 /// Get nullability annotation for a given type.
63 Nullability getNullabilityAnnotation(QualType Type);
67 } // end clang namespace