class LocationContext : public llvm::FoldingSetNode {
public:
- enum ContextKind { StackFrame, Scope };
+ enum ContextKind { StackFrame, Scope, Block };
private:
ContextKind Kind;
AnalysisContext *ctx, const LocationContext *parent);
static bool classof(const LocationContext*) { return true; }
+
+protected:
+ static void ProfileCommon(llvm::FoldingSetNodeID &ID,
+ ContextKind ck,
+ AnalysisContext *ctx,
+ const LocationContext *parent,
+ const void* data);
};
class StackFrameContext : public LocationContext {
const Stmt *CallSite;
-
public:
StackFrameContext(AnalysisContext *ctx, const LocationContext *parent,
const Stmt *s)
Stmt const *getCallSite() const { return CallSite; }
- virtual void Profile(llvm::FoldingSetNodeID &ID) {
- Profile(ID, getAnalysisContext(), getParent(), CallSite);
- }
-
+ void Profile(llvm::FoldingSetNodeID &ID);
+
static void Profile(llvm::FoldingSetNodeID &ID, AnalysisContext *ctx,
- const LocationContext *parent, const Stmt *s);
+ const LocationContext *parent, const Stmt *s) {
+ ProfileCommon(ID, StackFrame, ctx, parent, s);
+ }
static bool classof(const LocationContext* Ctx) {
return Ctx->getKind() == StackFrame;
class ScopeContext : public LocationContext {
const Stmt *Enter;
-
public:
ScopeContext(AnalysisContext *ctx, const LocationContext *parent,
const Stmt *s)
virtual ~ScopeContext() {}
- virtual void Profile(llvm::FoldingSetNodeID &ID) {
- Profile(ID, getAnalysisContext(), getParent(), Enter);
- }
+ void Profile(llvm::FoldingSetNodeID &ID);
static void Profile(llvm::FoldingSetNodeID &ID, AnalysisContext *ctx,
- const LocationContext *parent, const Stmt *s);
+ const LocationContext *parent, const Stmt *s) {
+ ProfileCommon(ID, Scope, ctx, parent, s);
+ }
static bool classof(const LocationContext* Ctx) {
return Ctx->getKind() == Scope;
}
};
+class BlockInvocationContext : public LocationContext {
+ const BlockDecl *BD;
+public:
+ BlockInvocationContext(const BlockDecl *bd, AnalysisContext *ctx,
+ const LocationContext *parent = 0)
+ : LocationContext(Block, ctx, parent), BD(bd) {}
+
+ ~BlockInvocationContext() {}
+
+ const BlockDecl *getBlockDecl() const { return BD; }
+
+ void Profile(llvm::FoldingSetNodeID &ID);
+
+ static void Profile(llvm::FoldingSetNodeID &ID, AnalysisContext *ctx,
+ const LocationContext *parent, const BlockDecl *bd) {
+ ProfileCommon(ID, Block, ctx, parent, bd);
+ }
+
+ static bool classof(const LocationContext* Ctx) {
+ return Ctx->getKind() == Block;
+ }
+};
+
class LocationContextManager {
llvm::FoldingSet<LocationContext> Contexts;
return AC;
}
+//===----------------------------------------------------------------------===//
+// FoldingSet profiling.
+//===----------------------------------------------------------------------===//
+
void LocationContext::Profile(llvm::FoldingSetNodeID &ID, ContextKind k,
AnalysisContext *ctx,
const LocationContext *parent) {
ID.AddPointer(parent);
}
-void StackFrameContext::Profile(llvm::FoldingSetNodeID &ID,AnalysisContext *ctx,
- const LocationContext *parent, const Stmt *s) {
- LocationContext::Profile(ID, StackFrame, ctx, parent);
- ID.AddPointer(s);
+void LocationContext::ProfileCommon(llvm::FoldingSetNodeID &ID,
+ ContextKind ck,
+ AnalysisContext *ctx,
+ const LocationContext *parent,
+ const void* data) {
+ LocationContext::Profile(ID, ck, ctx, parent);
+ ID.AddPointer(data);
}
-void ScopeContext::Profile(llvm::FoldingSetNodeID &ID, AnalysisContext *ctx,
- const LocationContext *parent, const Stmt *s) {
- LocationContext::Profile(ID, Scope, ctx, parent);
- ID.AddPointer(s);
+void StackFrameContext::Profile(llvm::FoldingSetNodeID &ID) {
+ Profile(ID, getAnalysisContext(), getParent(), CallSite);
}
+void ScopeContext::Profile(llvm::FoldingSetNodeID &ID) {
+ Profile(ID, getAnalysisContext(), getParent(), Enter);
+}
+
+void BlockInvocationContext::Profile(llvm::FoldingSetNodeID &ID) {
+ Profile(ID, getAnalysisContext(), getParent(), BD);
+}
+
+//===----------------------------------------------------------------------===//
+// Cleanup.
+//===----------------------------------------------------------------------===//
+
LocationContextManager::~LocationContextManager() {
clear();
}