Skip to content

Commit

Permalink
HeaderSearch: Simplify use of FileEntryRef in HeaderSearch::LookupFil…
Browse files Browse the repository at this point in the history
…e, NFC

Simplify `HeaderSearch::LookupFile`. Instead of deconstructing a
`FileEntryRef` into a name and `FileEntry` and then rebuilding it later,
use it as is. This helps to unblock making the constructor of
`FileEntryRef` private to `FileManager`.

Differential Revision:
  • Loading branch information
dexonsmith committed Oct 24, 2020
1 parent 0ec5baa commit 74910cb
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions clang/lib/Lex/HeaderSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,7 @@ Optional<FileEntryRef> HeaderSearch::LookupFile(

// This is the header that MSVC's header search would have found.
ModuleMap::KnownHeader MSSuggestedModule;
const FileEntry *MSFE_FE = nullptr;
StringRef MSFE_Name;
Optional<FileEntryRef> MSFE;

// Unless disabled, check to see if the file is in the #includer's
// directory. This cannot be based on CurDir, because each includer could be
Expand Down Expand Up @@ -841,8 +840,7 @@ Optional<FileEntryRef> HeaderSearch::LookupFile(
if (Diags.isIgnored(diag::ext_pp_include_search_ms, IncludeLoc)) {
return FE;
} else {
MSFE_FE = &FE->getFileEntry();
MSFE_Name = FE->getName();
MSFE = FE;
if (SuggestedModule) {
MSSuggestedModule = *SuggestedModule;
*SuggestedModule = ModuleMap::KnownHeader();
Expand All @@ -854,9 +852,6 @@ Optional<FileEntryRef> HeaderSearch::LookupFile(
}
}

Optional<FileEntryRef> MSFE(MSFE_FE ? FileEntryRef(MSFE_Name, *MSFE_FE)
: Optional<FileEntryRef>());

CurDir = nullptr;

// If this is a system #include, ignore the user #include locs.
Expand Down

0 comments on commit 74910cb

Please sign in to comment.