diff options
author | Lenny Maiorani <lenny@colorado.edu> | 2011-04-28 19:31:12 +0000 |
---|---|---|
committer | Lenny Maiorani <lenny@colorado.edu> | 2011-04-28 19:31:12 +0000 |
commit | 401549d71fdbc8a566c1eb71d30825de653ea5c4 (patch) | |
tree | 8e020ba149d8b69984bd3b30574ee94fd0b64ee8 /lib/StaticAnalyzer/Checkers/CStringChecker.cpp | |
parent | 295163797a75c7c8b1f4b21fa7ac4a200bff9395 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130425 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Checkers/CStringChecker.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Checkers/CStringChecker.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/StaticAnalyzer/Checkers/CStringChecker.cpp b/lib/StaticAnalyzer/Checkers/CStringChecker.cpp index 534b887f3b..a6a256a87b 100644 --- a/lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -1190,7 +1190,14 @@ void CStringChecker::evalStrcmpCommon(CheckerContext &C, const CallExpr *CE, // 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. |