-
Notifications
You must be signed in to change notification settings - Fork 16.6k
[clang] Expose normalized module cache path in HeaderSearch
#185746
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -282,6 +282,10 @@ class HeaderSearch { | |
| /// The specific module cache path containing ContextHash (unless suppressed). | ||
| std::string SpecificModuleCachePath; | ||
|
|
||
| /// The length of the normalized module cache path at the start of \c | ||
| /// SpecificModuleCachePath. | ||
| size_t NormalizedModuleCachePathLen = 0; | ||
|
|
||
| /// All of the preprocessor-specific data about files that are | ||
| /// included, indexed by the FileEntry's UID. | ||
| mutable std::vector<HeaderFileInfo> FileInfo; | ||
|
|
@@ -467,20 +471,23 @@ class HeaderSearch { | |
| return {}; | ||
| } | ||
|
|
||
| /// Set the context hash to use for module cache paths. | ||
| void setContextHash(StringRef Hash) { ContextHash = std::string(Hash); } | ||
| /// Initialize the module cache path. | ||
| void initializeModuleCachePath(std::string ContextHash); | ||
|
|
||
| /// Set the module cache path with the context hash (unless suppressed). | ||
| void setSpecificModuleCachePath(StringRef Path) { | ||
| SpecificModuleCachePath = std::string(Path); | ||
| /// Retrieve the specific module cache path. This is the normalized module | ||
| /// cache path plus the context hash (unless suppressed). | ||
| StringRef getSpecificModuleCachePath() const { | ||
| return SpecificModuleCachePath; | ||
| } | ||
|
|
||
| /// Retrieve the context hash. | ||
| StringRef getContextHash() const { return ContextHash; } | ||
|
|
||
| /// Retrieve the module cache path with the context hash (unless suppressed). | ||
| StringRef getSpecificModuleCachePath() const { | ||
| return SpecificModuleCachePath; | ||
| /// Retrieve the normalized module cache path. This is the path as provided on | ||
| /// the command line, but absolute, without './' components, and with | ||
| /// preferred path separators. Note that this does not have the context hash. | ||
| StringRef getNormalizedModuleCachePath() const { | ||
cyndyishida marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return getSpecificModuleCachePath().substr(0, NormalizedModuleCachePathLen); | ||
| } | ||
|
|
||
| /// Forget everything we know about headers so far. | ||
|
|
@@ -1042,6 +1049,11 @@ void ApplyHeaderSearchOptions(HeaderSearch &HS, | |
| void normalizeModuleCachePath(FileManager &FileMgr, StringRef Path, | ||
| SmallVectorImpl<char> &NormalizedPath); | ||
|
|
||
| std::string createSpecificModuleCachePath(FileManager &FileMgr, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I notice some callsites now call this vs previously calling
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the call to The second call is done from I personally don't mind this that much, but if we can find an elegant way to de-duplicate these calls, that'd be a good follow-up.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could the path be saved within This is not a big enough concern to block this PR, but I'm more generally worried about what kinds of bugs would happen if accidental misalignment happened.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, my long-term goal is to prevent any mutation of TBH I'm not 100% sure these two calls do (or are supposed to) produce the same specific module cache path, so I'd like to defer this change to a separate PR if possible.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Can you add a FIXME in that case?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in ad7c29d. |
||
| StringRef ModuleCachePath, | ||
| bool DisableModuleHash, | ||
| std::string ContextHash); | ||
|
|
||
| } // namespace clang | ||
|
|
||
| #endif // LLVM_CLANG_LEX_HEADERSEARCH_H | ||
Uh oh!
There was an error while loading. Please reload this page.