clang  14.0.0git
AnalysisDeclContext.h
Go to the documentation of this file.
1 //===- AnalysisDeclContext.h - Context for path sensitivity -----*- 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 /// \file
10 /// This file defines AnalysisDeclContext, a class that manages the analysis
11 /// context data for context sensitive and path sensitive analysis.
12 /// It also defines the helper classes to model entering, leaving or inlining
13 /// function calls.
14 //
15 //===----------------------------------------------------------------------===//
16 
17 #ifndef LLVM_CLANG_ANALYSIS_ANALYSISDECLCONTEXT_H
18 #define LLVM_CLANG_ANALYSIS_ANALYSISDECLCONTEXT_H
19 
20 #include "clang/AST/DeclBase.h"
22 #include "clang/Analysis/CFG.h"
24 #include "clang/Basic/LLVM.h"
25 #include "llvm/ADT/DenseMap.h"
26 #include "llvm/ADT/FoldingSet.h"
27 #include "llvm/ADT/StringRef.h"
28 #include "llvm/ADT/iterator_range.h"
29 #include "llvm/Support/Allocator.h"
30 #include <functional>
31 #include <memory>
32 
33 namespace clang {
34 
35 class AnalysisDeclContextManager;
36 class ASTContext;
37 class BlockDecl;
38 class BlockInvocationContext;
39 class CFGReverseBlockReachabilityAnalysis;
40 class CFGStmtMap;
41 class ImplicitParamDecl;
42 class LocationContext;
43 class LocationContextManager;
44 class ParentMap;
45 class StackFrameContext;
46 class Stmt;
47 class VarDecl;
48 
49 /// The base class of a hierarchy of objects representing analyses tied
50 /// to AnalysisDeclContext.
52 protected:
53  ManagedAnalysis() = default;
54 
55 public:
56  virtual ~ManagedAnalysis();
57 
58  // Subclasses need to implement:
59  //
60  // static const void *getTag();
61  //
62  // Which returns a fixed pointer address to distinguish classes of
63  // analysis objects. They also need to implement:
64  //
65  // static [Derived*] create(AnalysisDeclContext &Ctx);
66  //
67  // which creates the analysis object given an AnalysisDeclContext.
68 };
69 
70 /// AnalysisDeclContext contains the context data for the function, method
71 /// or block under analysis.
73  // Backpoint to the AnalysisManager object that created this
74  // AnalysisDeclContext. This may be null.
76 
77  const Decl *const D;
78 
79  std::unique_ptr<CFG> cfg, completeCFG;
80  std::unique_ptr<CFGStmtMap> cfgStmtMap;
81 
82  CFG::BuildOptions cfgBuildOptions;
83  CFG::BuildOptions::ForcedBlkExprs *forcedBlkExprs = nullptr;
84 
85  bool builtCFG = false;
86  bool builtCompleteCFG = false;
87  std::unique_ptr<ParentMap> PM;
88  std::unique_ptr<CFGReverseBlockReachabilityAnalysis> CFA;
89 
90  llvm::BumpPtrAllocator A;
91 
92  llvm::DenseMap<const BlockDecl *, void *> *ReferencedBlockVars = nullptr;
93 
94  void *ManagedAnalyses = nullptr;
95 
96 public:
98 
100  const CFG::BuildOptions &BuildOptions);
101 
103 
104  ASTContext &getASTContext() const { return D->getASTContext(); }
105 
106  const Decl *getDecl() const { return D; }
107 
108  AnalysisDeclContextManager *getManager() const { return ADCMgr; }
109 
110  CFG::BuildOptions &getCFGBuildOptions() { return cfgBuildOptions; }
111 
113  return cfgBuildOptions;
114  }
115 
116  /// \returns Whether we are adding exception handling edges from CallExprs.
117  /// If this is false, then try/catch statements and blocks reachable from them
118  /// can appear to be dead in the CFG, analysis passes must cope with that.
119  bool getAddEHEdges() const { return cfgBuildOptions.AddEHEdges; }
120  bool getUseUnoptimizedCFG() const {
121  return !cfgBuildOptions.PruneTriviallyFalseEdges;
122  }
123  bool getAddImplicitDtors() const { return cfgBuildOptions.AddImplicitDtors; }
124  bool getAddInitializers() const { return cfgBuildOptions.AddInitializers; }
125 
128 
129  /// \returns The body of the stored Decl \c D.
130  Stmt *getBody() const;
131 
132  /// \copydoc AnalysisDeclContext::getBody()
133  /// \param[out] IsAutosynthesized Specifies if the body is auto-generated
134  /// by the BodyFarm.
135  Stmt *getBody(bool &IsAutosynthesized) const;
136 
137  /// \returns Whether the body of the Decl \c D is generated by the BodyFarm.
138  ///
139  /// \note The lookup is not free. We are going to call getBody behind
140  /// the scenes.
141  /// \sa getBody
142  bool isBodyAutosynthesized() const;
143 
144  /// \returns Whether the body of the Decl \c D is generated by the BodyFarm
145  /// from a model file.
146  ///
147  /// \note The lookup is not free. We are going to call getBody behind
148  /// the scenes.
149  /// \sa getBody
151 
152  CFG *getCFG();
153 
155 
157 
158  /// \returns A version of the CFG without any edges pruned.
160 
161  void dumpCFG(bool ShowColors);
162 
163  /// \returns Whether we have built a CFG for this analysis context.
164  ///
165  /// \note This doesn't correspond to whether or not a valid CFG exists, it
166  /// corresponds to whether we *attempted* to build one.
167  bool isCFGBuilt() const { return builtCFG; }
168 
170 
171  using referenced_decls_iterator = const VarDecl *const *;
172 
173  llvm::iterator_range<referenced_decls_iterator>
175 
176  /// \returns The ImplicitParamDecl associated with \c self if this
177  /// AnalysisDeclContext wraps an ObjCMethodDecl or nullptr otherwise.
178  const ImplicitParamDecl *getSelfDecl() const;
179 
180  /// \copydoc LocationContextManager::getStackFrame()
181  const StackFrameContext *getStackFrame(LocationContext const *ParentLC,
182  const Stmt *S, const CFGBlock *Blk,
183  unsigned BlockCount, unsigned Index);
184 
185  /// \copydoc LocationContextManager::getBlockInvocationContext()
186  const BlockInvocationContext *
188  const BlockDecl *BD, const void *Data);
189 
190  /// \returns The specified analysis object, lazily running the analysis if
191  /// necessary or nullptr if the analysis could not run.
192  template <typename T> T *getAnalysis() {
193  const void *tag = T::getTag();
194  std::unique_ptr<ManagedAnalysis> &data = getAnalysisImpl(tag);
195  if (!data)
196  data = T::create(*this);
197  return static_cast<T *>(data.get());
198  }
199 
200  /// \returns Whether the root namespace of \p D is the \c std C++ namespace.
201  static bool isInStdNamespace(const Decl *D);
202 
203  static std::string getFunctionName(const Decl *D);
204 
205 private:
206  std::unique_ptr<ManagedAnalysis> &getAnalysisImpl(const void *tag);
207 
208  LocationContextManager &getLocationContextManager();
209 };
210 
211 /// It wraps the AnalysisDeclContext to represent both the call stack with
212 /// the help of StackFrameContext and inside the function calls the
213 /// BlockInvocationContext. It is needed for context sensitive analysis to
214 /// model entering, leaving or inlining function calls.
215 class LocationContext : public llvm::FoldingSetNode {
216 public:
218 
219 private:
220  ContextKind Kind;
221 
222  // AnalysisDeclContext can't be const since some methods may modify its
223  // member.
224  AnalysisDeclContext *Ctx;
225 
226  const LocationContext *Parent;
227  int64_t ID;
228 
229 protected:
231  const LocationContext *parent, int64_t ID)
232  : Kind(k), Ctx(ctx), Parent(parent), ID(ID) {}
233 
234 public:
235  virtual ~LocationContext();
236 
237  ContextKind getKind() const { return Kind; }
238 
239  int64_t getID() const { return ID; }
240 
242 
243  const LocationContext *getParent() const { return Parent; }
244 
245  bool isParentOf(const LocationContext *LC) const;
246 
247  const Decl *getDecl() const { return Ctx->getDecl(); }
248 
249  CFG *getCFG() const { return Ctx->getCFG(); }
250 
251  template <typename T> T *getAnalysis() const { return Ctx->getAnalysis<T>(); }
252 
253  const ParentMap &getParentMap() const { return Ctx->getParentMap(); }
254 
255  /// \copydoc AnalysisDeclContext::getSelfDecl()
256  const ImplicitParamDecl *getSelfDecl() const { return Ctx->getSelfDecl(); }
257 
258  const StackFrameContext *getStackFrame() const;
259 
260  /// \returns Whether the current LocationContext has no caller context.
261  virtual bool inTopFrame() const;
262 
263  virtual void Profile(llvm::FoldingSetNodeID &ID) = 0;
264 
265  /// Prints out the call stack.
266  ///
267  /// \param Out The out stream.
268  LLVM_DUMP_METHOD void dumpStack(raw_ostream &Out) const;
269 
270  /// Prints out the call stack in \c json format.
271  ///
272  /// \param Out The out stream.
273  /// \param NL The newline.
274  /// \param Space The space count for indentation.
275  /// \param IsDot Whether the output format is \c dot.
276  /// \param printMoreInfoPerContext
277  /// A callback to print more information for each context, for example:
278  /// \code
279  /// [&](const LocationContext *LC) { LC->dump(); }
280  /// \endcode
281  void printJson(
282  raw_ostream &Out, const char *NL = "\n", unsigned int Space = 0,
283  bool IsDot = false,
284  std::function<void(const LocationContext *)> printMoreInfoPerContext =
285  [](const LocationContext *) {}) const;
286 
287  LLVM_DUMP_METHOD void dump() const;
288 
289  static void ProfileCommon(llvm::FoldingSetNodeID &ID, ContextKind ck,
290  AnalysisDeclContext *ctx,
291  const LocationContext *parent, const void *data);
292 };
293 
294 /// It represents a stack frame of the call stack (based on CallEvent).
297 
298  // The call site where this stack frame is established.
299  const Stmt *CallSite;
300 
301  // The parent block of the call site.
302  const CFGBlock *Block;
303 
304  // The number of times the 'Block' has been visited.
305  // It allows discriminating between stack frames of the same call that is
306  // called multiple times in a loop.
307  const unsigned BlockCount;
308 
309  // The index of the call site in the CFGBlock.
310  const unsigned Index;
311 
313  const Stmt *S, const CFGBlock *Block, unsigned BlockCount,
314  unsigned Index, int64_t ID)
315  : LocationContext(StackFrame, ADC, ParentLC, ID), CallSite(S),
316  Block(Block), BlockCount(BlockCount), Index(Index) {}
317 
318 public:
319  ~StackFrameContext() override = default;
320 
321  const Stmt *getCallSite() const { return CallSite; }
322 
323  const CFGBlock *getCallSiteBlock() const { return Block; }
324 
325  bool inTopFrame() const override { return getParent() == nullptr; }
326 
327  unsigned getIndex() const { return Index; }
328 
329  CFGElement getCallSiteCFGElement() const { return (*Block)[Index]; }
330 
331  void Profile(llvm::FoldingSetNodeID &ID) override;
332 
333  static void Profile(llvm::FoldingSetNodeID &ID, AnalysisDeclContext *ADC,
334  const LocationContext *ParentLC, const Stmt *S,
335  const CFGBlock *Block, unsigned BlockCount,
336  unsigned Index) {
337  ProfileCommon(ID, StackFrame, ADC, ParentLC, S);
338  ID.AddPointer(Block);
339  ID.AddInteger(BlockCount);
340  ID.AddInteger(Index);
341  }
342 
343  static bool classof(const LocationContext *LC) {
344  return LC->getKind() == StackFrame;
345  }
346 };
347 
348 /// It represents a block invocation (based on BlockCall).
351 
352  const BlockDecl *BD;
353 
354  // FIXME: Come up with a more type-safe way to model context-sensitivity.
355  const void *Data;
356 
358  const LocationContext *ParentLC, const BlockDecl *BD,
359  const void *Data, int64_t ID)
360  : LocationContext(Block, ADC, ParentLC, ID), BD(BD), Data(Data) {}
361 
362 public:
363  ~BlockInvocationContext() override = default;
364 
365  const BlockDecl *getBlockDecl() const { return BD; }
366 
367  const void *getData() const { return Data; }
368 
369  void Profile(llvm::FoldingSetNodeID &ID) override;
370 
371  static void Profile(llvm::FoldingSetNodeID &ID, AnalysisDeclContext *ADC,
372  const LocationContext *ParentLC, const BlockDecl *BD,
373  const void *Data) {
374  ProfileCommon(ID, Block, ADC, ParentLC, BD);
375  ID.AddPointer(Data);
376  }
377 
378  static bool classof(const LocationContext *LC) {
379  return LC->getKind() == Block;
380  }
381 };
382 
384  llvm::FoldingSet<LocationContext> Contexts;
385 
386  // ID used for generating a new location context.
387  int64_t NewID = 0;
388 
389 public:
391 
392  /// Obtain a context of the call stack using its parent context.
393  ///
394  /// \param ADC The AnalysisDeclContext.
395  /// \param ParentLC The parent context of this newly created context.
396  /// \param S The call.
397  /// \param Block The basic block.
398  /// \param BlockCount The current count of entering into \p Blk.
399  /// \param Index The index of \p Blk.
400  /// \returns The context for \p D with parent context \p ParentLC.
402  const LocationContext *ParentLC,
403  const Stmt *S, const CFGBlock *Block,
404  unsigned BlockCount, unsigned Index);
405 
406  /// Obtain a context of the block invocation using its parent context.
407  ///
408  /// \param ADC The AnalysisDeclContext.
409  /// \param ParentLC The parent context of this newly created context.
410  /// \param BD The BlockDecl.
411  /// \param Data The raw data to store as part of the context.
412  const BlockInvocationContext *
414  const LocationContext *ParentLC,
415  const BlockDecl *BD, const void *Data);
416 
417  /// Discard all previously created LocationContext objects.
418  void clear();
419 };
420 
422  using ContextMap =
423  llvm::DenseMap<const Decl *, std::unique_ptr<AnalysisDeclContext>>;
424 
425  ContextMap Contexts;
426  LocationContextManager LocCtxMgr;
427  CFG::BuildOptions cfgBuildOptions;
428 
429  // Pointer to an interface that can provide function bodies for
430  // declarations from external source.
431  std::unique_ptr<CodeInjector> Injector;
432 
433  // A factory for creating and caching implementations for common
434  // methods during the analysis.
435  BodyFarm FunctionBodyFarm;
436 
437  // Flag to indicate whether or not bodies should be synthesized
438  // for well-known functions.
439  bool SynthesizeBodies;
440 
441 public:
443  ASTContext &ASTCtx, bool useUnoptimizedCFG = false,
444  bool addImplicitDtors = false, bool addInitializers = false,
445  bool addTemporaryDtors = false, bool addLifetime = false,
446  bool addLoopExit = false, bool addScopes = false,
447  bool synthesizeBodies = false, bool addStaticInitBranches = false,
448  bool addCXXNewAllocator = true, bool addRichCXXConstructors = true,
449  bool markElidedCXXConstructors = true, bool addVirtualBaseBranches = true,
450  CodeInjector *injector = nullptr);
451 
453 
454  bool getUseUnoptimizedCFG() const {
455  return !cfgBuildOptions.PruneTriviallyFalseEdges;
456  }
457 
458  CFG::BuildOptions &getCFGBuildOptions() { return cfgBuildOptions; }
459 
460  /// \returns Whether faux bodies should be synthesized for known functions.
461  bool synthesizeBodies() const { return SynthesizeBodies; }
462 
463  /// Obtain the beginning context of the analysis.
464  ///
465  /// \returns The top level stack frame for \p D.
467  return LocCtxMgr.getStackFrame(getContext(D), nullptr, nullptr, nullptr, 0,
468  0);
469  }
470 
471  /// \copydoc LocationContextManager::getStackFrame()
473  const LocationContext *Parent,
474  const Stmt *S, const CFGBlock *Block,
475  unsigned BlockCount, unsigned Index) {
476  return LocCtxMgr.getStackFrame(ADC, Parent, S, Block, BlockCount, Index);
477  }
478 
480 
481  /// Discard all previously created AnalysisDeclContexts.
482  void clear();
483 
484 private:
485  friend class AnalysisDeclContext;
486 
487  LocationContextManager &getLocationContextManager() { return LocCtxMgr; }
488 };
489 
490 } // namespace clang
491 
492 #endif // LLVM_CLANG_ANALYSIS_ANALYSISDECLCONTEXT_H
clang::AnalysisDeclContext::getCFGStmtMap
CFGStmtMap * getCFGStmtMap()
Definition: AnalysisDeclContext.cpp:251
clang::LocationContext::printJson
void printJson(raw_ostream &Out, const char *NL="\n", unsigned int Space=0, bool IsDot=false, std::function< void(const LocationContext *)> printMoreInfoPerContext=[](const LocationContext *) {}) const
Prints out the call stack in json format.
Definition: AnalysisDeclContext.cpp:532
clang::LocationContext::Profile
virtual void Profile(llvm::FoldingSetNodeID &ID)=0
clang::Decl::getASTContext
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:414
clang::StackFrameContext::Profile
static void Profile(llvm::FoldingSetNodeID &ID, AnalysisDeclContext *ADC, const LocationContext *ParentLC, const Stmt *S, const CFGBlock *Block, unsigned BlockCount, unsigned Index)
Definition: AnalysisDeclContext.h:333
clang::AnalysisDeclContext::getASTContext
ASTContext & getASTContext() const
Definition: AnalysisDeclContext.h:104
clang::AnalysisDeclContext::AnalysisDeclContext
AnalysisDeclContext(AnalysisDeclContextManager *Mgr, const Decl *D)
Definition: AnalysisDeclContext.cpp:62
clang::LocationContextManager::clear
void clear()
Discard all previously created LocationContext objects.
Definition: AnalysisDeclContext.cpp:698
clang::LocationContext
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
Definition: AnalysisDeclContext.h:215
clang::LocationContext::getStackFrame
const StackFrameContext * getStackFrame() const
Definition: AnalysisDeclContext.cpp:463
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::AnalysisDeclContext::isBodyAutosynthesized
bool isBodyAutosynthesized() const
Definition: AnalysisDeclContext.cpp:131
clang::ast_matchers::stmt
const internal::VariadicAllOfMatcher< Stmt > stmt
Matches statements.
Definition: ASTMatchersInternal.cpp:810
CodeInjector.h
clang::CFG::BuildOptions::AddEHEdges
bool AddEHEdges
Definition: CFG.h:1240
clang::AnalysisDeclContextManager::getStackFrame
const StackFrameContext * getStackFrame(const Decl *D)
Obtain the beginning context of the analysis.
Definition: AnalysisDeclContext.h:466
clang::AnalysisDeclContext::referenced_decls_iterator
const VarDecl *const * referenced_decls_iterator
Definition: AnalysisDeclContext.h:171
clang::LocationContextManager
Definition: AnalysisDeclContext.h:383
clang::AnalysisDeclContextManager::synthesizeBodies
bool synthesizeBodies() const
Definition: AnalysisDeclContext.h:461
clang::AnalysisDeclContextManager::getStackFrame
const StackFrameContext * getStackFrame(AnalysisDeclContext *ADC, const LocationContext *Parent, const Stmt *S, const CFGBlock *Block, unsigned BlockCount, unsigned Index)
Obtain a context of the call stack using its parent context.
Definition: AnalysisDeclContext.h:472
clang::AnalysisDeclContext
AnalysisDeclContext contains the context data for the function, method or block under analysis.
Definition: AnalysisDeclContext.h:72
clang::AnalysisDeclContext::getSelfDecl
const ImplicitParamDecl * getSelfDecl() const
Definition: AnalysisDeclContext.cpp:148
clang::LocationContext::StackFrame
@ StackFrame
Definition: AnalysisDeclContext.h:217
clang::StackFrameContext::getCallSiteCFGElement
CFGElement getCallSiteCFGElement() const
Definition: AnalysisDeclContext.h:329
clang::AnalysisDeclContext::getStackFrame
const StackFrameContext * getStackFrame(LocationContext const *ParentLC, const Stmt *S, const CFGBlock *Blk, unsigned BlockCount, unsigned Index)
Obtain a context of the call stack using its parent context.
Definition: AnalysisDeclContext.cpp:312
clang::StackFrameContext::getCallSiteBlock
const CFGBlock * getCallSiteBlock() const
Definition: AnalysisDeclContext.h:323
clang::StackFrameContext
It represents a stack frame of the call stack (based on CallEvent).
Definition: AnalysisDeclContext.h:295
clang::StackFrameContext::getIndex
unsigned getIndex() const
Definition: AnalysisDeclContext.h:327
clang::AnalysisDeclContextManager::AnalysisDeclContextManager
AnalysisDeclContextManager(ASTContext &ASTCtx, bool useUnoptimizedCFG=false, bool addImplicitDtors=false, bool addInitializers=false, bool addTemporaryDtors=false, bool addLifetime=false, bool addLoopExit=false, bool addScopes=false, bool synthesizeBodies=false, bool addStaticInitBranches=false, bool addCXXNewAllocator=true, bool addRichCXXConstructors=true, bool markElidedCXXConstructors=true, bool addVirtualBaseBranches=true, CodeInjector *injector=nullptr)
Definition: AnalysisDeclContext.cpp:68
clang::LocationContext::getAnalysis
T * getAnalysis() const
Definition: AnalysisDeclContext.h:251
clang::CFG
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt.
Definition: CFG.h:1225
clang::AnalysisDeclContext::getBlockInvocationContext
const BlockInvocationContext * getBlockInvocationContext(const LocationContext *ParentLC, const BlockDecl *BD, const void *Data)
Obtain a context of the block invocation using its parent context.
Definition: AnalysisDeclContext.cpp:319
clang::StackFrameContext::classof
static bool classof(const LocationContext *LC)
Definition: AnalysisDeclContext.h:343
clang::CFG::BuildOptions::PruneTriviallyFalseEdges
bool PruneTriviallyFalseEdges
Definition: CFG.h:1239
clang::AnalysisDeclContext::dumpCFG
void dumpCFG(bool ShowColors)
Definition: AnalysisDeclContext.cpp:275
clang::AnalysisDeclContext::registerForcedBlockExpression
void registerForcedBlockExpression(const Stmt *stmt)
Definition: AnalysisDeclContext.cpp:180
clang::CFGBlock
Represents a single basic block in a source-level CFG.
Definition: CFG.h:576
clang::AnalysisDeclContext::getCFGBuildOptions
const CFG::BuildOptions & getCFGBuildOptions() const
Definition: AnalysisDeclContext.h:112
clang::CFG::BuildOptions
Definition: CFG.h:1231
clang::AnalysisDeclContext::getAddEHEdges
bool getAddEHEdges() const
Definition: AnalysisDeclContext.h:119
clang::StackFrameContext::inTopFrame
bool inTopFrame() const override
Definition: AnalysisDeclContext.h:325
clang::LocationContext::dumpStack
LLVM_DUMP_METHOD void dumpStack(raw_ostream &Out) const
Prints out the call stack.
Definition: AnalysisDeclContext.cpp:497
clang::AnalysisDeclContext::getParentMap
ParentMap & getParentMap()
Definition: AnalysisDeclContext.cpp:279
clang::AnalysisDeclContext::getAnalysis
T * getAnalysis()
Definition: AnalysisDeclContext.h:192
clang::AnalysisDeclContext::isBodyAutosynthesizedFromModelFile
bool isBodyAutosynthesizedFromModelFile() const
Definition: AnalysisDeclContext.cpp:137
clang::BlockDecl
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4162
clang::LocationContext::getAnalysisDeclContext
AnalysisDeclContext * getAnalysisDeclContext() const
Definition: AnalysisDeclContext.h:241
DeclBase.h
clang::CFGReverseBlockReachabilityAnalysis
Definition: CFGReachabilityAnalysis.h:31
clang::LocationContext::inTopFrame
virtual bool inTopFrame() const
Definition: AnalysisDeclContext.cpp:473
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:212
clang::LocationContext::isParentOf
bool isParentOf(const LocationContext *LC) const
Definition: AnalysisDeclContext.cpp:477
clang::BlockInvocationContext
It represents a block invocation (based on BlockCall).
Definition: AnalysisDeclContext.h:349
clang::LocationContext::getSelfDecl
const ImplicitParamDecl * getSelfDecl() const
Definition: AnalysisDeclContext.h:256
clang::AnalysisDeclContext::getCFGReachablityAnalysis
CFGReverseBlockReachabilityAnalysis * getCFGReachablityAnalysis()
Definition: AnalysisDeclContext.cpp:263
clang::AnalysisDeclContextManager::getBodyFarm
BodyFarm & getBodyFarm()
Definition: AnalysisDeclContext.cpp:309
clang::LocationContextManager::~LocationContextManager
~LocationContextManager()
Definition: AnalysisDeclContext.cpp:694
clang::ImplicitParamDecl
Definition: Decl.h:1601
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:876
clang::AnalysisDeclContext::isInStdNamespace
static bool isInStdNamespace(const Decl *D)
Definition: AnalysisDeclContext.cpp:325
clang::LocationContext::getKind
ContextKind getKind() const
Definition: AnalysisDeclContext.h:237
clang::ManagedAnalysis
The base class of a hierarchy of objects representing analyses tied to AnalysisDeclContext.
Definition: AnalysisDeclContext.h:51
clang::AnalysisDeclContext::getAddImplicitDtors
bool getAddImplicitDtors() const
Definition: AnalysisDeclContext.h:123
clang::LocationContextManager::getStackFrame
const StackFrameContext * getStackFrame(AnalysisDeclContext *ADC, const LocationContext *ParentLC, const Stmt *S, const CFGBlock *Block, unsigned BlockCount, unsigned Index)
Obtain a context of the call stack using its parent context.
Definition: AnalysisDeclContext.cpp:428
clang::CFGStmtMap
Definition: CFGStmtMap.h:24
clang::AnalysisDeclContextManager::getContext
AnalysisDeclContext * getContext(const Decl *D)
Definition: AnalysisDeclContext.cpp:295
clang::BlockInvocationContext::classof
static bool classof(const LocationContext *LC)
Definition: AnalysisDeclContext.h:378
clang::AnalysisDeclContext::getUnoptimizedCFG
CFG * getUnoptimizedCFG()
Definition: AnalysisDeclContext.cpp:232
clang::LocationContext::Block
@ Block
Definition: AnalysisDeclContext.h:217
clang::AnalysisDeclContext::getManager
AnalysisDeclContextManager * getManager() const
Definition: AnalysisDeclContext.h:108
clang::AnalysisDeclContext::getUseUnoptimizedCFG
bool getUseUnoptimizedCFG() const
Definition: AnalysisDeclContext.h:120
clang::AnalysisDeclContext::isCFGBuilt
bool isCFGBuilt() const
Definition: AnalysisDeclContext.h:167
clang::LocationContext::getParent
const LocationContext * getParent() const
Definition: AnalysisDeclContext.h:243
clang::BlockInvocationContext::Profile
static void Profile(llvm::FoldingSetNodeID &ID, AnalysisDeclContext *ADC, const LocationContext *ParentLC, const BlockDecl *BD, const void *Data)
Definition: AnalysisDeclContext.h:371
clang::ParentMap
Definition: ParentMap.h:20
clang::serialized_diags::create
std::unique_ptr< DiagnosticConsumer > create(StringRef OutputFile, DiagnosticOptions *Diags, bool MergeChildRecords=false)
Returns a DiagnosticConsumer that serializes diagnostics to a bitcode file.
Definition: SerializedDiagnosticPrinter.cpp:302
clang::AnalysisDeclContext::getCFGBuildOptions
CFG::BuildOptions & getCFGBuildOptions()
Definition: AnalysisDeclContext.h:110
clang::LocationContext::dump
LLVM_DUMP_METHOD void dump() const
Definition: AnalysisDeclContext.cpp:584
clang::LocationContextManager::getBlockInvocationContext
const BlockInvocationContext * getBlockInvocationContext(AnalysisDeclContext *ADC, const LocationContext *ParentLC, const BlockDecl *BD, const void *Data)
Obtain a context of the block invocation using its parent context.
Definition: AnalysisDeclContext.cpp:443
clang::StackFrameContext::~StackFrameContext
~StackFrameContext() override=default
clang::AnalysisDeclContextManager::clear
void clear()
Discard all previously created AnalysisDeclContexts.
Definition: AnalysisDeclContext.cpp:91
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:89
clang::StackFrameContext::getCallSite
const Stmt * getCallSite() const
Definition: AnalysisDeclContext.h:321
clang::ManagedAnalysis::ManagedAnalysis
ManagedAnalysis()=default
clang::LocationContext::LocationContext
LocationContext(ContextKind k, AnalysisDeclContext *ctx, const LocationContext *parent, int64_t ID)
Definition: AnalysisDeclContext.h:230
LLVM.h
clang::BlockInvocationContext::getData
const void * getData() const
Definition: AnalysisDeclContext.h:367
clang::AnalysisDeclContext::getAddInitializers
bool getAddInitializers() const
Definition: AnalysisDeclContext.h:124
clang::BlockInvocationContext::Profile
void Profile(llvm::FoldingSetNodeID &ID) override
Definition: AnalysisDeclContext.cpp:420
clang::AnalysisDeclContext::getFunctionName
static std::string getFunctionName(const Decl *D)
Definition: AnalysisDeclContext.cpp:340
clang::AnalysisDeclContext::getBody
Stmt * getBody() const
Definition: AnalysisDeclContext.cpp:126
clang::BodyFarm
Definition: BodyFarm.h:31
BodyFarm.h
clang::CFGElement
Represents a top-level expression in a basic block.
Definition: CFG.h:55
clang::CFG::BuildOptions::AddImplicitDtors
bool AddImplicitDtors
Definition: CFG.h:1242
clang::AnalysisDeclContext::getReferencedBlockVars
llvm::iterator_range< referenced_decls_iterator > getReferencedBlockVars(const BlockDecl *BD)
Definition: AnalysisDeclContext.cpp:664
clang::LocationContext::getID
int64_t getID() const
Definition: AnalysisDeclContext.h:239
clang::Builtin::ID
ID
Definition: Builtins.h:48
clang
Definition: CalledOnceCheck.h:17
clang::ManagedAnalysis::~ManagedAnalysis
virtual ~ManagedAnalysis()
CFG.h
clang::AnalysisDeclContext::getDecl
const Decl * getDecl() const
Definition: AnalysisDeclContext.h:106
clang::DeclaratorContext::Block
@ Block
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:69
clang::LocationContext::ProfileCommon
static void ProfileCommon(llvm::FoldingSetNodeID &ID, ContextKind ck, AnalysisDeclContext *ctx, const LocationContext *parent, const void *data)
Definition: AnalysisDeclContext.cpp:404
clang::AnalysisDeclContext::getBlockForRegisteredExpression
const CFGBlock * getBlockForRegisteredExpression(const Stmt *stmt)
Definition: AnalysisDeclContext.cpp:190
clang::AnalysisDeclContextManager::getUseUnoptimizedCFG
bool getUseUnoptimizedCFG() const
Definition: AnalysisDeclContext.h:454
clang::BlockInvocationContext::getBlockDecl
const BlockDecl * getBlockDecl() const
Definition: AnalysisDeclContext.h:365
clang::AnalysisDeclContext::~AnalysisDeclContext
~AnalysisDeclContext()
Definition: AnalysisDeclContext.cpp:686
clang::AnalysisDeclContextManager
Definition: AnalysisDeclContext.h:421
clang::LocationContext::ContextKind
ContextKind
Definition: AnalysisDeclContext.h:217
clang::StackFrameContext::Profile
void Profile(llvm::FoldingSetNodeID &ID) override
Definition: AnalysisDeclContext.cpp:415
clang::CodeInjector
CodeInjector is an interface which is responsible for injecting AST of function definitions that may ...
Definition: CodeInjector.h:35
Parent
NodeId Parent
Definition: ASTDiff.cpp:192
clang::LocationContext::getCFG
CFG * getCFG() const
Definition: AnalysisDeclContext.h:249
clang::AnalysisDeclContext::getCFG
CFG * getCFG()
Definition: AnalysisDeclContext.cpp:213
clang::CFG::BuildOptions::ForcedBlkExprs
llvm::DenseMap< const Stmt *, const CFGBlock * > ForcedBlkExprs
Definition: CFG.h:1235
clang::LocationContext::getDecl
const Decl * getDecl() const
Definition: AnalysisDeclContext.h:247
clang::LocationContext::~LocationContext
virtual ~LocationContext()
clang::CFG::BuildOptions::AddInitializers
bool AddInitializers
Definition: CFG.h:1241
clang::LocationContext::getParentMap
const ParentMap & getParentMap() const
Definition: AnalysisDeclContext.h:253
clang::BlockInvocationContext::~BlockInvocationContext
~BlockInvocationContext() override=default
clang::AnalysisDeclContextManager::getCFGBuildOptions
CFG::BuildOptions & getCFGBuildOptions()
Definition: AnalysisDeclContext.h:458