[PATCH] Fix replacements for files with relative paths are not applied.

Manuel Klimek klimek at google.com
Sat Oct 5 02:06:19 PDT 2013



================
Comment at: lib/Tooling/Refactoring.cpp:108
@@ -107,4 +107,3 @@
   const FileEntry *Entry = Sources.getFileEntryForID(DecomposedLocation.first);
-
-  if (Entry != NULL) {
+  if (Entry != NULL)
     // Make FilePath absolute so replacements can be applied correctly when
----------------
I'd always use {} if there's a more complex statement inside.

================
Comment at: lib/Tooling/Refactoring.cpp:112
@@ +111,3 @@
+    // files.
+    if (Sources.getFileManager().isFileVirtual(Entry->getName())) {
+      this->FilePath = Entry->getName();
----------------
Can't we instead just check whether the relative file exists?
If the file is relative, and it can be accessed via the filesystem, use make_absolute; otherwise, simply use the entry name.

================
Comment at: include/clang/Basic/FileManager.h:278
@@ +277,3 @@
+  /// \brief Check if a FilePath is a virtual file that we have allocated.
+  bool isFileVirtual(StringRef FilePath);
+
----------------
If we decided we need this (see further down), this'll need approval from Doug...


http://llvm-reviews.chandlerc.com/D1800



More information about the cfe-commits mailing list