diff options
| author | Aaron Ballman <aaron@aaronballman.com> | 2018-11-06 21:12:44 +0000 |
|---|---|---|
| committer | Aaron Ballman <aaron@aaronballman.com> | 2018-11-06 21:12:44 +0000 |
| commit | f3869cd14d93b72bb9799af614d2b38fff0f0ff8 (patch) | |
| tree | 94a0e66c3aa4bf7b826159c7e7f7bb39e5ce0f28 | |
| parent | 902fa411888e5c23c2a9ff7038947e5c5ee98c4e (diff) | |
| download | bcm5719-llvm-f3869cd14d93b72bb9799af614d2b38fff0f0ff8.tar.gz bcm5719-llvm-f3869cd14d93b72bb9799af614d2b38fff0f0ff8.zip | |
Don't use std::next() on an input iterator; NFC.
Instead, advance the old-fashioned way, as std::next() cannot be used on an input iterator until C++17.
llvm-svn: 346266
| -rw-r--r-- | clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp index db1550c63fd..448faa4a904 100644 --- a/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp +++ b/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp @@ -82,25 +82,27 @@ static std::string fileNameToURI(StringRef Filename) { Ret += Twine("/" + Root).str(); } - // Add the rest of the path components, encoding any reserved characters. - std::for_each(std::next(sys::path::begin(Filename)), sys::path::end(Filename), - [&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); - } - }); + 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); + } + }); + } return Ret.str().str(); } |

