From fe97fa141d90e5fbcb18a988bb5d72739d397b6c Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 2 Aug 2010 20:33:02 +0000 Subject: [PATCH] '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 --- lib/Checker/IdempotentOperationChecker.cpp | 13 +++++-------- 1 file 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. -- 2.50.1