diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-08-02 20:33:02 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-08-02 20:33:02 +0000 |
commit | fe97fa141d90e5fbcb18a988bb5d72739d397b6c (patch) | |
tree | a6ac2cf13cab4ea266b951f292d48292ee1c245f /lib/Checker/IdempotentOperationChecker.cpp | |
parent | 80776387c299a40f32dc95246bef0098bee8d6dc (diff) |
'Assumption &A' gets default initialized to 'Possible' if it doesn't exist; no need to two
lookups in the hashtable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110059 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Checker/IdempotentOperationChecker.cpp')
-rw-r--r-- | lib/Checker/IdempotentOperationChecker.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/Checker/IdempotentOperationChecker.cpp b/lib/Checker/IdempotentOperationChecker.cpp index 9ef56b0d58..267e747928 100644 --- a/lib/Checker/IdempotentOperationChecker.cpp +++ b/lib/Checker/IdempotentOperationChecker.cpp @@ -70,7 +70,7 @@ class IdempotentOperationChecker private: // Our assumption about a particular operation. - enum Assumption { Possible, Impossible, Equal, LHSis1, RHSis1, LHSis0, + enum Assumption { Possible = 0, Impossible, Equal, LHSis1, RHSis1, LHSis0, RHSis0 }; void UpdateAssumption(Assumption &A, const Assumption &New); @@ -101,13 +101,10 @@ void clang::RegisterIdempotentOperationChecker(GRExprEngine &Eng) { void IdempotentOperationChecker::PreVisitBinaryOperator( CheckerContext &C, const BinaryOperator *B) { - // Find or create an entry in the hash for this BinaryOperator instance - AssumptionMap::iterator i = hash.find(B); - Assumption &A = i == hash.end() ? hash[B] : i->second; - - // If we had to create an entry, initialise the value to Possible - if (i == hash.end()) - A = Possible; + // Find or create an entry in the hash for this BinaryOperator instance. + // If we haven't done a lookup before, it will get default initialized to + // 'Possible'. + Assumption &A = hash[B]; // If we already have visited this node on a path that does not contain an // idempotent operation, return immediately. |