Skip to content

Commit

Permalink
[clang][tools] Remove path separator assumption
Browse files Browse the repository at this point in the history
After 98e6deb the 'HeadersForSymbolTest.IWYUTransitiveExportWithPrivate' test in 'ClangIncludeCleanerTest' started failing. This is most likely because `FileEntryRef::getName()` now starts with ".\" on Windows, whereas `FileEntry::getName()` did not. This commit fixes assumption of forward slash separators.
  • Loading branch information
jansvoboda11 committed Sep 9, 2023
1 parent 60c0d30 commit eea232d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ llvm::SmallVector<Header> ranked(llvm::SmallVector<Hinted<Header>> Headers) {
// name.
llvm::StringRef basename(llvm::StringRef Header) {
Header = Header.trim("<>\"");
if (auto LastSlash = Header.rfind('/'); LastSlash != Header.npos)
Header = Header.drop_front(LastSlash + 1);
Header = llvm::sys::path::filename(Header);
// Drop everything after first `.` (dot).
// foo.h -> foo
// foo.cu.h -> foo
Expand Down

0 comments on commit eea232d

Please sign in to comment.