[cfe-commits] r130425 - /cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
Lenny Maiorani
lenny at colorado.edu
Thu Apr 28 12:31:12 PDT 2011
Author: lenny
Date: Thu Apr 28 14:31:12 2011
New Revision: 130425
URL: http://llvm.org/viewvc/llvm-project?rev=130425&view=rev
Log:
Use StringRef::substr() and unbounded StringRef::compare() instead of bounded version of StringRef::compare() because bounded version of StringRef::compare() is going to be removed.
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp?rev=130425&r1=130424&r2=130425&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp Thu Apr 28 14:31:12 2011
@@ -1190,7 +1190,14 @@
// For now, give up.
return;
} else {
- result = s1StrRef.compare(s2StrRef, (size_t)lenInt.getLimitedValue());
+ // Create substrings of each to compare the prefix.
+ llvm::StringRef s1SubStr =
+ s1StrRef.substr(0, (size_t)lenInt.getLimitedValue());
+ llvm::StringRef s2SubStr =
+ s2StrRef.substr(0, (size_t)lenInt.getLimitedValue());
+
+ // Compare the substrings.
+ result = s1SubStr.compare(s2SubStr);
}
} else {
// Compare string 1 to string 2 the same way strcmp() does.
More information about the cfe-commits
mailing list