[clang-tools-extra] eea232d - [clang][tools] Remove path separator assumption
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 9 11:38:38 PDT 2023
Author: Jan Svoboda
Date: 2023-09-09T11:38:32-07:00
New Revision: eea232da827abae1a4fd71a0fb1f4d239d7b2f6a
URL: https://github.com/llvm/llvm-project/commit/eea232da827abae1a4fd71a0fb1f4d239d7b2f6a
DIFF: https://github.com/llvm/llvm-project/commit/eea232da827abae1a4fd71a0fb1f4d239d7b2f6a.diff
LOG: [clang][tools] Remove path separator assumption
After 98e6deb6 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.
Added:
Modified:
clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
index 0f91ad57f0c51d3..06e5e1812ba7218 100644
--- a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
+++ b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
@@ -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
More information about the cfe-commits
mailing list