r265622 - [CrashReproducer] Setup 'case-sensitive' in YAML files.

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 6 17:00:57 PDT 2016


Author: bruno
Date: Wed Apr  6 19:00:57 2016
New Revision: 265622

URL: http://llvm.org/viewvc/llvm-project?rev=265622&view=rev
Log:
[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.

Modified:
    cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
    cfe/trunk/test/Modules/crash-vfs-relative-overlay.m

Modified: cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp?rev=265622&r1=265621&r2=265622&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp (original)
+++ cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp Wed Apr  6 19:00:57 2016
@@ -79,19 +79,42 @@ void ModuleDependencyCollector::attachTo
       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;

Modified: cfe/trunk/test/Modules/crash-vfs-relative-overlay.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-relative-overlay.m?rev=265622&r1=265621&r2=265622&view=diff
==============================================================================
--- cfe/trunk/test/Modules/crash-vfs-relative-overlay.m (original)
+++ cfe/trunk/test/Modules/crash-vfs-relative-overlay.m Wed Apr  6 19:00:57 2016
@@ -36,6 +36,8 @@
 // CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml"
 // CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/modules"
 
+// CHECKYAML: 'case-sensitive':
+// CHECKYAML-NEXT: 'overlay-relative': 'true',
 // CHECKYAML: 'type': 'directory'
 // CHECKYAML: 'name': "/[[PATH:.*]]/Inputs/crash-recovery/usr/include",
 // CHECKYAML-NEXT: 'contents': [




More information about the cfe-commits mailing list