Thanks to visit codestin.com
Credit goes to clang.llvm.org

clang 22.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/AST/Type.h"
31#include "clang/Analysis/CFG.h"
32#include "clang/Basic/LLVM.h"
33#include "llvm/ADT/DenseMap.h"
34#include "llvm/ADT/PointerIntPair.h"
35#include "llvm/ADT/PointerUnion.h"
36#include "llvm/ADT/SmallVector.h"
37#include "llvm/Support/Casting.h"
38#include <functional>
39#include <sstream>
40#include <string>
41#include <utility>
42#include <vector>
43
44namespace clang {
45
48class BinaryOperator;
49class CallExpr;
50class CastExpr;
54class CXXThisExpr;
55class DeclRefExpr;
56class DeclStmt;
57class Expr;
58class MemberExpr;
59class Stmt;
60class UnaryOperator;
61
62namespace threadSafety {
63
64// Various helper functions on til::SExpr
65namespace sx {
66
67inline bool equals(const til::SExpr *E1, const til::SExpr *E2) {
69}
70
71inline bool matches(const til::SExpr *E1, const til::SExpr *E2) {
72 // We treat a top-level wildcard as the "univsersal" lock.
73 // It matches everything for the purpose of checking locks, but not
74 // for unlocking them.
75 if (isa<til::Wildcard>(E1))
76 return isa<til::Wildcard>(E2);
77 if (isa<til::Wildcard>(E2))
78 return isa<til::Wildcard>(E1);
79
81}
82
83inline bool partiallyMatches(const til::SExpr *E1, const til::SExpr *E2) {
84 const auto *PE1 = dyn_cast_or_null<til::Project>(E1);
85 if (!PE1)
86 return false;
87 const auto *PE2 = dyn_cast_or_null<til::Project>(E2);
88 if (!PE2)
89 return false;
90 return PE1->clangDecl() == PE2->clangDecl();
91}
92
93inline std::string toString(const til::SExpr *E) {
94 std::stringstream ss;
96 return ss.str();
97}
98
99} // namespace sx
100
101// This class defines the interface of a clang CFG Visitor.
102// CFGWalker will invoke the following methods.
103// Note that methods are not virtual; the visitor is templatized.
105 // Enter the CFG for Decl D, and perform any initial setup operations.
106 void enterCFG(CFG *Cfg, const NamedDecl *D, const CFGBlock *First) {}
107
108 // Enter a CFGBlock.
109 void enterCFGBlock(const CFGBlock *B) {}
110
111 // Returns true if this visitor implements handlePredecessor
112 bool visitPredecessors() { return true; }
113
114 // Process a predecessor edge.
115 void handlePredecessor(const CFGBlock *Pred) {}
116
117 // Process a successor back edge to a previously visited block.
118 void handlePredecessorBackEdge(const CFGBlock *Pred) {}
119
120 // Called just before processing statements.
121 void enterCFGBlockBody(const CFGBlock *B) {}
122
123 // Process an ordinary statement.
124 void handleStatement(const Stmt *S) {}
125
126 // Process a destructor call
127 void handleDestructorCall(const VarDecl *VD, const CXXDestructorDecl *DD) {}
128
129 // Called after all statements have been handled.
130 void exitCFGBlockBody(const CFGBlock *B) {}
131
132 // Return true
133 bool visitSuccessors() { return true; }
134
135 // Process a successor edge.
136 void handleSuccessor(const CFGBlock *Succ) {}
137
138 // Process a successor back edge to a previously visited block.
139 void handleSuccessorBackEdge(const CFGBlock *Succ) {}
140
141 // Leave a CFGBlock.
142 void exitCFGBlock(const CFGBlock *B) {}
143
144 // Leave the CFG, and perform any final cleanup operations.
145 void exitCFG(const CFGBlock *Last) {}
146};
147
148// Walks the clang CFG, and invokes methods on a given CFGVisitor.
150public:
151 CFGWalker() = default;
152
153 // Initialize the CFGWalker. This setup only needs to be done once, even
154 // if there are multiple passes over the CFG.
156 ACtx = &AC;
157 CFGraph = AC.getCFG();
158 if (!CFGraph)
159 return false;
160
161 // Ignore anonymous functions.
162 if (!isa_and_nonnull<NamedDecl>(AC.getDecl()))
163 return false;
164
165 SortedGraph = AC.getAnalysis<PostOrderCFGView>();
166 if (!SortedGraph)
167 return false;
168
169 return true;
170 }
171
172 // Traverse the CFG, calling methods on V as appropriate.
173 template <class Visitor>
174 void walk(Visitor &V) {
175 PostOrderCFGView::CFGBlockSet VisitedBlocks(CFGraph);
176
177 V.enterCFG(CFGraph, getDecl(), &CFGraph->getEntry());
178
179 for (const auto *CurrBlock : *SortedGraph) {
180 VisitedBlocks.insert(CurrBlock);
181
182 V.enterCFGBlock(CurrBlock);
183
184 // Process predecessors, handling back edges last
185 if (V.visitPredecessors()) {
187 // Process successors
188 for (CFGBlock::const_pred_iterator SI = CurrBlock->pred_begin(),
189 SE = CurrBlock->pred_end();
190 SI != SE; ++SI) {
191 if (*SI == nullptr)
192 continue;
193
194 if (!VisitedBlocks.alreadySet(*SI)) {
195 BackEdges.push_back(*SI);
196 continue;
197 }
198 V.handlePredecessor(*SI);
199 }
200
201 for (auto *Blk : BackEdges)
202 V.handlePredecessorBackEdge(Blk);
203 }
204
205 V.enterCFGBlockBody(CurrBlock);
206
207 // Process statements
208 for (const auto &BI : *CurrBlock) {
209 switch (BI.getKind()) {
211 V.handleStatement(BI.castAs<CFGStmt>().getStmt());
212 break;
213
216 auto *DD = const_cast<CXXDestructorDecl *>(
217 AD.getDestructorDecl(ACtx->getASTContext()));
218 auto *VD = const_cast<VarDecl *>(AD.getVarDecl());
219 V.handleDestructorCall(VD, DD);
220 break;
221 }
222 default:
223 break;
224 }
225 }
226
227 V.exitCFGBlockBody(CurrBlock);
228
229 // Process successors, handling back edges first.
230 if (V.visitSuccessors()) {
231 SmallVector<CFGBlock*, 8> ForwardEdges;
232
233 // Process successors
234 for (CFGBlock::const_succ_iterator SI = CurrBlock->succ_begin(),
235 SE = CurrBlock->succ_end();
236 SI != SE; ++SI) {
237 if (*SI == nullptr)
238 continue;
239
240 if (!VisitedBlocks.alreadySet(*SI)) {
241 ForwardEdges.push_back(*SI);
242 continue;
243 }
244 V.handleSuccessorBackEdge(*SI);
245 }
246
247 for (auto *Blk : ForwardEdges)
248 V.handleSuccessor(Blk);
249 }
250
251 V.exitCFGBlock(CurrBlock);
252 }
253 V.exitCFG(&CFGraph->getExit());
254 }
255
256 const CFG *getGraph() const { return CFGraph; }
257 CFG *getGraph() { return CFGraph; }
258
259 const NamedDecl *getDecl() const {
260 return dyn_cast<NamedDecl>(ACtx->getDecl());
261 }
262
263 const PostOrderCFGView *getSortedGraph() const { return SortedGraph; }
264
265private:
266 CFG *CFGraph = nullptr;
267 AnalysisDeclContext *ACtx = nullptr;
268 PostOrderCFGView *SortedGraph = nullptr;
269};
270
271// TODO: move this back into ThreadSafety.cpp
272// This is specific to thread safety. It is here because
273// translateAttrExpr needs it, but that should be moved too.
275private:
276 static constexpr unsigned FlagNegative = 1u << 0;
277 static constexpr unsigned FlagReentrant = 1u << 1;
278
279 /// The capability expression and flags.
280 llvm::PointerIntPair<const til::SExpr *, 2, unsigned> CapExpr;
281
282 /// The kind of capability as specified by @ref CapabilityAttr::getName.
283 StringRef CapKind;
284
285public:
286 CapabilityExpr() : CapExpr(nullptr, 0) {}
287 CapabilityExpr(const til::SExpr *E, StringRef Kind, bool Neg, bool Reentrant)
288 : CapExpr(E, (Neg ? FlagNegative : 0) | (Reentrant ? FlagReentrant : 0)),
289 CapKind(Kind) {}
290 // Infers `Kind` and `Reentrant` from `QT`.
291 CapabilityExpr(const til::SExpr *E, QualType QT, bool Neg);
292
293 // Don't allow implicitly-constructed StringRefs since we'll capture them.
294 template <typename T>
295 CapabilityExpr(const til::SExpr *, T, bool, bool) = delete;
296
297 const til::SExpr *sexpr() const { return CapExpr.getPointer(); }
298 StringRef getKind() const { return CapKind; }
299 bool negative() const { return CapExpr.getInt() & FlagNegative; }
300 bool reentrant() const { return CapExpr.getInt() & FlagReentrant; }
301
303 return CapabilityExpr(CapExpr.getPointer(), CapKind, !negative(),
304 reentrant());
305 }
306
307 bool equals(const CapabilityExpr &other) const {
308 return (negative() == other.negative()) &&
309 sx::equals(sexpr(), other.sexpr());
310 }
311
312 bool matches(const CapabilityExpr &other) const {
313 return (negative() == other.negative()) &&
314 sx::matches(sexpr(), other.sexpr());
315 }
316
317 bool matchesUniv(const CapabilityExpr &CapE) const {
318 return isUniversal() || matches(CapE);
319 }
320
321 bool partiallyMatches(const CapabilityExpr &other) const {
322 return (negative() == other.negative()) &&
323 sx::partiallyMatches(sexpr(), other.sexpr());
324 }
325
326 const ValueDecl* valueDecl() const {
327 if (negative() || sexpr() == nullptr)
328 return nullptr;
329 if (const auto *P = dyn_cast<til::Project>(sexpr()))
330 return P->clangDecl();
331 if (const auto *P = dyn_cast<til::LiteralPtr>(sexpr()))
332 return P->clangDecl();
333 return nullptr;
334 }
335
336 std::string toString() const {
337 if (negative())
338 return "!" + sx::toString(sexpr());
339 return sx::toString(sexpr());
340 }
341
342 bool shouldIgnore() const { return sexpr() == nullptr; }
343
344 bool isInvalid() const { return isa_and_nonnull<til::Undefined>(sexpr()); }
345
346 bool isUniversal() const { return isa_and_nonnull<til::Wildcard>(sexpr()); }
347};
348
349// Translate clang::Expr to til::SExpr.
351public:
352 /// Encapsulates the lexical context of a function call. The lexical
353 /// context includes the arguments to the call, including the implicit object
354 /// argument. When an attribute containing a mutex expression is attached to
355 /// a method, the expression may refer to formal parameters of the method.
356 /// Actual arguments must be substituted for formal parameters to derive
357 /// the appropriate mutex expression in the lexical context where the function
358 /// is called. PrevCtx holds the context in which the arguments themselves
359 /// should be evaluated; multiple calling contexts can be chained together
360 /// by the lock_returned attribute.
362 // The previous context; or 0 if none.
364
365 // The decl to which the attr is attached.
367
368 // Implicit object argument -- e.g. 'this'
369 llvm::PointerUnion<const Expr *, til::SExpr *> SelfArg = nullptr;
370
371 // Number of funArgs
372 unsigned NumArgs = 0;
373
374 // Function arguments
375 llvm::PointerUnion<const Expr *const *, til::SExpr *> FunArgs = nullptr;
376
377 // is Self referred to with -> or .?
378 bool SelfArrow = false;
379
381 : Prev(P), AttrDecl(D) {}
382 };
383
385 // FIXME: we don't always have a self-variable.
386 SelfVar = new (Arena) til::Variable(nullptr);
387 SelfVar->setKind(til::Variable::VK_SFun);
388 }
389
390 // Create placeholder for this: we don't know the VarDecl on construction yet.
392 return new (Arena) til::LiteralPtr(nullptr);
393 }
394
395 // Translate a clang expression in an attribute to a til::SExpr.
396 // Constructs the context from D, DeclExp, and SelfDecl.
397 CapabilityExpr translateAttrExpr(const Expr *AttrExp, const NamedDecl *D,
398 const Expr *DeclExp,
399 til::SExpr *Self = nullptr);
400
402
403 // Translate a VarDecl to its canonical TIL expression.
405
406 // Translate a clang statement or expression to a TIL expression.
407 // Also performs substitution of variables; Ctx provides the context.
408 // Dispatches on the type of S.
409 til::SExpr *translate(const Stmt *S, CallingContext *Ctx);
410 til::SCFG *buildCFG(CFGWalker &Walker);
411
412 til::SExpr *lookupStmt(const Stmt *S);
413
415 return BlockMap[B->getBlockID()];
416 }
417
418 const til::SCFG *getCFG() const { return Scfg; }
419 til::SCFG *getCFG() { return Scfg; }
420
422 LookupLocalVarExpr = std::move(F);
423 }
424
425private:
426 // We implement the CFGVisitor API
427 friend class CFGWalker;
428
429 til::SExpr *translateDeclRefExpr(const DeclRefExpr *DRE,
430 CallingContext *Ctx) ;
431 til::SExpr *translateCXXThisExpr(const CXXThisExpr *TE, CallingContext *Ctx);
432 til::SExpr *translateMemberExpr(const MemberExpr *ME, CallingContext *Ctx);
433 til::SExpr *translateObjCIVarRefExpr(const ObjCIvarRefExpr *IVRE,
434 CallingContext *Ctx);
435 til::SExpr *translateCallExpr(const CallExpr *CE, CallingContext *Ctx,
436 const Expr *SelfE = nullptr);
437 til::SExpr *translateCXXMemberCallExpr(const CXXMemberCallExpr *ME,
438 CallingContext *Ctx);
439 til::SExpr *translateCXXOperatorCallExpr(const CXXOperatorCallExpr *OCE,
440 CallingContext *Ctx);
441 til::SExpr *translateUnaryOperator(const UnaryOperator *UO,
442 CallingContext *Ctx);
443 til::SExpr *translateBinOp(til::TIL_BinaryOpcode Op,
444 const BinaryOperator *BO,
445 CallingContext *Ctx, bool Reverse = false);
446 til::SExpr *translateBinAssign(til::TIL_BinaryOpcode Op,
447 const BinaryOperator *BO,
448 CallingContext *Ctx, bool Assign = false);
449 til::SExpr *translateBinaryOperator(const BinaryOperator *BO,
450 CallingContext *Ctx);
451 til::SExpr *translateCastExpr(const CastExpr *CE, CallingContext *Ctx);
452 til::SExpr *translateArraySubscriptExpr(const ArraySubscriptExpr *E,
453 CallingContext *Ctx);
454 til::SExpr *translateAbstractConditionalOperator(
456
457 til::SExpr *translateDeclStmt(const DeclStmt *S, CallingContext *Ctx);
458 til::SExpr *translateStmtExpr(const StmtExpr *SE, CallingContext *Ctx);
459
460 // Map from statements in the clang CFG to SExprs in the til::SCFG.
461 using StatementMap = llvm::DenseMap<const Stmt *, til::SExpr *>;
462
463 // Map from clang local variables to indices in a LVarDefinitionMap.
464 using LVarIndexMap = llvm::DenseMap<const ValueDecl *, unsigned>;
465
466 // Map from local variable indices to SSA variables (or constants).
467 using NameVarPair = std::pair<const ValueDecl *, til::SExpr *>;
468 using LVarDefinitionMap = CopyOnWriteVector<NameVarPair>;
469
470 struct BlockInfo {
471 LVarDefinitionMap ExitMap;
472 bool HasBackEdges = false;
473
474 // Successors yet to be processed
475 unsigned UnprocessedSuccessors = 0;
476
477 // Predecessors already processed
478 unsigned ProcessedPredecessors = 0;
479
480 BlockInfo() = default;
481 BlockInfo(BlockInfo &&) = default;
482 BlockInfo &operator=(BlockInfo &&) = default;
483 };
484
485 void enterCFG(CFG *Cfg, const NamedDecl *D, const CFGBlock *First);
486 void enterCFGBlock(const CFGBlock *B);
487 bool visitPredecessors() { return true; }
488 void handlePredecessor(const CFGBlock *Pred);
489 void handlePredecessorBackEdge(const CFGBlock *Pred);
490 void enterCFGBlockBody(const CFGBlock *B);
491 void handleStatement(const Stmt *S);
492 void handleDestructorCall(const VarDecl *VD, const CXXDestructorDecl *DD);
493 void exitCFGBlockBody(const CFGBlock *B);
494 bool visitSuccessors() { return true; }
495 void handleSuccessor(const CFGBlock *Succ);
496 void handleSuccessorBackEdge(const CFGBlock *Succ);
497 void exitCFGBlock(const CFGBlock *B);
498 void exitCFG(const CFGBlock *Last);
499
500 void insertStmt(const Stmt *S, til::SExpr *E) {
501 SMap.insert(std::make_pair(S, E));
502 }
503
504 til::SExpr *addStatement(til::SExpr *E, const Stmt *S,
505 const ValueDecl *VD = nullptr);
506 til::SExpr *lookupVarDecl(const ValueDecl *VD);
507 til::SExpr *addVarDecl(const ValueDecl *VD, til::SExpr *E);
508 til::SExpr *updateVarDecl(const ValueDecl *VD, til::SExpr *E);
509
510 void makePhiNodeVar(unsigned i, unsigned NPreds, til::SExpr *E);
511 void mergeEntryMap(LVarDefinitionMap Map);
512 void mergeEntryMapBackEdge();
513 void mergePhiNodesBackEdge(const CFGBlock *Blk);
514
515private:
516 // Set to true when parsing capability expressions, which get translated
517 // inaccurately in order to hack around smart pointers etc.
518 static const bool CapabilityExprMode = true;
519
520 til::MemRegionRef Arena;
521
522 // Variable to use for 'this'. May be null.
523 til::Variable *SelfVar = nullptr;
524
525 til::SCFG *Scfg = nullptr;
526
527 // Map from Stmt to TIL Variables
528 StatementMap SMap;
529
530 // Indices of clang local vars.
531 LVarIndexMap LVarIdxMap;
532
533 // Map from clang to til BBs.
534 std::vector<til::BasicBlock *> BlockMap;
535
536 // Extra information per BB. Indexed by clang BlockID.
537 std::vector<BlockInfo> BBInfo;
538
539 LVarDefinitionMap CurrentLVarMap;
540 std::vector<til::Phi *> CurrentArguments;
541 std::vector<til::SExpr *> CurrentInstructions;
542 std::vector<til::Phi *> IncompleteArgs;
543 til::BasicBlock *CurrentBB = nullptr;
544 BlockInfo *CurrentBlockInfo = nullptr;
545
546 // The closure that captures state required for the lookup; this may be
547 // mutable, so we have to save/restore before/after recursive lookups.
548 using LookupLocalVarExprClosure =
549 std::function<const Expr *(const NamedDecl *)>;
550 // Recursion guard.
551 llvm::DenseSet<const ValueDecl *> VarsBeingTranslated;
552 // Context-dependent lookup of currently valid definitions of local variables.
553 LookupLocalVarExprClosure LookupLocalVarExpr;
554};
555
556#ifndef NDEBUG
557// Dump an SCFG to llvm::errs().
558void printSCFG(CFGWalker &Walker);
559#endif // NDEBUG
560
561} // namespace threadSafety
562} // namespace clang
563
564#endif // LLVM_CLANG_ANALYSIS_ANALYSES_THREADSAFETYCOMMON_H
#define V(N, I)
This file defines AnalysisDeclContext, a class that manages the analysis context data for context sen...
llvm::DenseMap< const Stmt *, CFGBlock * > SMap
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
SExprBuilder::CallingContext CallingContext
C Language Family Type Representation.
AbstractConditionalOperator - An abstract base class for ConditionalOperator and BinaryConditionalOpe...
Definition Expr.h:4287
AnalysisDeclContext contains the context data for the function, method or block under analysis.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition Expr.h:2721
A builtin binary operation expression such as "x + y" or "x <= y".
Definition Expr.h:3972
Represents C++ object destructor implicitly generated for automatic object or temporary bound to cons...
Definition CFG.h:418
const VarDecl * getVarDecl() const
Definition CFG.h:423
Represents a single basic block in a source-level CFG.
Definition CFG.h:605
AdjacentBlocks::const_iterator const_pred_iterator
Definition CFG.h:959
unsigned getBlockID() const
Definition CFG.h:1111
AdjacentBlocks::const_iterator const_succ_iterator
Definition CFG.h:966
@ AutomaticObjectDtor
Definition CFG.h:72
T castAs() const
Convert to the specified CFGElement type, asserting that this CFGElement is of the desired type.
Definition CFG.h:99
const CXXDestructorDecl * getDestructorDecl(ASTContext &astContext) const
Definition CFG.cpp:5398
const Stmt * getStmt() const
Definition CFG.h:139
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt.
Definition CFG.h:1222
Represents a C++ destructor within a class.
Definition DeclCXX.h:2869
Represents a call to a member function that may be written either with member call syntax (e....
Definition ExprCXX.h:179
A call to an overloaded operator written using operator syntax.
Definition ExprCXX.h:84
Represents the this expression in C++.
Definition ExprCXX.h:1155
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:2877
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition Expr.h:3610
A reference to a declared variable, function, enum, etc.
Definition Expr.h:1270
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition Stmt.h:1611
This represents one expression.
Definition Expr.h:112
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition Expr.h:3298
This represents a decl that may have a name.
Definition Decl.h:273
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition ExprObjC.h:548
Implements a set of CFGBlocks using a BitVector.
std::pair< std::nullopt_t, bool > insert(const CFGBlock *Block)
Set the bit associated with a particular CFGBlock.
bool alreadySet(const CFGBlock *Block)
Check if the bit for a CFGBlock has been already set.
A (possibly-)qualified type.
Definition TypeBase.h:937
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition Expr.h:4529
Stmt - This represents one statement.
Definition Stmt.h:85
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition Expr.h:2244
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:711
Represents a variable declaration or definition.
Definition Decl.h:925
const PostOrderCFGView * getSortedGraph() const
const NamedDecl * getDecl() const
bool init(AnalysisDeclContext &AC)
CapabilityExpr(const til::SExpr *E, StringRef Kind, bool Neg, bool Reentrant)
CapabilityExpr(const til::SExpr *, T, bool, bool)=delete
bool matches(const CapabilityExpr &other) const
bool partiallyMatches(const CapabilityExpr &other) const
bool equals(const CapabilityExpr &other) const
bool matchesUniv(const CapabilityExpr &CapE) const
CapabilityExpr translateAttrExpr(const Expr *AttrExp, const NamedDecl *D, const Expr *DeclExp, til::SExpr *Self=nullptr)
Translate a clang expression in an attribute to a til::SExpr.
void setLookupLocalVarExpr(std::function< const Expr *(const NamedDecl *)> F)
til::SExpr * translate(const Stmt *S, CallingContext *Ctx)
til::SExpr * lookupStmt(const Stmt *S)
til::SCFG * buildCFG(CFGWalker &Walker)
til::SExpr * translateVariable(const VarDecl *VD, CallingContext *Ctx)
til::BasicBlock * lookupBlock(const CFGBlock *B)
A basic block is part of an SCFG.
static bool compareExprs(const SExpr *E1, const SExpr *E2)
A Literal pointer to an object allocated in memory.
static bool compareExprs(const SExpr *E1, const SExpr *E2)
An SCFG is a control-flow graph.
Base class for AST nodes in the typed intermediate language.
@ VK_SFun
SFunction (self) parameter.
bool matches(const til::SExpr *E1, const til::SExpr *E2)
bool equals(const til::SExpr *E1, const til::SExpr *E2)
std::string toString(const til::SExpr *E)
bool partiallyMatches(const til::SExpr *E1, const til::SExpr *E2)
TIL_BinaryOpcode
Opcode for binary arithmetic operations.
void printSCFG(CFGWalker &Walker)
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
Definition Address.h:330
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
const FunctionProtoType * T
int const char * function
Definition c++config.h:31
Encapsulates the lexical context of a function call.
llvm::PointerUnion< const Expr *const *, til::SExpr * > FunArgs
CallingContext(CallingContext *P, const NamedDecl *D=nullptr)
llvm::PointerUnion< const Expr *, til::SExpr * > SelfArg