Page MenuHomePhabricator

Use LLVM's directory enumeration code
ClosedPublic

Authored by zturner on Mar 9 2017, 8:26 PM.

Details

Summary

FileSpec::EnumerateDirectory has a bunch of platform-specific gunk in it for posix and non-posix platforms. We can get rid of all this by using LLVM's easy-to-use directory iterators.

Ideally I would like to just remove this entire EnumerateDirectory function. It served a useful purpose when the code for iterating directories would have to be re-invented every single time otherwise, but since we have these nice iterators, this intermediate enumerator function actually makes the code more verbose, since we have to set up this baton and return these magic values from the callback function, when usually this just means "be recursive" or "don't be recursive", something the writer of the algorithm could more cleanly express by simply choosing recursive_directory_iterator or directory_iterator. Anyway, I'm getting ahead of myself. For now just clean up this function and leave everything else as-is.

Diff Detail

Repository
rL LLVM

Event Timeline

zturner created this revision.Mar 9 2017, 8:26 PM
labath edited edge metadata.Mar 10 2017, 2:27 AM
lldb/source/Host/common/FileSpec.cpp
786 ↗(On Diff #91260)

This looks like it changes behavior. Previously, if find_directories was false this function would *not* recurse into them, whereas now it will. I guess you did not intend to do that (?)

labath accepted this revision.Mar 10 2017, 11:17 AM
This revision is now accepted and ready to land.Mar 10 2017, 11:17 AM
This revision was automatically updated to reflect the committed changes.