[llvm-cov] Check path emptyness in path-equivalence after removing dots.
authorZequan Wu <zequanwu@google.com>
Thu, 25 Mar 2021 00:54:26 +0000 (17:54 -0700)
committerZequan Wu <zequanwu@google.com>
Thu, 25 Mar 2021 00:54:38 +0000 (17:54 -0700)
llvm/tools/llvm-cov/CodeCoverage.cpp

index 712766ec992937ad2e6ed813c7fda8e3b1bdbf19..144f338b10ed97c5f57b5c30fa7dbd6390a96d1f 100644 (file)
@@ -475,7 +475,7 @@ void CodeCoverageTool::remapPathNames(const CoverageMapping &Coverage) {
     SmallString<128> NativePath;
     sys::path::native(Path, NativePath);
     sys::path::remove_dots(NativePath, true);
-    if (!sys::path::is_separator(NativePath.back()))
+    if (!NativePath.empty() && !sys::path::is_separator(NativePath.back()))
       NativePath += sys::path::get_separator();
     return NativePath.c_str();
   };