[cfe-commits] r110059 - /cfe/trunk/lib/Checker/IdempotentOperationChecker.cpp
Ted Kremenek
kremenek at apple.com
Mon Aug 2 13:33:03 PDT 2010
Author: kremenek
Date: Mon Aug 2 15:33:02 2010
New Revision: 110059
URL: http://llvm.org/viewvc/llvm-project?rev=110059&view=rev
Log:
'Assumption &A' gets default initialized to 'Possible' if it doesn't exist; no need to two
lookups in the hashtable.
Modified:
cfe/trunk/lib/Checker/IdempotentOperationChecker.cpp
Modified: cfe/trunk/lib/Checker/IdempotentOperationChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/IdempotentOperationChecker.cpp?rev=110059&r1=110058&r2=110059&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/IdempotentOperationChecker.cpp (original)
+++ cfe/trunk/lib/Checker/IdempotentOperationChecker.cpp Mon Aug 2 15:33:02 2010
@@ -70,7 +70,7 @@
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 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.
More information about the cfe-commits
mailing list