llvm / llvm/llvm-project

[Support] Reconsider sys::path::native() semantics for POSIX paths

Open
#207,885 1 comment 0 reactions 0 assignees View on GitHub
llvm:support
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

`llvm::sys::path::native()` currently rewrites backslashes to forward slashes on POSIX platforms.

That behavior is documented, but it is easy to misuse for real POSIX filesystem paths because `\` is a valid filename character on POSIX, not a path separator. For example, a POSIX path like:

```text
a\b.cc
```

names a file whose filename contains a literal backslash. After `sys::path::native()`, it becomes:

```text
a/b.cc
```

which names a different path.

Should we clarify, discourage, or eventually deprecate `sys::path::native()` for real filesystem paths on POSIX?

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the documented contract for llvm::sys::path::native() and its POSIX behavior. Compare the literal-backslash example with intended filesystem-path use; done means deciding whether to clarify, discourage, or deprecate this behavior.

Written by the indexing model from the issue text.

Assessment

Domain
operating-systems
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.