[cfe-dev] patch for improving Clang's virtual file handling
Douglas Gregor
dgregor at apple.com
Fri Feb 11 10:41:42 PST 2011
On Feb 11, 2011, at 10:38 AM, Zhanyong Wan (λx.x x) wrote:
> Thanks, Doug!
>
> 2011/2/10 Douglas Gregor <dgregor at apple.com>:
>> Hi Zhanyong,
>>
>> Your patch looks good to me. Did you consider using the functionality in llvm::sys::path to handle the parsing of path names, rather than hand-coding string algorithm such as
>>
>> +void FileManager::addAncestorsAsVirtualDirs(llvm::StringRef Path) {
>> + size_t SlashPos = Path.size();
>> +
>> + // Find the beginning of the last segment in Path.
>> + while (SlashPos != 0 && !IS_DIR_SEPARATOR_CHAR(Path[SlashPos-1]))
>> + --SlashPos;
>> +
>> + // Ignore repeated //'s.
>> + while (SlashPos != 0 && IS_DIR_SEPARATOR_CHAR(Path[SlashPos-1]))
>> + --SlashPos;
>> +
>> + if (SlashPos == 0)
>> + return;
>
> I wasn't aware of llvm::sys::path, so I just followed what the
> existing code in FileManager was doing. I like the idea of switching
> to llvm::sys::path.
>
> May I commit the patch as is and send you a separate one for using
> llvm::sys::path? Thanks,
Yes, that's fine. Thanks!
- Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110211/f82f7cc5/attachment.html>
More information about the cfe-dev
mailing list