Skip to content

Commit

Permalink
[clang] NFCI: Use FileEntryRef in LookupSubframeworkHeader()
Browse files Browse the repository at this point in the history
  • Loading branch information
jansvoboda11 committed Sep 10, 2023
1 parent 33f19a6 commit e483a6e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion clang/include/clang/Lex/HeaderSearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ class HeaderSearch {
/// HIToolbox is a subframework within Carbon.framework. If so, return
/// the FileEntry for the designated file, otherwise return null.
OptionalFileEntryRef LookupSubframeworkHeader(
StringRef Filename, const FileEntry *ContextFileEnt,
StringRef Filename, FileEntryRef ContextFileEnt,
SmallVectorImpl<char> *SearchPath, SmallVectorImpl<char> *RelativePath,
Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule);

Expand Down
6 changes: 2 additions & 4 deletions clang/lib/Lex/HeaderSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1178,19 +1178,17 @@ OptionalFileEntryRef HeaderSearch::LookupFile(
/// is a subframework within Carbon.framework. If so, return the FileEntry
/// for the designated file, otherwise return null.
OptionalFileEntryRef HeaderSearch::LookupSubframeworkHeader(
StringRef Filename, const FileEntry *ContextFileEnt,
StringRef Filename, FileEntryRef ContextFileEnt,
SmallVectorImpl<char> *SearchPath, SmallVectorImpl<char> *RelativePath,
Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule) {
assert(ContextFileEnt && "No context file?");

// Framework names must have a '/' in the filename. Find it.
// FIXME: Should we permit '\' on Windows?
size_t SlashPos = Filename.find('/');
if (SlashPos == StringRef::npos)
return std::nullopt;

// Look up the base framework name of the ContextFileEnt.
StringRef ContextName = ContextFileEnt->getName();
StringRef ContextName = ContextFileEnt.getName();

// If the context info wasn't a framework, couldn't be a subframework.
const unsigned DotFrameworkLen = 10;
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/Lex/PPDirectives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,14 +1041,14 @@ OptionalFileEntryRef Preprocessor::LookupFile(
return FE;
}

const FileEntry *CurFileEnt;
OptionalFileEntryRef CurFileEnt;
// Otherwise, see if this is a subframework header. If so, this is relative
// to one of the headers on the #include stack. Walk the list of the current
// headers on the #include stack and pass them to HeaderInfo.
if (IsFileLexer()) {
if ((CurFileEnt = CurPPLexer->getFileEntry())) {
if (OptionalFileEntryRef FE = HeaderInfo.LookupSubframeworkHeader(
Filename, CurFileEnt, SearchPath, RelativePath, RequestingModule,
Filename, *CurFileEnt, SearchPath, RelativePath, RequestingModule,
SuggestedModule)) {
if (SuggestedModule && !LangOpts.AsmPreprocessor)
HeaderInfo.getModuleMap().diagnoseHeaderInclusion(
Expand All @@ -1063,7 +1063,7 @@ OptionalFileEntryRef Preprocessor::LookupFile(
if (IsFileLexer(ISEntry)) {
if ((CurFileEnt = ISEntry.ThePPLexer->getFileEntry())) {
if (OptionalFileEntryRef FE = HeaderInfo.LookupSubframeworkHeader(
Filename, CurFileEnt, SearchPath, RelativePath,
Filename, *CurFileEnt, SearchPath, RelativePath,
RequestingModule, SuggestedModule)) {
if (SuggestedModule && !LangOpts.AsmPreprocessor)
HeaderInfo.getModuleMap().diagnoseHeaderInclusion(
Expand Down

0 comments on commit e483a6e

Please sign in to comment.