summaryrefslogtreecommitdiffstats
path: root/lib/Checker/GRBlockCounter.cpp
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2010-04-02 08:55:10 +0000
committerrdivacky <rdivacky@FreeBSD.org>2010-04-02 08:55:10 +0000
commit07b2cfcdb817cc0790420f159a313d61e7241cb9 (patch)
treed374cdca417e76f1bf101f139dba2db1d10ee8f7 /lib/Checker/GRBlockCounter.cpp
parent1e255aab650a7fa2047fd953cae65b12215280af (diff)
downloadFreeBSD-src-07b2cfcdb817cc0790420f159a313d61e7241cb9.zip
FreeBSD-src-07b2cfcdb817cc0790420f159a313d61e7241cb9.tar.gz
Update clang to r100181.
Diffstat (limited to 'lib/Checker/GRBlockCounter.cpp')
-rw-r--r--lib/Checker/GRBlockCounter.cpp43
1 files changed, 37 insertions, 6 deletions
diff --git a/lib/Checker/GRBlockCounter.cpp b/lib/Checker/GRBlockCounter.cpp
index 3fa3e1e..cd26060 100644
--- a/lib/Checker/GRBlockCounter.cpp
+++ b/lib/Checker/GRBlockCounter.cpp
@@ -18,7 +18,34 @@
using namespace clang;
-typedef llvm::ImmutableMap<unsigned,unsigned> CountMap;
+namespace {
+
+class CountKey {
+ const StackFrameContext *CallSite;
+ unsigned BlockID;
+
+public:
+ CountKey(const StackFrameContext *CS, unsigned ID)
+ : CallSite(CS), BlockID(ID) {}
+
+ bool operator==(const CountKey &RHS) const {
+ return (CallSite == RHS.CallSite) && (BlockID == RHS.BlockID);
+ }
+
+ bool operator<(const CountKey &RHS) const {
+ return (CallSite == RHS.CallSite) ? (BlockID < RHS.BlockID)
+ : (CallSite < RHS.CallSite);
+ }
+
+ void Profile(llvm::FoldingSetNodeID &ID) const {
+ ID.AddPointer(CallSite);
+ ID.AddInteger(BlockID);
+ }
+};
+
+}
+
+typedef llvm::ImmutableMap<CountKey, unsigned> CountMap;
static inline CountMap GetMap(void* D) {
return CountMap(static_cast<CountMap::TreeTy*>(D));
@@ -28,9 +55,10 @@ static inline CountMap::Factory& GetFactory(void* F) {
return *static_cast<CountMap::Factory*>(F);
}
-unsigned GRBlockCounter::getNumVisited(unsigned BlockID) const {
+unsigned GRBlockCounter::getNumVisited(const StackFrameContext *CallSite,
+ unsigned BlockID) const {
CountMap M = GetMap(Data);
- CountMap::data_type* T = M.lookup(BlockID);
+ CountMap::data_type* T = M.lookup(CountKey(CallSite, BlockID));
return T ? *T : 0;
}
@@ -43,9 +71,12 @@ GRBlockCounter::Factory::~Factory() {
}
GRBlockCounter
-GRBlockCounter::Factory::IncrementCount(GRBlockCounter BC, unsigned BlockID) {
- return GRBlockCounter(GetFactory(F).Add(GetMap(BC.Data), BlockID,
- BC.getNumVisited(BlockID)+1).getRoot());
+GRBlockCounter::Factory::IncrementCount(GRBlockCounter BC,
+ const StackFrameContext *CallSite,
+ unsigned BlockID) {
+ return GRBlockCounter(GetFactory(F).Add(GetMap(BC.Data),
+ CountKey(CallSite, BlockID),
+ BC.getNumVisited(CallSite, BlockID)+1).getRoot());
}
GRBlockCounter
OpenPOWER on IntegriCloud