]> granicus.if.org Git - clang/commitdiff
Fix PR31644 introduced by r287138 and add a regression test.
authorYaron Keren <yaron.keren@gmail.com>
Sat, 14 Jan 2017 21:12:08 +0000 (21:12 +0000)
committerYaron Keren <yaron.keren@gmail.com>
Sat, 14 Jan 2017 21:12:08 +0000 (21:12 +0000)
Thanks Dimitry Andric for the report and fix!

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

lib/Frontend/DependencyFile.cpp
test/Preprocessor/dependencies-and-pp.c

index 059f116a3c31abe9f499ebd45c8d76870a138b99..bd14c53e4d15f2adb23c86d7fb4f0eb8492e450f 100644 (file)
@@ -447,9 +447,9 @@ void DFGImpl::OutputDependencyFile() {
   // Create phony targets if requested.
   if (PhonyTarget && !Files.empty()) {
     // Skip the first entry, this is always the input file itself.
-    for (StringRef File : Files) {
+    for (auto I = Files.begin() + 1, E = Files.end(); I != E; ++I) {
       OS << '\n';
-      PrintFilename(OS, File, OutputFormat);
+      PrintFilename(OS, *I, OutputFormat);
       OS << ":\n";
     }
   }
index fb4963804093ee865623f0e5cf1b98f46a21465b..8bf32dc0fd654667c8220dc8a8582437c08c974b 100644 (file)
 // RUN: FileCheck -check-prefix=TEST5 %s < %t.d
 // TEST5: foo $$(bar) b az qu\ ux \ space:
 
+// Test self dependency, PR31644
+
+// RUN: %clang -E -MD -MP -MF %t.d %s
+// RUN: FileCheck -check-prefix=TEST6 %s < %t.d
+// TEST6: dependencies-and-pp.c
+// TEST6-NOT: dependencies-and-pp.c:
+
 // TODO: Test default target without quoting
 // TODO: Test default target with quoting