[cfe-commits] r163445 - /cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp

Ted Kremenek kremenek at apple.com
Fri Sep 7 18:24:54 PDT 2012


Author: kremenek
Date: Fri Sep  7 20:24:53 2012
New Revision: 163445

URL: http://llvm.org/viewvc/llvm-project?rev=163445&view=rev
Log:
Revert "Further tweaks to hopefully make the PathDiagnostic emission more deterministic."

Modified:
    cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp?rev=163445&r1=163444&r2=163445&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp Fri Sep  7 20:24:53 2012
@@ -217,8 +217,10 @@
   }
   FullSourceLoc XL = X.getLocation().asLocation();
   FullSourceLoc YL = Y.getLocation().asLocation();
-  if (XL != YL)
-    return XL < YL;
+  if (XL < YL)
+    return true;
+  if (YL < XL)
+    return false;
   const std::string &XS = X.getString();
   const std::string &YS = Y.getString();
   if (XS != YS)
@@ -227,8 +229,10 @@
 }
   
 static bool comparePathPieces(const PathPieces &X, const PathPieces &Y) {
-  if (X.size() != Y.size())
-    return X.size() < Y.size();
+  if (X.size() < Y.size())
+    return true;
+  if (X.size() > Y.size())
+    return false;
   // Compare individual parts of the path.
   assert(X.size() == Y.size());
   for (unsigned i = 0, n = X.size(); i < n; ++i) {
@@ -245,20 +249,26 @@
     // First compare by location
     const FullSourceLoc &XLoc = X->getLocation().asLocation();
     const FullSourceLoc &YLoc = Y->getLocation().asLocation();
-    if (XLoc != YLoc)
-      return XLoc < YLoc;
+    if (XLoc < YLoc)
+      return true;
+    if (YLoc < XLoc)
+      return false;
     
     // Next, compare by bug type.
     StringRef XBugType = X->getBugType();
     StringRef YBugType = Y->getBugType();
+    if (XBugType < YBugType)
+      return true;
     if (XBugType != YBugType)
-      return XBugType < YBugType;
+      return false;
     
     // Next, compare by bug description.
     StringRef XDesc = X->getVerboseDescription();
     StringRef YDesc = Y->getVerboseDescription();
+    if (XDesc < YDesc)
+      return true;
     if (XDesc != YDesc)
-      return XDesc < YDesc;
+      return false;
     
     // Fall back to comparing path pieces.
     return comparePathPieces(X->path, Y->path);





More information about the cfe-commits mailing list