[Lldb-commits] [PATCH] FileSpec::Resolve should not turn a filename-only FileSpec into a qualified FileSpec if that file doesn't exist

Zachary Turner zturner at google.com
Tue Feb 17 17:49:27 PST 2015


REPOSITORY
  rL LLVM

================
Comment at: source/Host/common/FileSpec.cpp:173
@@ +172,3 @@
+    
+    path.push_back(0);  // Be sure we have a nul terminated string
+    path.pop_back();
----------------
nit: s/nul/null/

================
Comment at: source/Host/common/FileSpec.cpp:179-180
@@ +178,4 @@
+        path.clear();
+        path.resize (original_path.size());
+        memcpy (path.data(), original_path.data(), original_path.size());
+    }
----------------
After you call path.clear(), the length is 0.  So you can change these two lines to path.append(original_path.begin(), original_path.end()).  I think path = original_path will also work.

================
Comment at: test/functionalities/paths/TestPaths.py:32-35
@@ +31,6 @@
+    def test_filespec_resolve_doesnt_prepend_cwd_if_file_doesnt_exist (self):
+        file_only = lldb.SBFileSpec("VeryUnlikelToExistInTheCurrentWorkingDirectory", True)
+        # SBFileSpec(path, True) should not prepend the current-working-directory to the
+        # file path if it doesn't exist in the current directory.
+        self.assertTrue (file_only.GetDirectory() == None)
+
----------------
Admittedly this is pretty unlikely.  You might be able to make it a *tad* better by using tempfile.mktemp() to generate the name of a file which definitely doesn't exist in the current directory.  then using something from os.path to strip the directory name from it, and then passing that.  I don't feel too strongly though.

http://reviews.llvm.org/D7477

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the lldb-commits mailing list