clang  6.0.0svn
AnalysisDeclContext.cpp
Go to the documentation of this file.
1 //== AnalysisDeclContext.cpp - Analysis context for Path Sens analysis -*- 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 AnalysisDeclContext, a class that manages the analysis context
11 // data for path sensitive analysis.
12 //
13 //===----------------------------------------------------------------------===//
14 
16 #include "BodyFarm.h"
17 #include "clang/AST/ASTContext.h"
18 #include "clang/AST/Decl.h"
19 #include "clang/AST/DeclObjC.h"
20 #include "clang/AST/DeclTemplate.h"
21 #include "clang/AST/ParentMap.h"
22 #include "clang/AST/StmtVisitor.h"
26 #include "clang/Analysis/CFG.h"
29 #include "llvm/ADT/SmallPtrSet.h"
30 #include "llvm/Support/ErrorHandling.h"
31 #include "llvm/Support/SaveAndRestore.h"
32 #include "llvm/Support/raw_ostream.h"
33 
34 using namespace clang;
35 
36 typedef llvm::DenseMap<const void *, ManagedAnalysis *> ManagedAnalysisMap;
37 
39  const Decl *d,
40  const CFG::BuildOptions &buildOptions)
41  : Manager(Mgr),
42  D(d),
43  cfgBuildOptions(buildOptions),
44  forcedBlkExprs(nullptr),
45  builtCFG(false),
46  builtCompleteCFG(false),
47  ReferencedBlockVars(nullptr),
48  ManagedAnalyses(nullptr)
49 {
50  cfgBuildOptions.forcedBlkExprs = &forcedBlkExprs;
51 }
52 
54  const Decl *d)
55 : Manager(Mgr),
56  D(d),
57  forcedBlkExprs(nullptr),
58  builtCFG(false),
59  builtCompleteCFG(false),
60  ReferencedBlockVars(nullptr),
61  ManagedAnalyses(nullptr)
62 {
63  cfgBuildOptions.forcedBlkExprs = &forcedBlkExprs;
64 }
65 
67  bool addImplicitDtors,
68  bool addInitializers,
69  bool addTemporaryDtors,
70  bool addLifetime,
71  bool addLoopExit,
72  bool synthesizeBodies,
73  bool addStaticInitBranch,
74  bool addCXXNewAllocator,
75  CodeInjector *injector)
76  : Injector(injector), SynthesizeBodies(synthesizeBodies)
77 {
78  cfgBuildOptions.PruneTriviallyFalseEdges = !useUnoptimizedCFG;
79  cfgBuildOptions.AddImplicitDtors = addImplicitDtors;
80  cfgBuildOptions.AddInitializers = addInitializers;
81  cfgBuildOptions.AddTemporaryDtors = addTemporaryDtors;
82  cfgBuildOptions.AddLifetime = addLifetime;
83  cfgBuildOptions.AddLoopExit = addLoopExit;
84  cfgBuildOptions.AddStaticInitBranches = addStaticInitBranch;
85  cfgBuildOptions.AddCXXNewAllocator = addCXXNewAllocator;
86 }
87 
88 void AnalysisDeclContextManager::clear() { Contexts.clear(); }
89 
90 static BodyFarm &getBodyFarm(ASTContext &C, CodeInjector *injector = nullptr) {
91  static BodyFarm *BF = new BodyFarm(C, injector);
92  return *BF;
93 }
94 
95 Stmt *AnalysisDeclContext::getBody(bool &IsAutosynthesized) const {
96  IsAutosynthesized = false;
97  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
98  Stmt *Body = FD->getBody();
99  if (auto *CoroBody = dyn_cast_or_null<CoroutineBodyStmt>(Body))
100  Body = CoroBody->getBody();
101  if (Manager && Manager->synthesizeBodies()) {
102  Stmt *SynthesizedBody =
103  getBodyFarm(getASTContext(), Manager->Injector.get()).getBody(FD);
104  if (SynthesizedBody) {
105  Body = SynthesizedBody;
106  IsAutosynthesized = true;
107  }
108  }
109  return Body;
110  }
111  else if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) {
112  Stmt *Body = MD->getBody();
113  if (Manager && Manager->synthesizeBodies()) {
114  Stmt *SynthesizedBody =
115  getBodyFarm(getASTContext(), Manager->Injector.get()).getBody(MD);
116  if (SynthesizedBody) {
117  Body = SynthesizedBody;
118  IsAutosynthesized = true;
119  }
120  }
121  return Body;
122  } else if (const BlockDecl *BD = dyn_cast<BlockDecl>(D))
123  return BD->getBody();
124  else if (const FunctionTemplateDecl *FunTmpl
125  = dyn_cast_or_null<FunctionTemplateDecl>(D))
126  return FunTmpl->getTemplatedDecl()->getBody();
127 
128  llvm_unreachable("unknown code decl");
129 }
130 
132  bool Tmp;
133  return getBody(Tmp);
134 }
135 
137  bool Tmp;
138  getBody(Tmp);
139  return Tmp;
140 }
141 
143  bool Tmp;
144  Stmt *Body = getBody(Tmp);
145  return Tmp && Body->getLocStart().isValid();
146 }
147 
148 /// Returns true if \param VD is an Objective-C implicit 'self' parameter.
149 static bool isSelfDecl(const VarDecl *VD) {
150  return isa<ImplicitParamDecl>(VD) && VD->getName() == "self";
151 }
152 
154  if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D))
155  return MD->getSelfDecl();
156  if (const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
157  // See if 'self' was captured by the block.
158  for (const auto &I : BD->captures()) {
159  const VarDecl *VD = I.getVariable();
160  if (isSelfDecl(VD))
161  return dyn_cast<ImplicitParamDecl>(VD);
162  }
163  }
164 
165  auto *CXXMethod = dyn_cast<CXXMethodDecl>(D);
166  if (!CXXMethod)
167  return nullptr;
168 
169  const CXXRecordDecl *parent = CXXMethod->getParent();
170  if (!parent->isLambda())
171  return nullptr;
172 
173  for (const LambdaCapture &LC : parent->captures()) {
174  if (!LC.capturesVariable())
175  continue;
176 
177  VarDecl *VD = LC.getCapturedVar();
178  if (isSelfDecl(VD))
179  return dyn_cast<ImplicitParamDecl>(VD);
180  }
181 
182  return nullptr;
183 }
184 
186  if (!forcedBlkExprs)
187  forcedBlkExprs = new CFG::BuildOptions::ForcedBlkExprs();
188  // Default construct an entry for 'stmt'.
189  if (const Expr *e = dyn_cast<Expr>(stmt))
190  stmt = e->IgnoreParens();
191  (void) (*forcedBlkExprs)[stmt];
192 }
193 
194 const CFGBlock *
196  assert(forcedBlkExprs);
197  if (const Expr *e = dyn_cast<Expr>(stmt))
198  stmt = e->IgnoreParens();
199  CFG::BuildOptions::ForcedBlkExprs::const_iterator itr =
200  forcedBlkExprs->find(stmt);
201  assert(itr != forcedBlkExprs->end());
202  return itr->second;
203 }
204 
205 /// Add each synthetic statement in the CFG to the parent map, using the
206 /// source statement's parent.
207 static void addParentsForSyntheticStmts(const CFG *TheCFG, ParentMap &PM) {
208  if (!TheCFG)
209  return;
210 
212  E = TheCFG->synthetic_stmt_end();
213  I != E; ++I) {
214  PM.setParent(I->first, PM.getParent(I->second));
215  }
216 }
217 
219  if (!cfgBuildOptions.PruneTriviallyFalseEdges)
220  return getUnoptimizedCFG();
221 
222  if (!builtCFG) {
223  cfg = CFG::buildCFG(D, getBody(), &D->getASTContext(), cfgBuildOptions);
224  // Even when the cfg is not successfully built, we don't
225  // want to try building it again.
226  builtCFG = true;
227 
228  if (PM)
229  addParentsForSyntheticStmts(cfg.get(), *PM);
230 
231  // The Observer should only observe one build of the CFG.
232  getCFGBuildOptions().Observer = nullptr;
233  }
234  return cfg.get();
235 }
236 
238  if (!builtCompleteCFG) {
239  SaveAndRestore<bool> NotPrune(cfgBuildOptions.PruneTriviallyFalseEdges,
240  false);
241  completeCFG =
242  CFG::buildCFG(D, getBody(), &D->getASTContext(), cfgBuildOptions);
243  // Even when the cfg is not successfully built, we don't
244  // want to try building it again.
245  builtCompleteCFG = true;
246 
247  if (PM)
248  addParentsForSyntheticStmts(completeCFG.get(), *PM);
249 
250  // The Observer should only observe one build of the CFG.
251  getCFGBuildOptions().Observer = nullptr;
252  }
253  return completeCFG.get();
254 }
255 
257  if (cfgStmtMap)
258  return cfgStmtMap.get();
259 
260  if (CFG *c = getCFG()) {
261  cfgStmtMap.reset(CFGStmtMap::Build(c, &getParentMap()));
262  return cfgStmtMap.get();
263  }
264 
265  return nullptr;
266 }
267 
269  if (CFA)
270  return CFA.get();
271 
272  if (CFG *c = getCFG()) {
273  CFA.reset(new CFGReverseBlockReachabilityAnalysis(*c));
274  return CFA.get();
275  }
276 
277  return nullptr;
278 }
279 
280 void AnalysisDeclContext::dumpCFG(bool ShowColors) {
281  getCFG()->dump(getASTContext().getLangOpts(), ShowColors);
282 }
283 
285  if (!PM) {
286  PM.reset(new ParentMap(getBody()));
287  if (const CXXConstructorDecl *C = dyn_cast<CXXConstructorDecl>(getDecl())) {
288  for (const auto *I : C->inits()) {
289  PM->addStmt(I->getInit());
290  }
291  }
292  if (builtCFG)
293  addParentsForSyntheticStmts(getCFG(), *PM);
294  if (builtCompleteCFG)
295  addParentsForSyntheticStmts(getUnoptimizedCFG(), *PM);
296  }
297  return *PM;
298 }
299 
301  if (!PCA)
302  PCA.reset(new PseudoConstantAnalysis(getBody()));
303  return PCA.get();
304 }
305 
307  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
308  // Calling 'hasBody' replaces 'FD' in place with the FunctionDecl
309  // that has the body.
310  FD->hasBody(FD);
311  D = FD;
312  }
313 
314  std::unique_ptr<AnalysisDeclContext> &AC = Contexts[D];
315  if (!AC)
316  AC = llvm::make_unique<AnalysisDeclContext>(this, D, cfgBuildOptions);
317  return AC.get();
318 }
319 
320 const StackFrameContext *
322  const CFGBlock *Blk, unsigned Idx) {
323  return getLocationContextManager().getStackFrame(this, Parent, S, Blk, Idx);
324 }
325 
328  const clang::BlockDecl *BD,
329  const void *ContextData) {
330  return getLocationContextManager().getBlockInvocationContext(this, parent,
331  BD, ContextData);
332 }
333 
336  const NamespaceDecl *ND = dyn_cast<NamespaceDecl>(DC);
337  if (!ND)
338  return false;
339 
340  while (const DeclContext *Parent = ND->getParent()) {
341  if (!isa<NamespaceDecl>(Parent))
342  break;
343  ND = cast<NamespaceDecl>(Parent);
344  }
345 
346  return ND->isStdNamespace();
347 }
348 
349 LocationContextManager & AnalysisDeclContext::getLocationContextManager() {
350  assert(Manager &&
351  "Cannot create LocationContexts without an AnalysisDeclContextManager!");
352  return Manager->getLocationContextManager();
353 }
354 
355 //===----------------------------------------------------------------------===//
356 // FoldingSet profiling.
357 //===----------------------------------------------------------------------===//
358 
359 void LocationContext::ProfileCommon(llvm::FoldingSetNodeID &ID,
360  ContextKind ck,
361  AnalysisDeclContext *ctx,
362  const LocationContext *parent,
363  const void *data) {
364  ID.AddInteger(ck);
365  ID.AddPointer(ctx);
366  ID.AddPointer(parent);
367  ID.AddPointer(data);
368 }
369 
370 void StackFrameContext::Profile(llvm::FoldingSetNodeID &ID) {
371  Profile(ID, getAnalysisDeclContext(), getParent(), CallSite, Block, Index);
372 }
373 
374 void ScopeContext::Profile(llvm::FoldingSetNodeID &ID) {
375  Profile(ID, getAnalysisDeclContext(), getParent(), Enter);
376 }
377 
378 void BlockInvocationContext::Profile(llvm::FoldingSetNodeID &ID) {
379  Profile(ID, getAnalysisDeclContext(), getParent(), BD, ContextData);
380 }
381 
382 //===----------------------------------------------------------------------===//
383 // LocationContext creation.
384 //===----------------------------------------------------------------------===//
385 
386 template <typename LOC, typename DATA>
387 const LOC*
388 LocationContextManager::getLocationContext(AnalysisDeclContext *ctx,
389  const LocationContext *parent,
390  const DATA *d) {
391  llvm::FoldingSetNodeID ID;
392  LOC::Profile(ID, ctx, parent, d);
393  void *InsertPos;
394 
395  LOC *L = cast_or_null<LOC>(Contexts.FindNodeOrInsertPos(ID, InsertPos));
396 
397  if (!L) {
398  L = new LOC(ctx, parent, d);
399  Contexts.InsertNode(L, InsertPos);
400  }
401  return L;
402 }
403 
404 const StackFrameContext*
406  const LocationContext *parent,
407  const Stmt *s,
408  const CFGBlock *blk, unsigned idx) {
409  llvm::FoldingSetNodeID ID;
410  StackFrameContext::Profile(ID, ctx, parent, s, blk, idx);
411  void *InsertPos;
412  StackFrameContext *L =
413  cast_or_null<StackFrameContext>(Contexts.FindNodeOrInsertPos(ID, InsertPos));
414  if (!L) {
415  L = new StackFrameContext(ctx, parent, s, blk, idx);
416  Contexts.InsertNode(L, InsertPos);
417  }
418  return L;
419 }
420 
421 const ScopeContext *
423  const LocationContext *parent,
424  const Stmt *s) {
425  return getLocationContext<ScopeContext, Stmt>(ctx, parent, s);
426 }
427 
430  const LocationContext *parent,
431  const BlockDecl *BD,
432  const void *ContextData) {
433  llvm::FoldingSetNodeID ID;
434  BlockInvocationContext::Profile(ID, ctx, parent, BD, ContextData);
435  void *InsertPos;
437  cast_or_null<BlockInvocationContext>(Contexts.FindNodeOrInsertPos(ID,
438  InsertPos));
439  if (!L) {
440  L = new BlockInvocationContext(ctx, parent, BD, ContextData);
441  Contexts.InsertNode(L, InsertPos);
442  }
443  return L;
444 }
445 
446 //===----------------------------------------------------------------------===//
447 // LocationContext methods.
448 //===----------------------------------------------------------------------===//
449 
451  const LocationContext *LC = this;
452  while (LC) {
453  if (const StackFrameContext *SFC = dyn_cast<StackFrameContext>(LC))
454  return SFC;
455  LC = LC->getParent();
456  }
457  return nullptr;
458 }
459 
461  return getCurrentStackFrame()->inTopFrame();
462 }
463 
465  do {
466  const LocationContext *Parent = LC->getParent();
467  if (Parent == this)
468  return true;
469  else
470  LC = Parent;
471  } while (LC);
472 
473  return false;
474 }
475 
476 void LocationContext::dumpStack(raw_ostream &OS, StringRef Indent) const {
477  ASTContext &Ctx = getAnalysisDeclContext()->getASTContext();
478  PrintingPolicy PP(Ctx.getLangOpts());
479  PP.TerseOutput = 1;
480 
481  unsigned Frame = 0;
482  for (const LocationContext *LCtx = this; LCtx; LCtx = LCtx->getParent()) {
483  switch (LCtx->getKind()) {
484  case StackFrame:
485  OS << Indent << '#' << Frame++ << ' ';
486  cast<StackFrameContext>(LCtx)->getDecl()->print(OS, PP);
487  OS << '\n';
488  break;
489  case Scope:
490  OS << Indent << " (scope)\n";
491  break;
492  case Block:
493  OS << Indent << " (block context: "
494  << cast<BlockInvocationContext>(LCtx)->getContextData()
495  << ")\n";
496  break;
497  }
498  }
499 }
500 
501 LLVM_DUMP_METHOD void LocationContext::dumpStack() const {
502  dumpStack(llvm::errs());
503 }
504 
505 //===----------------------------------------------------------------------===//
506 // Lazily generated map to query the external variables referenced by a Block.
507 //===----------------------------------------------------------------------===//
508 
509 namespace {
510 class FindBlockDeclRefExprsVals : public StmtVisitor<FindBlockDeclRefExprsVals>{
512  BumpVectorContext &BC;
513  llvm::SmallPtrSet<const VarDecl*, 4> Visited;
514  llvm::SmallPtrSet<const DeclContext*, 4> IgnoredContexts;
515 public:
516  FindBlockDeclRefExprsVals(BumpVector<const VarDecl*> &bevals,
517  BumpVectorContext &bc)
518  : BEVals(bevals), BC(bc) {}
519 
520  void VisitStmt(Stmt *S) {
521  for (Stmt *Child : S->children())
522  if (Child)
523  Visit(Child);
524  }
525 
526  void VisitDeclRefExpr(DeclRefExpr *DR) {
527  // Non-local variables are also directly modified.
528  if (const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl())) {
529  if (!VD->hasLocalStorage()) {
530  if (Visited.insert(VD).second)
531  BEVals.push_back(VD, BC);
532  }
533  }
534  }
535 
536  void VisitBlockExpr(BlockExpr *BR) {
537  // Blocks containing blocks can transitively capture more variables.
538  IgnoredContexts.insert(BR->getBlockDecl());
539  Visit(BR->getBlockDecl()->getBody());
540  }
541 
542  void VisitPseudoObjectExpr(PseudoObjectExpr *PE) {
544  et = PE->semantics_end(); it != et; ++it) {
545  Expr *Semantic = *it;
546  if (OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(Semantic))
547  Semantic = OVE->getSourceExpr();
548  Visit(Semantic);
549  }
550  }
551 };
552 } // end anonymous namespace
553 
555 
557  void *&Vec,
558  llvm::BumpPtrAllocator &A) {
559  if (Vec)
560  return (DeclVec*) Vec;
561 
562  BumpVectorContext BC(A);
563  DeclVec *BV = (DeclVec*) A.Allocate<DeclVec>();
564  new (BV) DeclVec(BC, 10);
565 
566  // Go through the capture list.
567  for (const auto &CI : BD->captures()) {
568  BV->push_back(CI.getVariable(), BC);
569  }
570 
571  // Find the referenced global/static variables.
572  FindBlockDeclRefExprsVals F(*BV, BC);
573  F.Visit(BD->getBody());
574 
575  Vec = BV;
576  return BV;
577 }
578 
579 llvm::iterator_range<AnalysisDeclContext::referenced_decls_iterator>
581  if (!ReferencedBlockVars)
582  ReferencedBlockVars = new llvm::DenseMap<const BlockDecl*,void*>();
583 
584  const DeclVec *V =
585  LazyInitializeReferencedDecls(BD, (*ReferencedBlockVars)[BD], A);
586  return llvm::make_range(V->begin(), V->end());
587 }
588 
589 ManagedAnalysis *&AnalysisDeclContext::getAnalysisImpl(const void *tag) {
590  if (!ManagedAnalyses)
591  ManagedAnalyses = new ManagedAnalysisMap();
592  ManagedAnalysisMap *M = (ManagedAnalysisMap*) ManagedAnalyses;
593  return (*M)[tag];
594 }
595 
596 //===----------------------------------------------------------------------===//
597 // Cleanup.
598 //===----------------------------------------------------------------------===//
599 
601 
603  delete forcedBlkExprs;
604  delete ReferencedBlockVars;
605  // Release the managed analyses.
606  if (ManagedAnalyses) {
607  ManagedAnalysisMap *M = (ManagedAnalysisMap*) ManagedAnalyses;
608  llvm::DeleteContainerSeconds(*M);
609  delete M;
610  }
611 }
612 
614 
616 
618  clear();
619 }
620 
622  for (llvm::FoldingSet<LocationContext>::iterator I = Contexts.begin(),
623  E = Contexts.end(); I != E; ) {
624  LocationContext *LC = &*I;
625  ++I;
626  delete LC;
627  }
628 
629  Contexts.clear();
630 }
631 
Defines the clang::ASTContext interface.
const BlockDecl * getBlockDecl() const
Definition: Expr.h:4853
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Definition: Decl.h:1629
AnalysisDeclContextManager(bool useUnoptimizedCFG=false, bool addImplicitDtors=false, bool addInitializers=false, bool addTemporaryDtors=false, bool addLifetime=false, bool addLoopExit=false, bool synthesizeBodies=false, bool addStaticInitBranches=false, bool addCXXNewAllocator=true, CodeInjector *injector=nullptr)
The base class of a hierarchy of objects representing analyses tied to AnalysisDeclContext.
BumpVector< const VarDecl * > DeclVec
void Profile(llvm::FoldingSetNodeID &ID) override
Stmt * getBody() const
Get the body of the Declaration.
Expr *const * semantics_iterator
Definition: Expr.h:5023
Stmt - This represents one statement.
Definition: Stmt.h:60
const internal::VariadicAllOfMatcher< Stmt > stmt
Matches statements.
Definition: ASTMatchers.h:1068
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:81
Defines the C++ template declaration subclasses.
Stmt * getParent(Stmt *) const
Definition: ParentMap.cpp:122
NamespaceDecl - Represent a C++ namespace.
Definition: Decl.h:472
capture_const_range captures() const
Definition: DeclCXX.h:1161
Describes the capture of a variable or of this, or of a C++1y init-capture.
Definition: LambdaCapture.h:26
bool AddStaticInitBranches
Definition: CFG.h:827
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2344
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Definition: Decl.h:769
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:113
Describes how types, statements, expressions, and declarations should be printed. ...
Definition: PrettyPrinter.h:38
unsigned TerseOutput
Provide a &#39;terse&#39; output.
bool isParentOf(const LocationContext *LC) const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:128
AnalysisDeclContext contains the context data for the function or method under analysis.
void addStmt(Stmt *S)
Adds and/or updates the parent/child-relations of the complete stmt tree of S.
Definition: ParentMap.cpp:109
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Definition: Decl.h:3662
void setParent(const Stmt *S, const Stmt *Parent)
Manually sets the parent of S to Parent.
Definition: ParentMap.cpp:115
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
Definition: DeclBase.cpp:1642
static bool isInStdNamespace(const Decl *D)
Returns true if the root namespace of the given declaration is the &#39;std&#39; C++ namespace.
llvm::DenseMap< const void *, ManagedAnalysis * > ManagedAnalysisMap
CFGReverseBlockReachabilityAnalysis * getCFGReachablityAnalysis()
const StackFrameContext * getCurrentStackFrame() const
CFGCallback * Observer
Definition: CFG.h:819
child_range children()
Definition: Stmt.cpp:208
virtual bool inTopFrame() const
Return true if the current LocationContext has no caller context.
semantics_iterator semantics_end()
Definition: Expr.h:5031
const LocationContext * getParent() const
bool isLambda() const
Determine whether this class describes a lambda function object.
Definition: DeclCXX.h:1113
Scope - A scope is a transient data structure that is used while parsing the program.
Definition: Scope.h:39
void clear()
Discard all previously created LocationContext objects.
NodeId Parent
Definition: ASTDiff.cpp:192
ForcedBlkExprs ** forcedBlkExprs
Definition: CFG.h:818
CFGBlock - Represents a single basic block in a source-level CFG.
Definition: CFG.h:401
ID
Defines the address space values used by the address space qualifier of QualType. ...
Definition: AddressSpaces.h:26
AnalysisDeclContext * getContext(const Decl *D)
bool isBodyAutosynthesizedFromModelFile() const
Checks if the body of the Decl is generated by the BodyFarm from a model file.
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
Definition: Decl.h:3582
Expr - This represents one expression.
Definition: Expr.h:106
CFG - Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt...
Definition: CFG.h:808
void Profile(llvm::FoldingSetNodeID &ID) override
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:4839
DeclContext * getDeclContext()
Definition: DeclBase.h:416
const CFGBlock * getBlockForRegisteredExpression(const Stmt *stmt)
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1296
bool isBodyAutosynthesized() const
Checks if the body of the Decl is generated by the BodyFarm.
const ScopeContext * getScope(AnalysisDeclContext *ctx, const LocationContext *parent, const Stmt *s)
const StackFrameContext * getStackFrame(LocationContext const *Parent, const Stmt *S, const CFGBlock *Blk, unsigned Idx)
ValueDecl * getDecl()
Definition: Expr.h:1041
CFG::BuildOptions & getCFGBuildOptions()
const StackFrameContext * getStackFrame(AnalysisDeclContext *ctx, const LocationContext *parent, const Stmt *s, const CFGBlock *blk, unsigned idx)
CFG * getUnoptimizedCFG()
Return a version of the CFG without any edges pruned.
llvm::DenseMap< const DeclStmt *, const DeclStmt * >::const_iterator synthetic_stmt_iterator
Definition: CFG.h:933
const ImplicitParamDecl * getSelfDecl() const
Return the ImplicitParamDecl* associated with &#39;self&#39; if this AnalysisDeclContext wraps an ObjCMethodD...
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Definition: Expr.h:868
#define false
Definition: stdbool.h:33
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:4957
static std::unique_ptr< CFG > buildCFG(const Decl *D, Stmt *AST, ASTContext *C, const BuildOptions &BO)
buildCFG - Builds a CFG from an AST.
Definition: CFG.cpp:4166
bool PruneTriviallyFalseEdges
Definition: CFG.h:820
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1918
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
Definition: StmtVisitor.h:180
bool isStdNamespace() const
Definition: DeclBase.cpp:993
void push_back(const_reference Elt, BumpVectorContext &C)
Definition: BumpVector.h:154
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
static CFGStmtMap * Build(CFG *C, ParentMap *PM)
Returns a new CFGMap for the given CFG.
Definition: CFGStmtMap.cpp:78
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1217
ArrayRef< Capture > captures() const
Definition: Decl.h:3707
CodeInjector is an interface which is responsible for injecting AST of function definitions that may ...
Definition: CodeInjector.h:36
llvm::iterator_range< referenced_decls_iterator > getReferencedBlockVars(const BlockDecl *BD)
static DeclVec * LazyInitializeReferencedDecls(const BlockDecl *BD, void *&Vec, llvm::BumpPtrAllocator &A)
void Profile(llvm::FoldingSetNodeID &ID) override
semantics_iterator semantics_begin()
Definition: Expr.h:5025
llvm::DenseMap< const Stmt *, const CFGBlock * > ForcedBlkExprs
Definition: CFG.h:817
static bool isSelfDecl(const VarDecl *VD)
Returns true if.
static void addParentsForSyntheticStmts(const CFG *TheCFG, ParentMap &PM)
Add each synthetic statement in the CFG to the parent map, using the source statement&#39;s parent...
PseudoConstantAnalysis * getPseudoConstantAnalysis()
const BlockInvocationContext * getBlockInvocationContext(AnalysisDeclContext *ctx, const LocationContext *parent, const BlockDecl *BD, const void *ContextData)
Represents a C++ struct/union/class.
Definition: DeclCXX.h:266
synthetic_stmt_iterator synthetic_stmt_end() const
Definition: CFG.h:946
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:237
void registerForcedBlockExpression(const Stmt *stmt)
synthetic_stmt_iterator synthetic_stmt_begin() const
Iterates over synthetic DeclStmts in the CFG.
Definition: CFG.h:941
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:956
const BlockInvocationContext * getBlockInvocationContext(const LocationContext *parent, const BlockDecl *BD, const void *ContextData)
void clear()
Discard all previously created AnalysisDeclContexts.
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.cpp:257
const LangOptions & getLangOpts() const
Definition: ASTContext.h:659
Declaration of a template function.
Definition: DeclTemplate.h:939
static BodyFarm & getBodyFarm(ASTContext &C, CodeInjector *injector=nullptr)
AnalysisDeclContext(AnalysisDeclContextManager *Mgr, const Decl *D)
static void ProfileCommon(llvm::FoldingSetNodeID &ID, ContextKind ck, AnalysisDeclContext *ctx, const LocationContext *parent, const void *data)