r346714 - Convert a condition into an assertion per post-review feedback; NFC intended.

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 12 14:32:38 PST 2018


Author: aaronballman
Date: Mon Nov 12 14:32:38 2018
New Revision: 346714

URL: http://llvm.org/viewvc/llvm-project?rev=346714&view=rev
Log:
Convert a condition into an assertion per post-review feedback; NFC intended.

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

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp?rev=346714&r1=346713&r2=346714&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp Mon Nov 12 14:32:38 2018
@@ -83,26 +83,25 @@ static std::string fileNameToURI(StringR
   }
 
   auto Iter = sys::path::begin(Filename), End = sys::path::end(Filename);
-  if (Iter != End) {
-    // Add the rest of the path components, encoding any reserved characters;
-    // we skip past the first path component, as it was handled it above.
-    std::for_each(++Iter, End, [&Ret](StringRef Component) {
-      // For reasons unknown to me, we may get a backslash with Windows native
-      // paths for the initial backslash following the drive component, which
-      // we need to ignore as a URI path part.
-      if (Component == "\\")
-        return;
+  assert(Iter != End && "Expected there to be a non-root path component.");
+  // Add the rest of the path components, encoding any reserved characters;
+  // we skip past the first path component, as it was handled it above.
+  std::for_each(++Iter, End, [&Ret](StringRef Component) {
+    // For reasons unknown to me, we may get a backslash with Windows native
+    // paths for the initial backslash following the drive component, which
+    // we need to ignore as a URI path part.
+    if (Component == "\\")
+      return;
 
-      // Add the separator between the previous path part and the one being
-      // currently processed.
-      Ret += "/";
+    // Add the separator between the previous path part and the one being
+    // currently processed.
+    Ret += "/";
 
-      // URI encode the part.
-      for (char C : Component) {
-        Ret += percentEncodeURICharacter(C);
-      }
-    });
-  }
+    // URI encode the part.
+    for (char C : Component) {
+      Ret += percentEncodeURICharacter(C);
+    }
+  });
 
   return Ret.str().str();
 }




More information about the cfe-commits mailing list