clang 10.0.0git

ThreadSafetyCommon.h
Go to the documentation of this file.
1 //===- ThreadSafetyCommon.h -------------------------------------*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Parts of thread safety analysis that are not specific to thread safety
10 // itself have been factored into classes here, where they can be potentially
11 // used by other analyses. Currently these include:
12 //
13 // * Generalize clang CFG visitors.
14 // * Conversion of the clang CFG to SSA form.
15 // * Translation of clang Exprs to TIL SExprs
16 //
17 // UNDER CONSTRUCTION. USE AT YOUR OWN RISK.
18 //
19 //===----------------------------------------------------------------------===//
20
21 #ifndef LLVM_CLANG_ANALYSIS_ANALYSES_THREADSAFETYCOMMON_H
22 #define LLVM_CLANG_ANALYSIS_ANALYSES_THREADSAFETYCOMMON_H
23
24 #include "clang/AST/Decl.h"
25 #include "clang/Analysis/Analyses/PostOrderCFGView.h"
26 #include "clang/Analysis/Analyses/ThreadSafetyTIL.h"
27 #include "clang/Analysis/Analyses/ThreadSafetyTraverse.h"
28 #include "clang/Analysis/Analyses/ThreadSafetyUtil.h"
29 #include "clang/Analysis/AnalysisDeclContext.h"
30 #include "clang/Analysis/CFG.h"
31 #include "clang/Basic/LLVM.h"
32 #include "llvm/ADT/DenseMap.h"
33 #include "llvm/ADT/SmallVector.h"
34 #include "llvm/Support/Casting.h"
35 #include <sstream>
36 #include <string>
37 #include <utility>
38 #include <vector>
39
40 namespace clang {
41
42 class AbstractConditionalOperator;
43 class ArraySubscriptExpr;
44 class BinaryOperator;
45 class CallExpr;
46 class CastExpr;
47 class CXXDestructorDecl;
48 class CXXMemberCallExpr;
49 class CXXOperatorCallExpr;
50 class CXXThisExpr;
51 class DeclRefExpr;
52 class DeclStmt;
53 class Expr;
54 class MemberExpr;
55 class Stmt;
56 class UnaryOperator;
57
58 namespace threadSafety {
59
60 // Various helper functions on til::SExpr
61 namespace sx {
62
63 inline bool equals(const til::SExpr *E1, const til::SExpr *E2) {
64 return til::EqualsComparator::compareExprs(E1, E2);
65 }
66
67 inline bool matches(const til::SExpr *E1, const til::SExpr *E2) {
68 // We treat a top-level wildcard as the "univsersal" lock.
69 // It matches everything for the purpose of checking locks, but not
70 // for unlocking them.
71 if (isa<til::Wildcard>(E1))
72 return isa<til::Wildcard>(E2);
73 if (isa<til::Wildcard>(E2))
74 return isa<til::Wildcard>(E1);
75
76 return til::MatchComparator::compareExprs(E1, E2);
77 }
78
79 inline bool partiallyMatches(const til::SExpr *E1, const til::SExpr *E2) {
80 const auto *PE1 = dyn_cast_or_null<til::Project>(E1);
81 if (!PE1)
82 return false;
83 const auto *PE2 = dyn_cast_or_null<til::Project>(E2);
84 if (!PE2)
85 return false;
86 return PE1->clangDecl() == PE2->clangDecl();
87 }
88
89 inline std::string toString(const til::SExpr *E) {
90 std::stringstream ss;
91 til::StdPrinter::print(E, ss);
92 return ss.str();
93 }
94
95 } // namespace sx
96
97 // This class defines the interface of a clang CFG Visitor.
98 // CFGWalker will invoke the following methods.
99 // Note that methods are not virtual; the visitor is templatized.
100 class CFGVisitor {
101 // Enter the CFG for Decl D, and perform any initial setup operations.
102 void enterCFG(CFG *Cfg, const NamedDecl *D, const CFGBlock *First) {}
103
104 // Enter a CFGBlock.
105 void enterCFGBlock(const CFGBlock *B) {}
106
107 // Returns true if this visitor implements handlePredecessor
108 bool visitPredecessors() { return true; }
109
110 // Process a predecessor edge.
111 void handlePredecessor(const CFGBlock *Pred) {}
112
113 // Process a successor back edge to a previously visited block.
114 void handlePredecessorBackEdge(const CFGBlock *Pred) {}
115
116 // Called just before processing statements.
117 void enterCFGBlockBody(const CFGBlock *B) {}
118
119 // Process an ordinary statement.
120 void handleStatement(const Stmt *S) {}
121
122 // Process a destructor call
123 void handleDestructorCall(const VarDecl *VD, const CXXDestructorDecl *DD) {}
124
125 // Called after all statements have been handled.
126 void exitCFGBlockBody(const CFGBlock *B) {}
127
128 // Return true
129 bool visitSuccessors() { return true; }
130
131 // Process a successor edge.
132 void handleSuccessor(const CFGBlock *Succ) {}
133
134 // Process a successor back edge to a previously visited block.
135 void handleSuccessorBackEdge(const CFGBlock *Succ) {}
136
137 // Leave a CFGBlock.
138 void exitCFGBlock(const CFGBlock *B) {}
139
140 // Leave the CFG, and perform any final cleanup operations.
141 void exitCFG(const CFGBlock *Last) {}
142 };
143
144 // Walks the clang CFG, and invokes methods on a given CFGVisitor.
145 class CFGWalker {
146 public:
147 CFGWalker() = default;
148
149 // Initialize the CFGWalker. This setup only needs to be done once, even
150 // if there are multiple passes over the CFG.
151 bool init(AnalysisDeclContext &AC) {
152 ACtx = &AC;
153 CFGraph = AC.getCFG();
154 if (!CFGraph)
155 return false;
156
157 // Ignore anonymous functions.
158 if (!dyn_cast_or_null<NamedDecl>(AC.getDecl()))
159 return false;
160
161 SortedGraph = AC.getAnalysis<PostOrderCFGView>();
162 if (!SortedGraph)
163 return false;
164
165 return true;
166 }
167
168 // Traverse the CFG, calling methods on V as appropriate.
169 template <class Visitor>
170 void walk(Visitor &V) {
171 PostOrderCFGView::CFGBlockSet VisitedBlocks(CFGraph);
172
173 V.enterCFG(CFGraph, getDecl(), &CFGraph->getEntry());
174
175 for (const auto *CurrBlock : *SortedGraph) {
176 VisitedBlocks.insert(CurrBlock);
177
178 V.enterCFGBlock(CurrBlock);
179
180 // Process predecessors, handling back edges last
181 if (V.visitPredecessors()) {
182 SmallVector<CFGBlock*, 4> BackEdges;
183 // Process successors
184 for (CFGBlock::const_pred_iterator SI = CurrBlock->pred_begin(),
185 SE = CurrBlock->pred_end();
186 SI != SE; ++SI) {
187 if (*SI == nullptr)
188 continue;
189
190 if (!VisitedBlocks.alreadySet(*SI)) {
191 BackEdges.push_back(*SI);
192 continue;
193 }
194 V.handlePredecessor(*SI);
195 }
196
197 for (auto *Blk : BackEdges)
198 V.handlePredecessorBackEdge(Blk);
199 }
200
201 V.enterCFGBlockBody(CurrBlock);
202
203 // Process statements
204 for (const auto &BI : *CurrBlock) {
205 switch (BI.getKind()) {
206 case CFGElement::Statement:
207 V.handleStatement(BI.castAs<CFGStmt>().getStmt());
208 break;
209
210 case CFGElement::AutomaticObjectDtor: {
211 CFGAutomaticObjDtor AD = BI.castAs<CFGAutomaticObjDtor>();
212 auto *DD = const_cast<CXXDestructorDecl *>(
213 AD.getDestructorDecl(ACtx->getASTContext()));
214 auto *VD = const_cast<VarDecl *>(AD.getVarDecl());
215 V.handleDestructorCall(VD, DD);
216 break;
217 }
218 default:
219 break;
220 }
221 }
222
223 V.exitCFGBlockBody(CurrBlock);
224
225 // Process successors, handling back edges first.
226 if (V.visitSuccessors()) {
227 SmallVector<CFGBlock*, 8> ForwardEdges;
228
229 // Process successors
230 for (CFGBlock::const_succ_iterator SI = CurrBlock->succ_begin(),
231 SE = CurrBlock->succ_end();
232 SI != SE; ++SI) {
233 if (*SI == nullptr)
234 continue;
235
236 if (!VisitedBlocks.alreadySet(*SI)) {
237 ForwardEdges.push_back(*SI);
238 continue;
239 }
240 V.handleSuccessorBackEdge(*SI);
241 }
242
243 for (auto *Blk : ForwardEdges)
244 V.handleSuccessor(Blk);
245 }
246
247 V.exitCFGBlock(CurrBlock);
248 }
249 V.exitCFG(&CFGraph->getExit());
250 }
251
252 const CFG *getGraph() const { return CFGraph; }
253 CFG *getGraph() { return CFGraph; }
254
255 const NamedDecl *getDecl() const {
256 return dyn_cast<NamedDecl>(ACtx->getDecl());
257 }
258
259 const PostOrderCFGView *getSortedGraph() const { return SortedGraph; }
260
261 private:
262 CFG *CFGraph = nullptr;
263 AnalysisDeclContext *ACtx = nullptr;
264 PostOrderCFGView *SortedGraph = nullptr;
265 };
266
267 // TODO: move this back into ThreadSafety.cpp
268 // This is specific to thread safety. It is here because
269 // translateAttrExpr needs it, but that should be moved too.
270 class CapabilityExpr {
271 private:
272 /// The capability expression.
273 const til::SExpr* CapExpr;
274
275 /// True if this is a negative capability.
276 bool Negated;
277
278 public:
279 CapabilityExpr(const til::SExpr *E, bool Neg) : CapExpr(E), Negated(Neg) {}
280
281 const til::SExpr* sexpr() const { return CapExpr; }
282 bool negative() const { return Negated; }
283
284 CapabilityExpr operator!() const {
285 return CapabilityExpr(CapExpr, !Negated);
286 }
287
288 bool equals(const CapabilityExpr &other) const {
289 return (Negated == other.Negated) && sx::equals(CapExpr, other.CapExpr);
290 }
291
292 bool matches(const CapabilityExpr &other) const {
293 return (Negated == other.Negated) && sx::matches(CapExpr, other.CapExpr);
294 }
295
296 bool matchesUniv(const CapabilityExpr &CapE) const {
297 return isUniversal() || matches(CapE);
298 }
299
300 bool partiallyMatches(const CapabilityExpr &other) const {
301 return (Negated == other.Negated) &&
302 sx::partiallyMatches(CapExpr, other.CapExpr);
303 }
304
305 const ValueDecl* valueDecl() const {
306 if (Negated || CapExpr == nullptr)
307 return nullptr;
308 if (const auto *P = dyn_cast<til::Project>(CapExpr))
309 return P->clangDecl();
310 if (const auto *P = dyn_cast<til::LiteralPtr>(CapExpr))
311 return P->clangDecl();
312 return nullptr;
313 }
314
315 std::string toString() const {
316 if (Negated)
317 return "!" + sx::toString(CapExpr);
318 return sx::toString(CapExpr);
319 }
320
321 bool shouldIgnore() const { return CapExpr == nullptr; }
322
323 bool isInvalid() const { return sexpr() && isa<til::Undefined>(sexpr()); }
324
325 bool isUniversal() const { return sexpr() && isa<til::Wildcard>(sexpr()); }
326 };
327
328 // Translate clang::Expr to til::SExpr.
329 class SExprBuilder {
330 public:
331 /// Encapsulates the lexical context of a function call. The lexical
332 /// context includes the arguments to the call, including the implicit object
333 /// argument. When an attribute containing a mutex expression is attached to
334 /// a method, the expression may refer to formal parameters of the method.
335 /// Actual arguments must be substituted for formal parameters to derive
336 /// the appropriate mutex expression in the lexical context where the function
337 /// is called. PrevCtx holds the context in which the arguments themselves
338 /// should be evaluated; multiple calling contexts can be chained together
339 /// by the lock_returned attribute.
340 struct CallingContext {
341 // The previous context; or 0 if none.
342 CallingContext *Prev;
343
344 // The decl to which the attr is attached.
345 const NamedDecl *AttrDecl;
346
347 // Implicit object argument -- e.g. 'this'
348 const Expr *SelfArg = nullptr;
349
350 // Number of funArgs
351 unsigned NumArgs = 0;
352
353 // Function arguments
354 const Expr *const *FunArgs = nullptr;
355
356 // is Self referred to with -> or .?
357 bool SelfArrow = false;
358
359 CallingContext(CallingContext *P, const NamedDecl *D = nullptr)
360 : Prev(P), AttrDecl(D) {}
361 };
362
363 SExprBuilder(til::MemRegionRef A) : Arena(A) {
364 // FIXME: we don't always have a self-variable.
365 SelfVar = new (Arena) til::Variable(nullptr);
366 SelfVar->setKind(til::Variable::VK_SFun);
367 }
368
369 // Translate a clang expression in an attribute to a til::SExpr.
370 // Constructs the context from D, DeclExp, and SelfDecl.
371 CapabilityExpr translateAttrExpr(const Expr *AttrExp, const NamedDecl *D,
372 const Expr *DeclExp, VarDecl *SelfD=nullptr);
373
374 CapabilityExpr translateAttrExpr(const Expr *AttrExp, CallingContext *Ctx);
375
376 // Translate a clang statement or expression to a TIL expression.
377 // Also performs substitution of variables; Ctx provides the context.
378 // Dispatches on the type of S.
379 til::SExpr *translate(const Stmt *S, CallingContext *Ctx);
380 til::SCFG *buildCFG(CFGWalker &Walker);
381
382 til::SExpr *lookupStmt(const Stmt *S);
383
384 til::BasicBlock *lookupBlock(const CFGBlock *B) {
385 return BlockMap[B->getBlockID()];
386 }
387
388 const til::SCFG *getCFG() const { return Scfg; }
389 til::SCFG *getCFG() { return Scfg; }
390
391 private:
392 // We implement the CFGVisitor API
393 friend class CFGWalker;
394
395 til::SExpr *translateDeclRefExpr(const DeclRefExpr *DRE,
396 CallingContext *Ctx) ;
397 til::SExpr *translateCXXThisExpr(const CXXThisExpr *TE, CallingContext *Ctx);
398 til::SExpr *translateMemberExpr(const MemberExpr *ME, CallingContext *Ctx);
399 til::SExpr *translateObjCIVarRefExpr(const ObjCIvarRefExpr *IVRE,
400 CallingContext *Ctx);
401 til::SExpr *translateCallExpr(const CallExpr *CE, CallingContext *Ctx,
402 const Expr *SelfE = nullptr);
403 til::SExpr *translateCXXMemberCallExpr(const CXXMemberCallExpr *ME,
404 CallingContext *Ctx);
405 til::SExpr *translateCXXOperatorCallExpr(const CXXOperatorCallExpr *OCE,
406 CallingContext *Ctx);
407 til::SExpr *translateUnaryOperator(const UnaryOperator *UO,
408 CallingContext *Ctx);
409 til::SExpr *translateBinOp(til::TIL_BinaryOpcode Op,
410 const BinaryOperator *BO,
411 CallingContext *Ctx, bool Reverse = false);
412 til::SExpr *translateBinAssign(til::TIL_BinaryOpcode Op,
413 const BinaryOperator *BO,
414 CallingContext *Ctx, bool Assign = false);
415 til::SExpr *translateBinaryOperator(const BinaryOperator *BO,
416 CallingContext *Ctx);
417 til::SExpr *translateCastExpr(const CastExpr *CE, CallingContext *Ctx);
418 til::SExpr *translateArraySubscriptExpr(const ArraySubscriptExpr *E,
419 CallingContext *Ctx);
420 til::SExpr *translateAbstractConditionalOperator(
421 const AbstractConditionalOperator *C, CallingContext *Ctx);
422
423 til::SExpr *translateDeclStmt(const DeclStmt *S, CallingContext *Ctx);
424
425 // Map from statements in the clang CFG to SExprs in the til::SCFG.
426 using StatementMap = llvm::DenseMap<const Stmt *, til::SExpr *>;
427
428 // Map from clang local variables to indices in a LVarDefinitionMap.
429 using LVarIndexMap = llvm::DenseMap<const ValueDecl *, unsigned>;
430
431 // Map from local variable indices to SSA variables (or constants).
432 using NameVarPair = std::pair<const ValueDecl *, til::SExpr *>;
433 using LVarDefinitionMap = CopyOnWriteVector<NameVarPair>;
434
435 struct BlockInfo {
436 LVarDefinitionMap ExitMap;
437 bool HasBackEdges = false;
438
439 // Successors yet to be processed
440 unsigned UnprocessedSuccessors = 0;
441
442 // Predecessors already processed
443 unsigned ProcessedPredecessors = 0;
444
445 BlockInfo() = default;
446 BlockInfo(BlockInfo &&) = default;
447 BlockInfo &operator=(BlockInfo &&) = default;
448 };
449
450 void enterCFG(CFG *Cfg, const NamedDecl *D, const CFGBlock *First);
451 void enterCFGBlock(const CFGBlock *B);
452 bool visitPredecessors() { return true; }
453 void handlePredecessor(const CFGBlock *Pred);
454 void handlePredecessorBackEdge(const CFGBlock *Pred);
455 void enterCFGBlockBody(const CFGBlock *B);
456 void handleStatement(const Stmt *S);
457 void handleDestructorCall(const VarDecl *VD, const CXXDestructorDecl *DD);
458 void exitCFGBlockBody(const CFGBlock *B);
459 bool visitSuccessors() { return true; }
460 void handleSuccessor(const CFGBlock *Succ);
461 void handleSuccessorBackEdge(const CFGBlock *Succ);
462 void exitCFGBlock(const CFGBlock *B);
463 void exitCFG(const CFGBlock *Last);
464
465 void insertStmt(const Stmt *S, til::SExpr *E) {
466 SMap.insert(std::make_pair(S, E));
467 }
468
469 til::SExpr *getCurrentLVarDefinition(const ValueDecl *VD);
470
471 til::SExpr *addStatement(til::SExpr *E, const Stmt *S,
472 const ValueDecl *VD = nullptr);
473 til::SExpr *lookupVarDecl(const ValueDecl *VD);
474 til::SExpr *addVarDecl(const ValueDecl *VD, til::SExpr *E);
475 til::SExpr *updateVarDecl(const ValueDecl *VD, til::SExpr *E);
476
477 void makePhiNodeVar(unsigned i, unsigned NPreds, til::SExpr *E);
478 void mergeEntryMap(LVarDefinitionMap Map);
479 void mergeEntryMapBackEdge();
480 void mergePhiNodesBackEdge(const CFGBlock *Blk);
481
482 private:
483 // Set to true when parsing capability expressions, which get translated
484 // inaccurately in order to hack around smart pointers etc.
485 static const bool CapabilityExprMode = true;
486
487 til::MemRegionRef Arena;
488
489 // Variable to use for 'this'. May be null.
490 til::Variable *SelfVar = nullptr;
491
492 til::SCFG *Scfg = nullptr;
493
494 // Map from Stmt to TIL Variables
495 StatementMap SMap;
496
497 // Indices of clang local vars.
498 LVarIndexMap LVarIdxMap;
499
500 // Map from clang to til BBs.
501 std::vector<til::BasicBlock *> BlockMap;
502
503 // Extra information per BB. Indexed by clang BlockID.
504 std::vector<BlockInfo> BBInfo;
505
506 LVarDefinitionMap CurrentLVarMap;
507 std::vector<til::Phi *> CurrentArguments;
508 std::vector<til::SExpr *> CurrentInstructions;
509 std::vector<til::Phi *> IncompleteArgs;
510 til::BasicBlock *CurrentBB = nullptr;
511 BlockInfo *CurrentBlockInfo = nullptr;
512 };
513
514 // Dump an SCFG to llvm::errs().
515 void printSCFG(CFGWalker &Walker);
516
517 } // namespace threadSafety
518 } // namespace clang
519
520 #endif // LLVM_CLANG_THREAD_SAFETY_COMMON_H
clang::CXXOperatorCallExpr
A call to an overloaded operator written using operator syntax.
Definition: ExprCXX.h:78
clang::threadSafety::SExprBuilder::SExprBuilder
SExprBuilder(til::MemRegionRef A)
Definition: ThreadSafetyCommon.h:363
clang::threadSafety::SExprBuilder::getCFG
til::SCFG * getCFG()
Definition: ThreadSafetyCommon.h:389
clang::threadSafety::CFGWalker::getSortedGraph
const PostOrderCFGView * getSortedGraph() const
Definition: ThreadSafetyCommon.h:259
clang::threadSafety::CapabilityExpr::equals
bool equals(const CapabilityExpr &other) const
Definition: ThreadSafetyCommon.h:288
clang::threadSafety::CapabilityExpr::isUniversal
bool isUniversal() const
Definition: ThreadSafetyCommon.h:325
clang::CFGBlock::const_pred_iterator
AdjacentBlocks::const_iterator const_pred_iterator
Definition: CFG.h:925
clang::CFGStmt::getStmt
const Stmt * getStmt() const
Definition: CFG.h:138
clang::threadSafety::CFGWalker::getGraph
const CFG * getGraph() const
Definition: ThreadSafetyCommon.h:252
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:66
clang::threadSafety::CapabilityExpr::partiallyMatches
bool partiallyMatches(const CapabilityExpr &other) const
Definition: ThreadSafetyCommon.h:300
clang::CFGBlock::getBlockID
unsigned getBlockID() const
Definition: CFG.h:1075
P
StringRef P
Definition: ASTMatchersInternal.cpp:485
clang::CFGElement::castAs
T castAs() const
Convert to the specified CFGElement type, asserting that this CFGElement is of the desired type...
Definition: CFG.h:98
clang::threadSafety::CapabilityExpr::toString
std::string toString() const
Definition: ThreadSafetyCommon.h:315
clang::CFGImplicitDtor::getDestructorDecl
const CXXDestructorDecl * getDestructorDecl(ASTContext &astContext) const
Definition: CFG.cpp:4980
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:820
clang::threadSafety::SExprBuilder::getCFG
const til::SCFG * getCFG() const
Definition: ThreadSafetyCommon.h:388
clang::threadSafety::CapabilityExpr::negative
bool negative() const
Definition: ThreadSafetyCommon.h:282
ThreadSafetyTraverse.h
clang::threadSafety::CapabilityExpr::sexpr
const til::SExpr * sexpr() const
Definition: ThreadSafetyCommon.h:281
clang::AnalysisDeclContext
AnalysisDeclContext contains the context data for the function or method under analysis.
Definition: AnalysisDeclContext.h:69
clang::CFGAutomaticObjDtor
Represents C++ object destructor implicitly generated for automatic object or temporary bound to cons...
Definition: CFG.h:389
clang::CFGBlock::const_succ_iterator
AdjacentBlocks::const_iterator const_succ_iterator
Definition: CFG.h:932
clang::CFGStmt
Definition: CFG.h:132
clang::threadSafety::CFGWalker
Definition: ThreadSafetyCommon.h:145
clang::PostOrderCFGView::CFGBlockSet::alreadySet
bool alreadySet(const CFGBlock *Block)
Check if the bit for a CFGBlock has been already set.
Definition: PostOrderCFGView.h:67
LLVM.h
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
clang::ComparisonCategoryType::First
clang::PostOrderCFGView::CFGBlockSet
Implements a set of CFGBlocks using a BitVector.
Definition: PostOrderCFGView.h:38
clang::AnalysisDeclContext::getAnalysis
T * getAnalysis()
Return the specified analysis object, lazily running the analysis if necessary.
Definition: AnalysisDeclContext.h:197
clang::BinaryOperator
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:3434
clang::threadSafety::til::PrettyPrinter< StdPrinter, std::ostream >::print
static void print(const SExpr *E, std::ostream &SS)
Definition: ThreadSafetyTraverse.h:420
clang::threadSafety::til::BasicBlock
A basic block is part of an SCFG.
Definition: ThreadSafetyTIL.h:1499
clang::CFGAutomaticObjDtor::getVarDecl
const VarDecl * getVarDecl() const
Definition: CFG.h:394
clang::CastExpr
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:3150
ThreadSafetyTIL.h
clang::threadSafety::CFGWalker::getGraph
CFG * getGraph()
Definition: ThreadSafetyCommon.h:253
ThreadSafetyUtil.h
clang::CXXThisExpr
Represents the this expression in C++.
Definition: ExprCXX.h:1097
clang::threadSafety::til::MemRegionRef
Definition: ThreadSafetyUtil.h:38
clang::threadSafety::til::SCFG
An SCFG is a control-flow graph.
Definition: ThreadSafetyTIL.h:1686
clang::threadSafety::CFGWalker::init
bool init(AnalysisDeclContext &AC)
Definition: ThreadSafetyCommon.h:151
clang::CFGBlock
Represents a single basic block in a source-level CFG.
Definition: CFG.h:576
clang::threadSafety::sx::equals
bool equals(const til::SExpr *E1, const til::SExpr *E2)
Definition: ThreadSafetyCommon.h:63
clang::ValueDecl
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:619
clang::Expr
This represents one expression.
Definition: Expr.h:108
clang::threadSafety::CFGWalker::walk
void walk(Visitor &V)
Definition: ThreadSafetyCommon.h:170
clang::CFG
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt...
Definition: CFG.h:1226
V
#define V(N, I)
Definition: ASTContext.h:2941
clang::CXXDestructorDecl
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2649
clang::CFGElement::AutomaticObjectDtor
Definition: CFG.h:72
clang::CFGElement::Statement
Definition: CFG.h:66
clang::threadSafety::printSCFG
void printSCFG(CFGWalker &Walker)
clang::AnalysisDeclContext::getCFG
CFG * getCFG()
Definition: AnalysisDeclContext.cpp:213
clang::threadSafety::SExprBuilder::CallingContext::Prev
CallingContext * Prev
Definition: ThreadSafetyCommon.h:342
clang::UnaryOperator
UnaryOperator - This represents the unary-expression&#39;s (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Definition: Expr.h:2046
clang::threadSafety::CapabilityExpr::matches
bool matches(const CapabilityExpr &other) const
Definition: ThreadSafetyCommon.h:292
clang::ComparisonCategoryType::Last
clang::threadSafety::til::EqualsComparator::compareExprs
static bool compareExprs(const SExpr *E1, const SExpr *E2)
Definition: ThreadSafetyTraverse.h:355
AnalysisDeclContext.h
clang::threadSafety::CapabilityExpr
Definition: ThreadSafetyCommon.h:270
clang::threadSafety::til::Variable
A named variable, e.g.
Definition: ThreadSafetyTIL.h:355
clang::threadSafety::CapabilityExpr::matchesUniv
bool matchesUniv(const CapabilityExpr &CapE) const
Definition: ThreadSafetyCommon.h:296
clang::threadSafety::til::TIL_BinaryOpcode
TIL_BinaryOpcode
Opcode for binary arithmetic operations.
Definition: ThreadSafetyTIL.h:92
clang::PostOrderCFGView::CFGBlockSet::insert
std::pair< llvm::NoneType, bool > insert(const CFGBlock *Block)
Set the bit associated with a particular CFGBlock.
Definition: PostOrderCFGView.h:51
clang::threadSafety::CopyOnWriteVector< NameVarPair >
clang::threadSafety::sx::partiallyMatches
bool partiallyMatches(const til::SExpr *E1, const til::SExpr *E2)
Definition: ThreadSafetyCommon.h:79
clang::CXXMemberCallExpr
Represents a call to a member function that may be written either with member call syntax (e...
Definition: ExprCXX.h:171
clang::DeclStmt
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
Definition: Stmt.h:1225
clang::threadSafety::til::Variable::setKind
void setKind(VariableKind K)
Definition: ThreadSafetyTIL.h:402
clang::AnalysisDeclContext::getDecl
const Decl * getDecl() const
Definition: AnalysisDeclContext.h:104
llvm::SmallVector
Definition: LLVM.h:35
clang::threadSafety::SExprBuilder::CallingContext
Encapsulates the lexical context of a function call.
Definition: ThreadSafetyCommon.h:340
clang::PostOrderCFGView
Definition: PostOrderCFGView.h:28
clang::threadSafety::CapabilityExpr::shouldIgnore
bool shouldIgnore() const
Definition: ThreadSafetyCommon.h:321
clang::threadSafety::CapabilityExpr::CapabilityExpr
CapabilityExpr(const til::SExpr *E, bool Neg)
Definition: ThreadSafetyCommon.h:279
Decl.h
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:21
clang::threadSafety::CapabilityExpr::operator!
CapabilityExpr operator!() const
Definition: ThreadSafetyCommon.h:284
clang::threadSafety::SExprBuilder::lookupBlock
til::BasicBlock * lookupBlock(const CFGBlock *B)
Definition: ThreadSafetyCommon.h:384
clang::threadSafety::sx::toString
std::string toString(const til::SExpr *E)
Definition: ThreadSafetyCommon.h:89
clang::threadSafety::CFGVisitor
Definition: ThreadSafetyCommon.h:100
clang::ArraySubscriptExpr
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2462
clang::AbstractConditionalOperator
AbstractConditionalOperator - An abstract base class for ConditionalOperator and BinaryConditionalOpe...
Definition: Expr.h:3690
clang::threadSafety::SExprBuilder
Definition: ThreadSafetyCommon.h:329
PostOrderCFGView.h
clang::threadSafety::CFGWalker::getDecl
const NamedDecl * getDecl() const
Definition: ThreadSafetyCommon.h:255
clang::ObjCIvarRefExpr
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:546
clang::MemberExpr
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:2836
CFG.h
clang::threadSafety::SExprBuilder::CallingContext::CallingContext
CallingContext(CallingContext *P, const NamedDecl *D=nullptr)
Definition: ThreadSafetyCommon.h:359
clang::threadSafety::CapabilityExpr::isInvalid
bool isInvalid() const
Definition: ThreadSafetyCommon.h:323
clang::CallExpr
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2546
clang::DeclRefExpr
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1171
clang::threadSafety::CapabilityExpr::valueDecl
const ValueDecl * valueDecl() const
Definition: ThreadSafetyCommon.h:305
clang::threadSafety::SExprBuilder::CallingContext::AttrDecl
const NamedDecl * AttrDecl
Definition: ThreadSafetyCommon.h:345
AttributeLangSupport::C
Definition: SemaDeclAttr.cpp:45
clang::threadSafety::til::SExpr
Base class for AST nodes in the typed intermediate language.
Definition: ThreadSafetyTIL.h:277
clang::threadSafety::sx::matches
bool matches(const til::SExpr *E1, const til::SExpr *E2)
Definition: ThreadSafetyCommon.h:67
clang::threadSafety::til::MatchComparator::compareExprs
static bool compareExprs(const SExpr *E1, const SExpr *E2)
Definition: ThreadSafetyTraverse.h:393
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:223
clang::threadSafety::til::Variable::VK_SFun
SFunction (self) parameter.
Definition: ThreadSafetyTIL.h:365
SMap
llvm::DenseMap< const Stmt *, CFGBlock * > SMap
Definition: CFGStmtMap.cpp:21