[cfe-commits] r127528 - /cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorsChecker.cpp
Ted Kremenek
kremenek at apple.com
Fri Mar 11 20:08:07 PST 2011
Author: kremenek
Date: Fri Mar 11 22:08:07 2011
New Revision: 127528
URL: http://llvm.org/viewvc/llvm-project?rev=127528&view=rev
Log:
Don't have side-effects (or rather non-trivial computation) in StringSwitch "cases."
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorsChecker.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorsChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorsChecker.cpp?rev=127528&r1=127527&r2=127528&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorsChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorsChecker.cpp Fri Mar 11 22:08:07 2011
@@ -282,12 +282,15 @@
// Finally, see if it is one of the calls that will create
// a valid iterator and mark it if so, else mark as Unknown.
llvm::StringRef mName = ME->getMemberDecl()->getName();
- return llvm::StringSwitch<const GRState*>(mName)
- .Cases("begin", "insert", "erase",
- state->set<IteratorState>(MR, RefState::getBeginValid(IMR)))
- .Case("end",
- state->set<IteratorState>(MR, RefState::getEndValid(IMR)))
- .Default(state->set<IteratorState>(MR, RefState::getUnknown()));
+
+ if (llvm::StringSwitch<bool>(mName)
+ .Cases("begin", "insert", "erase", true).Default(false)) {
+ return state->set<IteratorState>(MR, RefState::getBeginValid(IMR));
+ }
+ if (mName == "end")
+ return state->set<IteratorState>(MR, RefState::getEndValid(IMR));
+
+ return state->set<IteratorState>(MR, RefState::getUnknown());
}
}
// Handle straight copy from another iterator.
More information about the cfe-commits
mailing list