clang 8.0.0

ThreadSafetyLogical.h
Go to the documentation of this file.
1 //===- ThreadSafetyLogical.h -----------------------------------*- 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 // This file defines a representation for logical expressions with SExpr leaves
10 // that are used as part of fact-checking capability expressions.
11 //===----------------------------------------------------------------------===//
12
13 #ifndef LLVM_CLANG_ANALYSIS_ANALYSES_THREADSAFETYLOGICAL_H
14 #define LLVM_CLANG_ANALYSIS_ANALYSES_THREADSAFETYLOGICAL_H
15
16 #include "clang/Analysis/Analyses/ThreadSafetyTIL.h"
17
18 namespace clang {
19 namespace threadSafety {
20 namespace lexpr {
21
22 class LExpr {
23 public:
24 enum Opcode {
25 Terminal,
26 And,
27 Or,
28 Not
29 };
30 Opcode kind() const { return Kind; }
31
32 /// Logical implication. Returns true if the LExpr implies RHS, i.e. if
33 /// the LExpr holds, then RHS must hold. For example, (A & B) implies A.
34 inline bool implies(const LExpr *RHS) const;
35
36 protected:
37 LExpr(Opcode Kind) : Kind(Kind) {}
38
39 private:
40 Opcode Kind;
41 };
42
43 class Terminal : public LExpr {
44 til::SExpr *Expr;
45
46 public:
47 Terminal(til::SExpr *Expr) : LExpr(LExpr::Terminal), Expr(Expr) {}
48
49 const til::SExpr *expr() const { return Expr; }
50 til::SExpr *expr() { return Expr; }
51
52 static bool classof(const LExpr *E) { return E->kind() == LExpr::Terminal; }
53 };
54
55 class BinOp : public LExpr {
56 LExpr *LHS, *RHS;
57
58 protected:
59 BinOp(LExpr *LHS, LExpr *RHS, Opcode Code) : LExpr(Code), LHS(LHS), RHS(RHS) {}
60
61 public:
62 const LExpr *left() const { return LHS; }
63 LExpr *left() { return LHS; }
64
65 const LExpr *right() const { return RHS; }
66 LExpr *right() { return RHS; }
67 };
68
69 class And : public BinOp {
70 public:
71 And(LExpr *LHS, LExpr *RHS) : BinOp(LHS, RHS, LExpr::And) {}
72
73 static bool classof(const LExpr *E) { return E->kind() == LExpr::And; }
74 };
75
76 class Or : public BinOp {
77 public:
78 Or(LExpr *LHS, LExpr *RHS) : BinOp(LHS, RHS, LExpr::Or) {}
79
80 static bool classof(const LExpr *E) { return E->kind() == LExpr::Or; }
81 };
82
83 class Not : public LExpr {
84 LExpr *Exp;
85
86 public:
87 Not(LExpr *Exp) : LExpr(LExpr::Not), Exp(Exp) {}
88
89 const LExpr *exp() const { return Exp; }
90 LExpr *exp() { return Exp; }
91
92 static bool classof(const LExpr *E) { return E->kind() == LExpr::Not; }
93 };
94
95 /// Logical implication. Returns true if LHS implies RHS, i.e. if LHS
96 /// holds, then RHS must hold. For example, (A & B) implies A.
97 bool implies(const LExpr *LHS, const LExpr *RHS);
98
99 bool LExpr::implies(const LExpr *RHS) const {
100 return lexpr::implies(this, RHS);
101 }
102
103 }
104 }
105 }
106
107 #endif
108
clang::threadSafety::lexpr::LExpr::Not
Definition: ThreadSafetyLogical.h:28
clang::threadSafety::lexpr::LExpr::And
Definition: ThreadSafetyLogical.h:26
clang::threadSafety::lexpr::LExpr::kind
Opcode kind() const
Definition: ThreadSafetyLogical.h:30
clang::threadSafety::lexpr::LExpr::Or
Definition: ThreadSafetyLogical.h:27
clang::threadSafety::lexpr::implies
bool implies(const LExpr *LHS, const LExpr *RHS)
Logical implication.
Definition: ThreadSafetyLogical.cpp:106
clang::threadSafety::lexpr::Not::exp
LExpr * exp()
Definition: ThreadSafetyLogical.h:90
clang::threadSafety::lexpr::LExpr::Opcode
Opcode
Definition: ThreadSafetyLogical.h:24
clang::threadSafety::lexpr::Terminal::expr
til::SExpr * expr()
Definition: ThreadSafetyLogical.h:50
clang::threadSafety::lexpr::LExpr::implies
bool implies(const LExpr *RHS) const
Logical implication.
Definition: ThreadSafetyLogical.h:99
ThreadSafetyTIL.h
clang::threadSafety::lexpr::BinOp::right
LExpr * right()
Definition: ThreadSafetyLogical.h:66
clang::threadSafety::lexpr::Terminal
Definition: ThreadSafetyLogical.h:43
clang::Expr
This represents one expression.
Definition: Expr.h:106
clang::threadSafety::lexpr::Terminal::Terminal
Terminal(til::SExpr *Expr)
Definition: ThreadSafetyLogical.h:47
clang::threadSafety::lexpr::LExpr::LExpr
LExpr(Opcode Kind)
Definition: ThreadSafetyLogical.h:37
clang::threadSafety::lexpr::Or
Definition: ThreadSafetyLogical.h:76
Kind
Kind
Definition: ChrootChecker.cpp:29
clang::threadSafety::lexpr::BinOp::BinOp
BinOp(LExpr *LHS, LExpr *RHS, Opcode Code)
Definition: ThreadSafetyLogical.h:59
clang::threadSafety::lexpr::Or::classof
static bool classof(const LExpr *E)
Definition: ThreadSafetyLogical.h:80
clang::threadSafety::lexpr::Not
Definition: ThreadSafetyLogical.h:83
clang::threadSafety::lexpr::LExpr::Terminal
Definition: ThreadSafetyLogical.h:25
clang::threadSafety::lexpr::Or::Or
Or(LExpr *LHS, LExpr *RHS)
Definition: ThreadSafetyLogical.h:78
clang::threadSafety::lexpr::LExpr
Definition: ThreadSafetyLogical.h:22
clang::threadSafety::lexpr::And::classof
static bool classof(const LExpr *E)
Definition: ThreadSafetyLogical.h:73
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22
clang::threadSafety::lexpr::BinOp::right
const LExpr * right() const
Definition: ThreadSafetyLogical.h:65
clang::threadSafety::lexpr::Not::Not
Not(LExpr *Exp)
Definition: ThreadSafetyLogical.h:87
clang::threadSafety::lexpr::And::And
And(LExpr *LHS, LExpr *RHS)
Definition: ThreadSafetyLogical.h:71
clang::threadSafety::lexpr::BinOp::left
LExpr * left()
Definition: ThreadSafetyLogical.h:63
clang::threadSafety::lexpr::Not::classof
static bool classof(const LExpr *E)
Definition: ThreadSafetyLogical.h:92
clang::threadSafety::lexpr::BinOp::left
const LExpr * left() const
Definition: ThreadSafetyLogical.h:62
clang::threadSafety::lexpr::BinOp
Definition: ThreadSafetyLogical.h:55
clang::threadSafety::lexpr::Terminal::expr
const til::SExpr * expr() const
Definition: ThreadSafetyLogical.h:49
clang::threadSafety::til::SExpr
Base class for AST nodes in the typed intermediate language.
Definition: ThreadSafetyTIL.h:278
clang::threadSafety::lexpr::Not::exp
const LExpr * exp() const
Definition: ThreadSafetyLogical.h:89
clang::threadSafety::lexpr::Terminal::classof
static bool classof(const LExpr *E)
Definition: ThreadSafetyLogical.h:52
clang::threadSafety::lexpr::And
Definition: ThreadSafetyLogical.h:69