clang  7.0.0svn
CheckerHelpers.h
Go to the documentation of this file.
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,
60  Nonnull
61 };
62 
63 /// Get nullability annotation for a given type.
65 
66 } // end GR namespace
67 
68 } // end clang namespace
69 
70 #endif
A (possibly-)qualified type.
Definition: Type.h:654
bool containsStaticLocal(const Stmt *S)
Stmt - This represents one statement.
Definition: Stmt.h:66
The base class of the type hierarchy.
Definition: Type.h:1420
bool containsBuiltinOffsetOf(const Stmt *S)
child_range children()
Definition: Stmt.cpp:227
The l-value was considered opaque, so the alignment was determined from a type, but that type was an ...
bool containsStmt(const Stmt *S)
std::pair< const clang::VarDecl *, const clang::Expr * > parseAssignment(const Stmt *S)
Dataflow Directional Tag Classes.
Nullability getNullabilityAnnotation(QualType Type)
Get nullability annotation for a given type.
bool containsMacro(const Stmt *S)
bool containsEnum(const Stmt *S)