[clang-scan-deps] remove dots and dots dots from the reported file dependency paths
authorAlex Lorenz <arphaman@gmail.com>
Thu, 12 Sep 2019 18:03:24 +0000 (18:03 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Thu, 12 Sep 2019 18:03:24 +0000 (18:03 +0000)
This resolves differences observed on LLVM + Clang when running the comparison between canonical
dependencies (full preprocessing, no file manager reused), and dependencies obtained
when the file manager was reused between the full preprocessing invocations.

llvm-svn: 371751

clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
clang/test/ClangScanDeps/Inputs/subframework_header_dir_symlink_cdb.json

index f609607..f382c20 100644 (file)
@@ -30,8 +30,12 @@ public:
       : DependencyFileGenerator(*Opts), Opts(std::move(Opts)), C(C) {}
 
   void finishedMainFile(DiagnosticsEngine &Diags) override {
-    for (const auto &File : getDependencies())
-      C.handleFileDependency(*Opts, File);
+    llvm::SmallString<256> CanonPath;
+    for (const auto &File : getDependencies()) {
+      CanonPath = File;
+      llvm::sys::path::remove_dots(CanonPath, /*remove_dot_dot=*/true);
+      C.handleFileDependency(*Opts, CanonPath);
+    }
   }
 
 private:
index e458b5c..82c6b7c 100644 (file)
@@ -6,7 +6,7 @@
 },
 {
   "directory": "DIR",
-  "command": "clang -E DIR/subframework_header_dir_symlink_input2.m -FInputs/frameworks -iframework Inputs/frameworks_symlink",
+  "command": "clang -E DIR/subframework_header_dir_symlink_input2.m -FInputs/frameworks -iframework Inputs/frameworks_symlink/../frameworks_symlink",
   "file": "DIR/subframework_header_dir_symlink_input2.m"
 }
 ]