Open zmodem opened 2 months ago
This also breaks -Wnonportable-include-path
:
#include <array>
#include <array >
#include <Array >
#include <Array>
> clang-cl clang-cl test.cpp -fsyntax-only
test.cpp(4,10): warning: non-portable path to file '<array>'; specified path differs in case from file name on disk
[-Wnonportable-include-path]
4 | #include <Array>
| ^~~~~~~
| <array>
1 warning generated.
We should probably extend -Wnonportable-include-path
to consider trailing spaces.
Dots at the end are ignored in the same way on Windows too:
// All of these include the same file
#include <Array >
#include <Array.>
#include <Array >
#include <Array..............>
#include <Array. >
#include <Array . . ... .>
Since these trailing spaces/dots are always removed when you specify a filename (except when prefixed by \\?\
), we could issue the warning before even opening the file
https://learn.microsoft.com/en-gb/windows/win32/fileio/naming-a-file#naming-conventions (There's probably a more authoritative source on how the file name is transformed, this one only says "Do not end a file or directory name with a space or a period.")
+1 extending -Wnonportable-include-path
for this sounds good!
Hi!
This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:
test/
create fine-grained testing targets, so you can e.g. use make check-clang-ast
to only run Clang's AST tests.git clang-format HEAD~1
to format your changes.If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.
@llvm/issue-subscribers-good-first-issue
Author: Hans (zmodem)
Let me understand the issue. You are saying
I am I right? I am new here. Trying to understand things @zmodem
I would like to work on this issue, can I get assigned please? @shafik
Consider:
Assuming
foo.h
exists, the code above will compile on Windows whose filesystem API generally ignores leading and trailing space in filenames. However it will not compile on stricter systems such as Linux.Maybe Clang should warn? It's niche, but also seems easy to do.
(Yes, we hit this in real code, https://chromium-review.googlesource.com/c/chromium/src/+/5641197)