[Lldb-commits] [PATCH] D138348: [lldb] Fix SBFileSpec.fullpath

Dave Lee via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Nov 18 19:48:00 PST 2022


kastiglione created this revision.
kastiglione added reviewers: mib, labath.
Herald added a project: All.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Reimplement of `SBFileSpec.fullpath` to (indirectly) use `FileSpec::GetPath`.

Instead of hardcoding a `/` separator, use `GetPath`. This makes use of the `FileSpec`'s internal style, which for example allows for backslash on Windows where required.

It's not obvious from looking at the source, but the `fullpath` property is implemented with `str`, which calls `GetDescription`, which in finally calls `GetPath`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138348

Files:
  lldb/bindings/interface/SBFileSpec.i


Index: lldb/bindings/interface/SBFileSpec.i
===================================================================
--- lldb/bindings/interface/SBFileSpec.i
+++ lldb/bindings/interface/SBFileSpec.i
@@ -84,18 +84,7 @@
 
 #ifdef SWIGPYTHON
     %pythoncode %{
-        def __get_fullpath__(self):
-            spec_dir = self.GetDirectory()
-            spec_file = self.GetFilename()
-            if spec_dir and spec_file:
-                return '%s/%s' % (spec_dir, spec_file)
-            elif spec_dir:
-                return spec_dir
-            elif spec_file:
-                return spec_file
-            return None
-
-        fullpath = property(__get_fullpath__, None, doc='''A read only property that returns the fullpath as a python string.''')
+        fullpath = property(str, None, doc='''A read only property that returns the fullpath as a python string.''')
         basename = property(GetFilename, None, doc='''A read only property that returns the path basename as a python string.''')
         dirname = property(GetDirectory, None, doc='''A read only property that returns the path directory name as a python string.''')
         exists = property(Exists, None, doc='''A read only property that returns a boolean value that indicates if the file exists.''')


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138348.476651.patch
Type: text/x-patch
Size: 1280 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20221119/8e392970/attachment-0001.bin>


More information about the lldb-commits mailing list