Skip to content

Commit 4207ffe

Browse files
committed
[llvm-readtapi] Make directory traversal more reslient to different path
styles
1 parent 9359df8 commit 4207ffe

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

llvm/tools/llvm-readtapi/llvm-readtapi.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,16 +255,21 @@ static void stubifyDirectory(const StringRef InputPath, Context &Ctx) {
255255
if (EC)
256256
reportError(IT->path() + ": " + EC.message());
257257

258-
// Skip header directories (include/Headers/PrivateHeaders) and module
259-
// files.
258+
// Skip header directories (include/Headers/PrivateHeaders).
260259
StringRef Path = IT->path();
261-
if (Path.ends_with("/include") || Path.ends_with("/Headers") ||
262-
Path.ends_with("/PrivateHeaders") || Path.ends_with("/Modules") ||
263-
Path.ends_with(".map") || Path.ends_with(".modulemap")) {
264-
IT.no_push();
265-
continue;
260+
if (sys::fs::is_directory(Path)) {
261+
const StringRef Stem = sys::path::stem(Path);
262+
if ((Stem == "include") || (Stem == "Headers") ||
263+
(Stem == "PrivateHeaders") || (Stem == "Modules")) {
264+
IT.no_push();
265+
continue;
266+
}
266267
}
267268

269+
// Skip module files too.
270+
if (Path.ends_with(".map") || Path.ends_with(".modulemap"))
271+
continue;
272+
268273
// Check if the entry is a symlink. We don't follow symlinks but we record
269274
// their content.
270275
bool IsSymLink;

0 commit comments

Comments
 (0)