diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2018-11-12 22:32:38 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2018-11-12 22:32:38 +0000 |
commit | 6d2d7b776c65f587cabd8e1cb54e8084f8ae4a18 (patch) | |
tree | 1710c4ef2503a2cc3dc00f45d4e99d7c49d53914 | |
parent | f78993129b8de5baafb0d90aa59747d480be915d (diff) |
Convert a condition into an assertion per post-review feedback; NFC intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@346714 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/StaticAnalyzer/Core/SarifDiagnostics.cpp | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp b/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp index a6977d23c2..ee86195758 100644 --- a/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp +++ b/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp @@ -83,26 +83,25 @@ static std::string fileNameToURI(StringRef Filename) { } 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; - - // 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); - } - }); - } + 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 += "/"; + + // URI encode the part. + for (char C : Component) { + Ret += percentEncodeURICharacter(C); + } + }); return Ret.str().str(); } |