kfunk updated this revision to Diff 105929.
kfunk added a comment.

Remove unnecessary `sed` line in test driver


https://reviews.llvm.org/D35194

Files:
  clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
  test/clang-apply-replacements/invalid-files.cpp


Index: test/clang-apply-replacements/invalid-files.cpp
===================================================================
--- /dev/null
+++ test/clang-apply-replacements/invalid-files.cpp
@@ -0,0 +1,7 @@
+// RUN: mkdir -p %T/Inputs/invalid-files
+// RUN: clang-apply-replacements %T/Inputs/invalid-files
+//
+// Check that the yaml files are *not* deleted after running 
clang-apply-replacements without remove-change-desc-files.
+// RUN: ls -1 %T/Inputs/invalid-files | FileCheck %s --check-prefix=YAML
+//
+//// YAML: {{.+\.yaml$}}
Index: test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
===================================================================
--- /dev/null
+++ test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
@@ -0,0 +1,12 @@
+---
+MainSourceFile:  ''
+Replacements:
+  - FilePath:        idontexist.h
+    Offset:          2669
+    Length:          0
+    ReplacementText: ' override'
+  - FilePath:        idontexist.h
+    Offset:          2669
+    Length:          0
+    ReplacementText: ' override'
+...
Index: clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
===================================================================
--- clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -289,9 +289,11 @@
       // Use the file manager to deduplicate paths. FileEntries are
       // automatically canonicalized.
       const FileEntry *Entry = SM.getFileManager().getFile(R.getFilePath());
-      if (!Entry && Warned.insert(R.getFilePath()).second) {
-        errs() << "Described file '" << R.getFilePath()
-               << "' doesn't exist. Ignoring...\n";
+      if (!Entry) {
+        if (Warned.insert(R.getFilePath()).second) {
+          errs() << "Described file '" << R.getFilePath()
+                 << "' doesn't exist. Ignoring...\n";
+        }
         continue;
       }
       GroupedReplacements[Entry].push_back(R);
@@ -315,9 +317,11 @@
           // Use the file manager to deduplicate paths. FileEntries are
           // automatically canonicalized.
           const FileEntry *Entry = 
SM.getFileManager().getFile(R.getFilePath());
-          if (!Entry && Warned.insert(R.getFilePath()).second) {
-            errs() << "Described file '" << R.getFilePath()
-                   << "' doesn't exist. Ignoring...\n";
+          if (!Entry) {
+            if (Warned.insert(R.getFilePath()).second) {
+              errs() << "Described file '" << R.getFilePath()
+                     << "' doesn't exist. Ignoring...\n";
+            }
             continue;
           }
           GroupedReplacements[Entry].push_back(R);


Index: test/clang-apply-replacements/invalid-files.cpp
===================================================================
--- /dev/null
+++ test/clang-apply-replacements/invalid-files.cpp
@@ -0,0 +1,7 @@
+// RUN: mkdir -p %T/Inputs/invalid-files
+// RUN: clang-apply-replacements %T/Inputs/invalid-files
+//
+// Check that the yaml files are *not* deleted after running clang-apply-replacements without remove-change-desc-files.
+// RUN: ls -1 %T/Inputs/invalid-files | FileCheck %s --check-prefix=YAML
+//
+//// YAML: {{.+\.yaml$}}
Index: test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
===================================================================
--- /dev/null
+++ test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
@@ -0,0 +1,12 @@
+---
+MainSourceFile:  ''
+Replacements:
+  - FilePath:        idontexist.h
+    Offset:          2669
+    Length:          0
+    ReplacementText: ' override'
+  - FilePath:        idontexist.h
+    Offset:          2669
+    Length:          0
+    ReplacementText: ' override'
+...
Index: clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
===================================================================
--- clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -289,9 +289,11 @@
       // Use the file manager to deduplicate paths. FileEntries are
       // automatically canonicalized.
       const FileEntry *Entry = SM.getFileManager().getFile(R.getFilePath());
-      if (!Entry && Warned.insert(R.getFilePath()).second) {
-        errs() << "Described file '" << R.getFilePath()
-               << "' doesn't exist. Ignoring...\n";
+      if (!Entry) {
+        if (Warned.insert(R.getFilePath()).second) {
+          errs() << "Described file '" << R.getFilePath()
+                 << "' doesn't exist. Ignoring...\n";
+        }
         continue;
       }
       GroupedReplacements[Entry].push_back(R);
@@ -315,9 +317,11 @@
           // Use the file manager to deduplicate paths. FileEntries are
           // automatically canonicalized.
           const FileEntry *Entry = SM.getFileManager().getFile(R.getFilePath());
-          if (!Entry && Warned.insert(R.getFilePath()).second) {
-            errs() << "Described file '" << R.getFilePath()
-                   << "' doesn't exist. Ignoring...\n";
+          if (!Entry) {
+            if (Warned.insert(R.getFilePath()).second) {
+              errs() << "Described file '" << R.getFilePath()
+                     << "' doesn't exist. Ignoring...\n";
+            }
             continue;
           }
           GroupedReplacements[Entry].push_back(R);
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to