clang: lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
12#include "llvm/ADT/DenseSet.h"
13
15namespace dataflow {
16
17
18
19static bool
22
23
24 if (.isStatic())
25 return false;
26
27 if (CheckDecls.empty()) {
28
29
32 ParentClass->getName() != "CheckError")
33 return false;
34
35
36 const auto *N =
37 dyn_cast_or_null(ParentClass->getDeclContext());
38 if (N == nullptr || !N->getDeclName().isIdentifier() ||
39 N->getName() != "logging")
40 return false;
41
42
43 if (N->getParent() == nullptr || !N->getParent()->isTranslationUnit())
44 return false;
45
47 if (M->getDeclName().isIdentifier() && M->getName().ends_with("Check"))
48 CheckDecls.insert(M);
49 }
50
51 return CheckDecls.contains(&D);
52}
53
55 auto CS = Element.getAs<CFGStmt>();
56 if (!CS)
57 return false;
58 auto Stmt = CS->getStmt();
59 if (const auto *Call = dyn_cast(Stmt)) {
60 if (const auto *M =
61 dyn_cast_or_null(Call->getDirectCallee())) {
63
64 Env.assume(Env.arena().makeLiteral(false));
65 return true;
66 }
67 }
68 }
69 return false;
70}
71
72}
73}
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Represents a top-level expression in a basic block.
Represents a static or instance method of a struct/union/class.
Represents a C++ struct/union/class.
method_range methods() const
DeclContext * getDeclContext()
bool isIdentifier() const
Predicate functions for querying what type of name this is.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Stmt - This represents one statement.
bool transfer(const CFGElement &Element, Environment &Env) override
Return value indicates whether the model processed the Element.
Holds the state of the program (store and heap) at a given program point.
static bool isCheckLikeMethod(llvm::SmallDenseSet< const CXXMethodDecl * > &CheckDecls, const CXXMethodDecl &D)
Determines whether D is one of the methods used to implement Chromium's CHECK macros.
The JSON file list parser is used to communicate input to InstallAPI.