[llvm-commits] CVS: llvm/include/llvm/System/Path.h

Chris Lattner clattner at apple.com
Thu Mar 29 23:28:18 PDT 2007


On Mar 29, 2007, at 11:17 PM, Reid Spencer wrote:

> On Thu, 2007-03-29 at 22:59 -0700, Chris Lattner wrote:
>>>
>>> For PR789: http://llvm.org/PR789 :
>>> * Add a method: bool isAbsolute() const, which determines if the
>>> path name
>>>   is absolute or not.
>>> * Implement caching of file status information in the Path object.
>>> Allow it
>>>   to be updated forcefully or lazily re-fetched from the cached  
>>> value.
>>
>> Nice.  Instead of new'ing the status object separately from the Path
>> object, why not embed it by-value?
>
> Because, by far, the common case for Path objects is to copy them  
> around
> and not use the FileStatus stuff.  I even hesitated about putting a
> pointer into the Path object. :)

Okay, how about an alternate approach, which fixes both problems :),  
how about something like this:

class PathWithStatus : public Path {
   Status S;
   bool IsStatusValid;
}

If you sink the 'status gathering' methods out of Path into  
PathWithStatus, then you let the client decide whether they want to  
store a status or not.

reasonable?

-Chris



More information about the llvm-commits mailing list