================
@@ -271,94 +284,52 @@ class LocationContext : public llvm::FoldingSetNode {
/// \param printMoreInfoPerContext
/// A callback to print more information for each context, for example:
/// \code
- /// [&](const LocationContext *LC) { LC->dump(); }
+ /// [&](const StackFrame *SF) { SF->dump(); }
/// \endcode
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;
-
- LLVM_DUMP_METHOD void dump() const;
-
- static void ProfileCommon(llvm::FoldingSetNodeID &ID, ContextKind ck,
- AnalysisDeclContext *ctx,
- const LocationContext *parent, const void *data);
-};
-
-/// It represents a stack frame of the call stack (based on CallEvent).
-class StackFrame : public LocationContext {
- friend class LocationContextManager;
-
- // Extra data for BlockInvocations
- const void *Data;
-
- // The call site where this stack frame is established.
- const Expr *CallSite;
-
- // The parent block of the call site.
- const CFGBlock *Block;
-
- // The number of times the 'Block' has been visited.
- // It allows discriminating between stack frames of the same call that is
- // called multiple times in a loop.
- const unsigned BlockCount;
-
- // The index of the call site in the CFGBlock.
- const unsigned Index;
-
- StackFrame(AnalysisDeclContext *ADC, const LocationContext *ParentLC,
- const void *Data, const Expr *E, const CFGBlock *Block,
- unsigned BlockCount, unsigned Index, int64_t ID)
- : LocationContext(StackFrameKind, ADC, ParentLC, ID), Data(Data),
- CallSite(E), Block(Block), BlockCount(BlockCount), Index(Index) {}
-
-public:
- ~StackFrame() override = default;
+ std::function<void(const StackFrame *)> printMoreInfoPerContext =
+ [](const StackFrame *) {}) const;
- const void *getData() const { return Data; }
-
- const Expr *getCallSite() const { return CallSite; }
-
- const CFGBlock *getCallSiteBlock() const { return Block; }
-
- bool inTopFrame() const override { return getParent() == nullptr; }
+ /// Prints out the call stack.
+ ///
+ /// \param Out The out stream.
+ LLVM_DUMP_METHOD void dumpStack(raw_ostream &Out) const;
- unsigned getIndex() const { return Index; }
+ LLVM_DUMP_METHOD void dump() const;
- CFGElement getCallSiteCFGElement() const { return (*Block)[Index]; }
+ void Profile(llvm::FoldingSetNodeID &ID);
- void Profile(llvm::FoldingSetNodeID &ID) override;
+ static void ProfileCommon(llvm::FoldingSetNodeID &ID,
+ AnalysisDeclContext *ctx, const StackFrame *parent,
+ const void *data);
static void Profile(llvm::FoldingSetNodeID &ID, AnalysisDeclContext *ADC,
- const LocationContext *ParentLC, const void *Data,
- const Expr *E, const CFGBlock *Block, unsigned
BlockCount,
+ const StackFrame *SF, const void *Data, const Expr *E,
+ const CFGBlock *Block, unsigned BlockCount,
unsigned Index) {
- ProfileCommon(ID, StackFrameKind, ADC, ParentLC, E);
+ ProfileCommon(ID, ADC, SF, E);
ID.AddPointer(Data);
ID.AddPointer(Block);
ID.AddInteger(BlockCount);
ID.AddInteger(Index);
}
-
- static bool classof(const LocationContext *LC) {
- return LC->getKind() == StackFrameKind;
- }
};
-class LocationContextManager {
- llvm::FoldingSet<LocationContext> Contexts;
+class StackFrameManager {
+ llvm::FoldingSet<StackFrame> Contexts;
----------------
steakhal wrote:
I think now that `LocationContext` was replaced with `StachFrame`, maybe we
should also rename this to `Frames` or something similar.
https://github.com/llvm/llvm-project/pull/198211
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits