[clang][deps] Ensure deterministic filename case
authorJan Svoboda <jan_svoboda@apple.com>
Thu, 7 Apr 2022 15:05:54 +0000 (17:05 +0200)
committerJan Svoboda <jan_svoboda@apple.com>
Fri, 8 Apr 2022 07:18:00 +0000 (09:18 +0200)
commitb672638dbc7cec9a51826520e8f8aef276bac3ee
treebf34555ac2879fc1ab241bfda7e555e231708a59
parentfc2d8326ae4d6e05c1aa2db7e7dbd8e759bf4d51
[clang][deps] Ensure deterministic filename case

The dependency scanner can reuse single FileManager instance across multiple translation units. This may lead to non-deterministic output depending on which TU gets processed first.

One of the problems is that Clang uses DirectoryEntry::getName in the header search algorithm. This function returns the path that was first used to construct the (shared) entry in FileManager. Using DirectoryEntryRef::getName instead preserves the case as it was spelled out for the current "get directory entry" request.

rdar://90647508

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D123229
clang/include/clang/Lex/DirectoryLookup.h
clang/lib/Lex/HeaderSearch.cpp
clang/test/ClangScanDeps/header-search-case-sensitivity.c [new file with mode: 0644]