Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys::Path enhancement: add PathWithStatus #1663

Closed
lattner opened this issue Mar 30, 2007 · 5 comments
Closed

sys::Path enhancement: add PathWithStatus #1663

lattner opened this issue Mar 30, 2007 · 5 comments
Labels
bugzilla Issues migrated from bugzilla code-cleanup enhancement Improving things as opposed to bug fixing, e.g. new or missing feature

Comments

@lattner
Copy link
Collaborator

lattner commented Mar 30, 2007

Bugzilla Link 1291
Resolution FIXED
Resolved on Feb 22, 2010 12:40
Version 1.0
OS MacOS X

Extended Description

Getting the status of a sys::path curently requires new'ing the status object. It would be nice if we
could make a subclass PathWithStatus, and move the 'status' related stuff there. This would give us
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, and if they want it, they don't have to pay for a separate malloc.

-Chris

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 7, 2007

This isn't quite trivial. A lot of regular "Path" methods depend on the ability
to get the file status. For example, the "isExecutable" method has to check both
the access bits and determine if its a regular file. The method wants to only
indicate true for executable files, not searchable directories. Consequently it
needs the stat information.

There are several other examples of these that I'm not quite sure how to
resolve. From an API perspective it doesn't make sense to move these methods to
PathWithStatus. From a performance perspective, it doesn't make sense to
instantiate a PathWithStatus temporarily in the body of such methods.

I'll work on this and come up with a solution.

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 7, 2007

The solution is to just use stat(2) directly. In all of these cases it would be
bad if we were using stale stat information so the "force udpate" parameter was
being passed to getFileStatus anyway which means that just using stat(2)
directly preserves current behavior and simplifies things a lot.

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 7, 2007

Implemented with these patches:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070402/046965.html
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070402/046966.html
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070402/046967.html

Jeff:
I think I got the Win32 part of this right, but it hasn't been compiled. Could
you please try it and verify on Win32?

@lattner
Copy link
Collaborator Author

lattner commented Apr 7, 2007

Question: why not move isExecutable etc to PathWithStatus?

-Chris

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 7, 2007

Because isReadable and isWritable need to be on Path and it didn't seem like a
good API decision to move it to PathWithStatus. As I described, however, this
needs re-stat on each call in case the status changed since the last time it was
checked. So, the current approach (always stat) is both correct and equivalent
to what we had previously when getFileStatus was part of Path class.

Its also less impact to LLVM to leave it in Path class.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
@Endilll Endilll added enhancement Improving things as opposed to bug fixing, e.g. new or missing feature and removed new-feature labels Aug 15, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla code-cleanup enhancement Improving things as opposed to bug fixing, e.g. new or missing feature
Projects
None yet
Development

No branches or pull requests

3 participants