summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/ModuleDependencyCollector.cpp
diff options
context:
space:
mode:
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>2016-04-07 00:00:57 +0000
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>2016-04-07 00:00:57 +0000
commit4c20bef1ef1d29e8824dbf68ee91f072dd1b2f09 (patch)
treef42f9bb4c997e8d7233b73da70777e2c8ab36a69 /clang/lib/Frontend/ModuleDependencyCollector.cpp
parent7caebc182a90dda7ed698f0b4c889860f15422a1 (diff)
downloadbcm5719-llvm-4c20bef1ef1d29e8824dbf68ee91f072dd1b2f09.tar.gz
bcm5719-llvm-4c20bef1ef1d29e8824dbf68ee91f072dd1b2f09.zip
[CrashReproducer] Setup 'case-sensitive' in YAML files.
The crash reproducer was not setting up case sensitivity in the VFS yaml files, which defaults to true. Make the crash reproducer explicitly set that flag based on the case sensitivity of the .cache path where vfs and modules are dumped. llvm-svn: 265622
Diffstat (limited to 'clang/lib/Frontend/ModuleDependencyCollector.cpp')
-rw-r--r--clang/lib/Frontend/ModuleDependencyCollector.cpp31
1 files changed, 27 insertions, 4 deletions
diff --git a/clang/lib/Frontend/ModuleDependencyCollector.cpp b/clang/lib/Frontend/ModuleDependencyCollector.cpp
index d9cf40af0f6..1678d1801d2 100644
--- a/clang/lib/Frontend/ModuleDependencyCollector.cpp
+++ b/clang/lib/Frontend/ModuleDependencyCollector.cpp
@@ -79,19 +79,42 @@ void ModuleDependencyCollector::attachToPreprocessor(Preprocessor &PP) {
llvm::make_unique<ModuleDependencyMMCallbacks>(*this));
}
+static bool isCaseSensitivePath(StringRef Path) {
+ SmallString<PATH_MAX> TmpDest = Path, UpperDest, RealDest;
+ // Remove component traversals, links, etc.
+ if (!real_path(Path, TmpDest))
+ return true; // Current default value in vfs.yaml
+ Path = TmpDest;
+
+ // Change path to all upper case and ask for its real path, if the latter
+ // exists and is equal to Path, it's not case sensitive. Default to case
+ // sensitive in the absense of realpath, since this is what the VFSWriter
+ // already expects when sensitivity isn't setup.
+ for (auto &C : Path)
+ UpperDest.push_back(std::toupper(C));
+ if (real_path(UpperDest, RealDest) && Path.equals(RealDest))
+ return false;
+ return true;
+}
+
void ModuleDependencyCollector::writeFileMap() {
if (Seen.empty())
return;
- SmallString<256> Dest = getDest();
- llvm::sys::path::append(Dest, "vfs.yaml");
+ StringRef VFSDir = getDest();
// Default to use relative overlay directories in the VFS yaml file. This
// allows crash reproducer scripts to work across machines.
- VFSWriter.setOverlayDir(getDest());
+ VFSWriter.setOverlayDir(VFSDir);
+
+ // Explicitly set case sensitivity for the YAML writer. For that, find out
+ // the sensitivity at the path where the headers all collected to.
+ VFSWriter.setCaseSensitivity(isCaseSensitivePath(VFSDir));
std::error_code EC;
- llvm::raw_fd_ostream OS(Dest, EC, llvm::sys::fs::F_Text);
+ SmallString<256> YAMLPath = VFSDir;
+ llvm::sys::path::append(YAMLPath, "vfs.yaml");
+ llvm::raw_fd_ostream OS(YAMLPath, EC, llvm::sys::fs::F_Text);
if (EC) {
HasErrors = true;
return;
OpenPOWER on IntegriCloud