Skip to content

Commit

Permalink
Remove dead code; NFC
Browse files Browse the repository at this point in the history
This code was added 17 years ago but never enabled or tested. GCC warns
that -I- is deprecated for them, and Clang gives an error when passed
-I-, so we may as well remove this code rather than hook it up to the
driver and maintain it.
  • Loading branch information
AaronBallman committed Dec 7, 2023
1 parent 6a1badf commit 3293c08
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
7 changes: 2 additions & 5 deletions clang/include/clang/Lex/HeaderSearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,13 @@ class HeaderSearch {
/// \#include search path information. Requests for \#include "x" search the
/// directory of the \#including file first, then each directory in SearchDirs
/// consecutively. Requests for <x> search the current dir first, then each
/// directory in SearchDirs, starting at AngledDirIdx, consecutively. If
/// NoCurDirSearch is true, then the check for the file in the current
/// directory is suppressed.
/// directory in SearchDirs, starting at AngledDirIdx, consecutively.
std::vector<DirectoryLookup> SearchDirs;
/// Whether the DirectoryLookup at the corresponding index in SearchDirs has
/// been successfully used to lookup a file.
std::vector<bool> SearchDirsUsage;
unsigned AngledDirIdx = 0;
unsigned SystemDirIdx = 0;
bool NoCurDirSearch = false;

/// Maps HeaderMap keys to SearchDir indices. When HeaderMaps are used
/// heavily, SearchDirs can start with thousands of HeaderMaps, so this Index
Expand Down Expand Up @@ -373,7 +370,7 @@ class HeaderSearch {

/// Interface for setting the file search paths.
void SetSearchPaths(std::vector<DirectoryLookup> dirs, unsigned angledDirIdx,
unsigned systemDirIdx, bool noCurDirSearch,
unsigned systemDirIdx,
llvm::DenseMap<unsigned, unsigned> searchDirToHSEntry);

/// Add an additional search path.
Expand Down
15 changes: 7 additions & 8 deletions clang/lib/Lex/HeaderSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,14 @@ void HeaderSearch::PrintStats() {

void HeaderSearch::SetSearchPaths(
std::vector<DirectoryLookup> dirs, unsigned int angledDirIdx,
unsigned int systemDirIdx, bool noCurDirSearch,
unsigned int systemDirIdx,
llvm::DenseMap<unsigned int, unsigned int> searchDirToHSEntry) {
assert(angledDirIdx <= systemDirIdx && systemDirIdx <= dirs.size() &&
"Directory indices are unordered");
SearchDirs = std::move(dirs);
SearchDirsUsage.assign(SearchDirs.size(), false);
AngledDirIdx = angledDirIdx;
SystemDirIdx = systemDirIdx;
NoCurDirSearch = noCurDirSearch;
SearchDirToHSEntry = std::move(searchDirToHSEntry);
//LookupFileCache.clear();
indexInitialHeaderMaps();
Expand Down Expand Up @@ -904,12 +903,12 @@ OptionalFileEntryRef HeaderSearch::LookupFile(
ModuleMap::KnownHeader MSSuggestedModule;
OptionalFileEntryRef 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
// a #include of a subdirectory (#include "foo/bar.h") and a subsequent
// include of "baz.h" should resolve to "whatever/foo/baz.h".
// This search is not done for <> headers.
if (!Includers.empty() && !isAngled && !NoCurDirSearch) {
// Check to see if the file is in the #includer's directory. This cannot be
// based on CurDir, because each includer could be a #include of a
// subdirectory (#include "foo/bar.h") and a subsequent include of "baz.h"
// should resolve to "whatever/foo/baz.h". This search is not done for <>
// headers.
if (!Includers.empty() && !isAngled) {
SmallString<1024> TmpDir;
bool First = true;
for (const auto &IncluderAndDir : Includers) {
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/Lex/InitHeaderSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,8 @@ void InitHeaderSearch::Realize(const LangOptions &Lang) {
unsigned NonSystemRemoved = RemoveDuplicates(SearchList, NumQuoted, Verbose);
NumAngled -= NonSystemRemoved;

bool DontSearchCurDir = false; // TODO: set to true if -I- is set?
Headers.SetSearchPaths(extractLookups(SearchList), NumQuoted, NumAngled,
DontSearchCurDir, mapToUserEntries(SearchList));
mapToUserEntries(SearchList));

Headers.SetSystemHeaderPrefixes(SystemHeaderPrefixes);

Expand Down

0 comments on commit 3293c08

Please sign in to comment.