summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/AnalysisContext.cpp
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2009-08-03 07:23:22 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2009-08-03 07:23:22 +0000
commit9ad0b46a80aa75ddfd094cc30574b55a0bc91e42 (patch)
tree838d2446fbfa7ab7b76279b6c171153c536e507b /clang/lib/Analysis/AnalysisContext.cpp
parent129bb4165f94270eb81bb5d36e00f7c6669eb7d2 (diff)
downloadbcm5719-llvm-9ad0b46a80aa75ddfd094cc30574b55a0bc91e42.tar.gz
bcm5719-llvm-9ad0b46a80aa75ddfd094cc30574b55a0bc91e42.zip
add a bunch of routine methods to AnalysisContext.
llvm-svn: 77961
Diffstat (limited to 'clang/lib/Analysis/AnalysisContext.cpp')
-rw-r--r--clang/lib/Analysis/AnalysisContext.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/clang/lib/Analysis/AnalysisContext.cpp b/clang/lib/Analysis/AnalysisContext.cpp
index b92eb24d7c9..996d5c879ac 100644
--- a/clang/lib/Analysis/AnalysisContext.cpp
+++ b/clang/lib/Analysis/AnalysisContext.cpp
@@ -72,3 +72,53 @@ AnalysisContext *AnalysisContextManager::getContext(Decl *D) {
Ctx.setDecl(D);
return &Ctx;
}
+
+void LocationContext::Profile(llvm::FoldingSetNodeID &ID, ContextKind k,
+ AnalysisContext *ctx, LocationContext *parent) {
+ ID.AddInteger(k);
+ ID.AddPointer(ctx);
+ ID.AddPointer(parent);
+}
+
+void StackFrameContext::Profile(llvm::FoldingSetNodeID &ID,AnalysisContext *ctx,
+ LocationContext *parent, Stmt *s) {
+ LocationContext::Profile(ID, StackFrame, ctx, parent);
+ ID.AddPointer(s);
+}
+
+void ScopeContext::Profile(llvm::FoldingSetNodeID &ID, AnalysisContext *ctx,
+ LocationContext *parent, Stmt *s) {
+ LocationContext::Profile(ID, Scope, ctx, parent);
+ ID.AddPointer(s);
+}
+
+StackFrameContext *LocationContextManager::getStackFrame(AnalysisContext *ctx,
+ LocationContext *parent, Stmt *s) {
+ llvm::FoldingSetNodeID ID;
+ StackFrameContext::Profile(ID, ctx, parent, s);
+ void *InsertPos;
+
+ StackFrameContext *f =
+ cast_or_null<StackFrameContext>(Contexts.FindNodeOrInsertPos(ID, InsertPos));
+ if (!f) {
+ f = new StackFrameContext(ctx, parent, s);
+ Contexts.InsertNode(f, InsertPos);
+ }
+ return f;
+}
+
+ScopeContext *LocationContextManager::getScope(AnalysisContext *ctx,
+ LocationContext *parent, Stmt *s) {
+ llvm::FoldingSetNodeID ID;
+ ScopeContext::Profile(ID, ctx, parent, s);
+ void *InsertPos;
+
+ ScopeContext *scope =
+ cast_or_null<ScopeContext>(Contexts.FindNodeOrInsertPos(ID, InsertPos));
+
+ if (!scope) {
+ scope = new ScopeContext(ctx, parent, s);
+ Contexts.InsertNode(scope, InsertPos);
+ }
+ return scope;
+}
OpenPOWER on IntegriCloud