]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h
Merge clang 7.0.1 and several follow-up changes
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / StaticAnalyzer / Core / PathSensitive / CheckerHelpers.h
1 //== CheckerHelpers.h - Helper functions for checkers ------------*- C++ -*--=//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //  This file defines CheckerVisitor.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CHECKERHELPERS_H
15 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CHECKERHELPERS_H
16
17 #include "clang/AST/Stmt.h"
18 #include <tuple>
19
20 namespace clang {
21
22 class Expr;
23 class VarDecl;
24 class QualType;
25 class AttributedType;
26
27 namespace ento {
28
29 bool containsMacro(const Stmt *S);
30 bool containsEnum(const Stmt *S);
31 bool containsStaticLocal(const Stmt *S);
32 bool containsBuiltinOffsetOf(const Stmt *S);
33 template <class T> bool containsStmt(const Stmt *S) {
34   if (isa<T>(S))
35       return true;
36
37   for (const Stmt *Child : S->children())
38     if (Child && containsStmt<T>(Child))
39       return true;
40
41   return false;
42 }
43
44 std::pair<const clang::VarDecl *, const clang::Expr *>
45 parseAssignment(const Stmt *S);
46
47 // Do not reorder! The getMostNullable method relies on the order.
48 // Optimization: Most pointers expected to be unspecified. When a symbol has an
49 // unspecified or nonnull type non of the rules would indicate any problem for
50 // that symbol. For this reason only nullable and contradicted nullability are
51 // stored for a symbol. When a symbol is already contradicted, it can not be
52 // casted back to nullable.
53 enum class Nullability : char {
54   Contradicted, // Tracked nullability is contradicted by an explicit cast. Do
55                 // not report any nullability related issue for this symbol.
56                 // This nullability is propagated aggressively to avoid false
57                 // positive results. See the comment on getMostNullable method.
58   Nullable,
59   Unspecified,
60   Nonnull
61 };
62
63 /// Get nullability annotation for a given type.
64 Nullability getNullabilityAnnotation(QualType Type);
65
66 } // end GR namespace
67
68 } // end clang namespace
69
70 #endif