]> granicus.if.org Git - clang/commitdiff
Frontend: Canonicalize to native paths when dumping module dependencies
authorJustin Bogner <mail@justinbogner.com>
Fri, 12 Dec 2014 23:12:27 +0000 (23:12 +0000)
committerJustin Bogner <mail@justinbogner.com>
Fri, 12 Dec 2014 23:12:27 +0000 (23:12 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224164 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/ModuleDependencyCollector.cpp
test/Modules/dependency-dump.m

index 1ac7e36eff1f35fe4fae6a2bef02d49439e9a698..8e2ee55bcaa07c40f0ea167d409a2427231c7faa 100644 (file)
@@ -63,6 +63,10 @@ std::error_code ModuleDependencyListener::copyToRoot(StringRef Src) {
   // 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.
index e3d8b3796441e8a10dbc3db1b900a9544f74807b..630af4950c186710655937036853ac957793a634 100644 (file)
@@ -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;