[clangd] Attempt to fix failing Windows buildbots.
authorIlya Biryukov <ibiryukov@google.com>
Mon, 9 Sep 2019 17:03:49 +0000 (17:03 +0000)
committerIlya Biryukov <ibiryukov@google.com>
Mon, 9 Sep 2019 17:03:49 +0000 (17:03 +0000)
The assertion is failing on Windows, probably because path separator is different.

For the failure see:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/28072/steps/test/logs/stdio

llvm-svn: 371422

clang-tools-extra/clangd/index/CanonicalIncludes.cpp

index aee6e3fd92359d2b175a74f20b674c67c01bd5e2..4f9d2f253d4a96f17e8fa9365febf3a20b8dd906 100644 (file)
@@ -47,6 +47,7 @@ CanonicalIncludes::mapHeader(llvm::StringRef Header,
 
   int Components = 1;
 
+  // FIXME: check that this works on Windows and add tests.
   for (auto It = llvm::sys::path::rbegin(Header),
             End = llvm::sys::path::rend(Header);
        It != End && Components <= MaxSuffixComponents; ++It, ++Components) {
@@ -759,12 +760,14 @@ void CanonicalIncludes::addSystemHeadersMapping(const LangOptions &Language) {
   });
   // Check MaxSuffixComponents constant is correct.
   assert(llvm::all_of(SystemHeaderMap->keys(), [](llvm::StringRef Path) {
-    return std::distance(llvm::sys::path::begin(Path),
-                         llvm::sys::path::end(Path)) <= MaxSuffixComponents;
+    return std::distance(
+               llvm::sys::path::begin(Path, llvm::sys::path::Style::posix),
+               llvm::sys::path::end(Path)) <= MaxSuffixComponents;
   }));
   // ... and precise.
   assert(llvm::find_if(SystemHeaderMap->keys(), [](llvm::StringRef Path) {
-           return std::distance(llvm::sys::path::begin(Path),
+           return std::distance(llvm::sys::path::begin(
+                                    Path, llvm::sys::path::Style::posix),
                                 llvm::sys::path::end(Path)) ==
                   MaxSuffixComponents;
          }) != SystemHeaderMap->keys().end());