Skip to content

Commit 9749c47

Browse files
committed
Use forward slashes for header paths
1 parent 69f6e74 commit 9749c47

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

clang-tools-extra/clangd/Headers.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,16 +304,17 @@ IncludeInserter::calculateIncludePath(const HeaderFile &InsertedHeader,
304304
// FIXME: should we allow (some limited number of) "../header.h"?
305305
if (llvm::sys::path::is_absolute(Suggested))
306306
return std::nullopt;
307+
auto HeaderPath = llvm::sys::path::convert_to_slash(InsertedHeader.File);
307308
bool IsAngled = false;
308309
for (auto &Filter : AngledHeaders) {
309-
if (Filter(InsertedHeader.File)) {
310+
if (Filter(HeaderPath)) {
310311
IsAngled = true;
311312
break;
312313
}
313314
}
314315
bool IsQuoted = false;
315316
for (auto &Filter : QuotedHeaders) {
316-
if (Filter(InsertedHeader.File)) {
317+
if (Filter(HeaderPath)) {
317318
IsQuoted = true;
318319
break;
319320
}
@@ -324,7 +325,7 @@ IncludeInserter::calculateIncludePath(const HeaderFile &InsertedHeader,
324325
if (IsAngled && IsQuoted) {
325326
elog("Header '{0}' matches both quoted and angled regexes, default will "
326327
"be used.",
327-
InsertedHeader.File);
328+
HeaderPath);
328329
}
329330
IsAngled = IsAngledByDefault;
330331
}

clang-tools-extra/clangd/unittests/HeadersTests.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,11 +348,7 @@ TEST_F(HeadersTest, ShortenIncludesInSearchPathBracketedFilterByFullPath) {
348348
// The filter receives the full path of the header, so it is able to filter by
349349
// the parent directory, even if it is part of the include search path
350350
AngledHeaders.push_back([](auto Path) {
351-
#if defined(_WIN32)
352-
llvm::Regex Pattern("sub\\.*");
353-
#else
354351
llvm::Regex Pattern("sub/.*");
355-
#endif
356352
return Pattern.match(Path);
357353
});
358354
std::string BarHeader = testPath("sub/bar.h");

0 commit comments

Comments
 (0)