This is an archive of the discontinued LLVM Phabricator instance.

Make FileSpec handling platform-independent
ClosedPublic

Authored by labath on Apr 1 2016, 4:21 AM.

Details

Summary

Even though FileSpec attempted to handle both kinds of path syntaxes (posix and windows) on both
platforms, it relied on the llvm path library to do its work, whose behavior differed on
different platforms. This led to subtle differences in FileSpec behavior between platforms. This
replaces the pieces of the llvm library with our own implementations. The functions are simply
copied from llvm, with #ifdefs replaced by runtime checks for ePathSyntaxWindows.

Diff Detail

Repository
rL LLVM

Event Timeline

labath updated this revision to Diff 52348.Apr 1 2016, 4:21 AM
labath retitled this revision from to Make FileSpec handling platform-independent.
labath updated this object.
labath added a reviewer: zturner.
labath added a subscriber: lldb-commits.
zturner edited edge metadata.Apr 1 2016, 3:02 PM

Ugh. The only better way I can think of to do this would be to go into LLVM and rip out all the preprocessor defines, and compile _windows and _posix versions of every function unconditionally, and then only use the preprocessor defines to do something like:

#if defined(LLVM_ON_WIN32)
    #define parent_path parent_path_windows
#else
    #define parent_path parent_path_posix
#endif

But... That's a lot of effort to go through. So while this code duplication isn't really that desirable, I guess it's ok given the amount of effort of the alternative.

zturner accepted this revision.Apr 1 2016, 3:02 PM
zturner edited edge metadata.
This revision is now accepted and ready to land.Apr 1 2016, 3:02 PM
This revision was automatically updated to reflect the committed changes.