diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-09-07 23:13:11 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-09-07 23:13:11 +0000 |
commit | ec5fda4dedbc249b61be032f710e8c9d6396fee8 (patch) | |
tree | ffb48b56725737550b1b8e7085370f86053bf4b9 /lib/StaticAnalyzer/Core/PathDiagnostic.cpp | |
parent | c80ca020300f6f4ecc595cca1e6cb93af76a4434 (diff) |
Further tweaks to hopefully make the PathDiagnostic emission more deterministic.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163430 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/PathDiagnostic.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Core/PathDiagnostic.cpp | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/lib/StaticAnalyzer/Core/PathDiagnostic.cpp b/lib/StaticAnalyzer/Core/PathDiagnostic.cpp index 15a6635062..8b0fc8eda7 100644 --- a/lib/StaticAnalyzer/Core/PathDiagnostic.cpp +++ b/lib/StaticAnalyzer/Core/PathDiagnostic.cpp @@ -217,10 +217,8 @@ static llvm::Optional<bool> comparePiece(PathDiagnosticPiece &X, } FullSourceLoc XL = X.getLocation().asLocation(); FullSourceLoc YL = Y.getLocation().asLocation(); - if (XL < YL) - return true; - if (YL < XL) - return false; + if (XL != YL) + return XL < YL; const std::string &XS = X.getString(); const std::string &YS = Y.getString(); if (XS != YS) @@ -229,10 +227,8 @@ static llvm::Optional<bool> comparePiece(PathDiagnosticPiece &X, } static bool comparePathPieces(const PathPieces &X, const PathPieces &Y) { - if (X.size() < Y.size()) - return true; - if (X.size() > Y.size()) - return false; + if (X.size() != Y.size()) + return X.size() < Y.size(); // Compare individual parts of the path. assert(X.size() == Y.size()); for (unsigned i = 0, n = X.size(); i < n; ++i) { @@ -249,26 +245,20 @@ struct CompareDiagnostics { // First compare by location const FullSourceLoc &XLoc = X->getLocation().asLocation(); const FullSourceLoc &YLoc = Y->getLocation().asLocation(); - if (XLoc < YLoc) - return true; - if (YLoc < XLoc) - return false; + if (XLoc != YLoc) + return XLoc < YLoc; // Next, compare by bug type. StringRef XBugType = X->getBugType(); StringRef YBugType = Y->getBugType(); - if (XBugType < YBugType) - return true; if (XBugType != YBugType) - return false; + return XBugType < YBugType; // Next, compare by bug description. StringRef XDesc = X->getVerboseDescription(); StringRef YDesc = Y->getVerboseDescription(); - if (XDesc < YDesc) - return true; if (XDesc != YDesc) - return false; + return XDesc < YDesc; // Fall back to comparing path pieces. return comparePathPieces(X->path, Y->path); |