r224164 - Frontend: Canonicalize to native paths when dumping module dependencies

Justin Bogner mail at justinbogner.com
Fri Dec 12 15:12:27 PST 2014


Author: bogner
Date: Fri Dec 12 17:12:27 2014
New Revision: 224164

URL: http://llvm.org/viewvc/llvm-project?rev=224164&view=rev
Log:
Frontend: Canonicalize to native paths when dumping module dependencies

Mixed path separators (ie, both / and \\) can mess up the sort order
of the VFS map when dumping module dependencies, as was recently
exposed by r224055 and papered over in r224145. Instead, we should
simply use native paths for consistency.

This also adds a TODO to add handling of .. in paths. There was some
code for this before r224055, but it was untested and probably broken.

Modified:
    cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
    cfe/trunk/test/Modules/dependency-dump.m

Modified: cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp?rev=224164&r1=224163&r2=224164&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp (original)
+++ cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp Fri Dec 12 17:12:27 2014
@@ -63,6 +63,10 @@ std::error_code ModuleDependencyListener
   // We need an absolute path to append to the root.
   SmallString<256> AbsoluteSrc = Src;
   fs::make_absolute(AbsoluteSrc);
+  // Canonicalize to a native path to avoid mixed separator styles.
+  path::native(AbsoluteSrc);
+  // TODO: We probably need to handle .. as well as . in order to have valid
+  // input to the YAMLVFSWriter.
   FileManager::removeDotPaths(AbsoluteSrc);
 
   // Build the destination path.

Modified: cfe/trunk/test/Modules/dependency-dump.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/dependency-dump.m?rev=224164&r1=224163&r2=224164&view=diff
==============================================================================
--- cfe/trunk/test/Modules/dependency-dump.m (original)
+++ cfe/trunk/test/Modules/dependency-dump.m Fri Dec 12 17:12:27 2014
@@ -6,10 +6,10 @@
 // expected-no-diagnostics
 
 // RUN: FileCheck %s -check-prefix=VFS -input-file %t/vfs/vfs.yaml
-// VFS-DAG: 'name': "SubFramework.h"
-// VFS-DAG: 'name': "Treasure.h"
-// VFS-DAG: 'name': "Module.h"
-// VFS-DAG: 'name': "Sub.h"
-// VFS-DAG: 'name': "Sub2.h"
+// VFS: 'name': "SubFramework.h"
+// VFS: 'name': "Treasure.h"
+// VFS: 'name': "Module.h"
+// VFS: 'name': "Sub.h"
+// VFS: 'name': "Sub2.h"
 
 @import Module;





More information about the cfe-commits mailing list