Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -4564,9 +4564,6 @@ def ibuiltininc : Flag<["-"], "ibuiltininc">, Group<clang_i_Group>,
HelpText<"Enable builtin #include directories even when -nostdinc is used "
"before or after -ibuiltininc. "
"Using -nobuiltininc after the option disables it">;
def index_header_map : Flag<["-"], "index-header-map">,
Visibility<[ClangOption, CC1Option]>,
HelpText<"Make the next included directory (-I or -F) an indexer header map">;
def iapinotes_modules : JoinedOrSeparate<["-"], "iapinotes-modules">, Group<clang_i_Group>,
Visibility<[ClangOption, CC1Option]>,
HelpText<"Add directory to the API notes search path referenced by module name">, MetaVarName<"<directory>">;
Expand Down
16 changes: 3 additions & 13 deletions clang/include/clang/Lex/DirectoryLookup.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ class DirectoryLookup {
LLVM_PREFERRED_TYPE(LookupType_t)
unsigned LookupType : 2;

/// Whether this is a header map used when building a framework.
LLVM_PREFERRED_TYPE(bool)
unsigned IsIndexHeaderMap : 1;

/// Whether we've performed an exhaustive search for module maps
/// within the subdirectories of this directory.
LLVM_PREFERRED_TYPE(bool)
Expand All @@ -73,13 +69,12 @@ class DirectoryLookup {
bool isFramework)
: u(Dir), DirCharacteristic(DT),
LookupType(isFramework ? LT_Framework : LT_NormalDir),
IsIndexHeaderMap(false), SearchedAllModuleMaps(false) {}
SearchedAllModuleMaps(false) {}

/// This ctor *does not take ownership* of 'Map'.
DirectoryLookup(const HeaderMap *Map, SrcMgr::CharacteristicKind DT,
bool isIndexHeaderMap)
DirectoryLookup(const HeaderMap *Map, SrcMgr::CharacteristicKind DT)
: u(Map), DirCharacteristic(DT), LookupType(LT_HeaderMap),
IsIndexHeaderMap(isIndexHeaderMap), SearchedAllModuleMaps(false) {}
SearchedAllModuleMaps(false) {}

/// getLookupType - Return the kind of directory lookup that this is: either a
/// normal directory, a framework path, or a HeaderMap.
Expand Down Expand Up @@ -146,11 +141,6 @@ class DirectoryLookup {
return getDirCharacteristic() != SrcMgr::C_User;
}

/// Whether this header map is building a framework or not.
bool isIndexHeaderMap() const {
return isHeaderMap() && IsIndexHeaderMap;
}

/// LookupFile - Lookup the specified file in this search path, returning it
/// if it exists or returning null if not.
///
Expand Down
12 changes: 1 addition & 11 deletions clang/include/clang/Lex/HeaderSearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,6 @@ struct HeaderFileInfo {
LLVM_PREFERRED_TYPE(bool)
unsigned Resolved : 1;

/// Whether this is a header inside a framework that is currently
/// being built.
///
/// When a framework is being built, the headers have not yet been placed
/// into the appropriate framework subdirectories, and therefore are
/// provided via a header map. This bit indicates when this is one of
/// those framework headers.
LLVM_PREFERRED_TYPE(bool)
unsigned IndexHeaderMapHeader : 1;

/// Whether this file has been looked up as a header.
LLVM_PREFERRED_TYPE(bool)
unsigned IsValid : 1;
Expand All @@ -140,7 +130,7 @@ struct HeaderFileInfo {
: IsLocallyIncluded(false), isImport(false), isPragmaOnce(false),
DirInfo(SrcMgr::C_User), External(false), isModuleHeader(false),
isTextualModuleHeader(false), isCompilingModuleHeader(false),
Resolved(false), IndexHeaderMapHeader(false), IsValid(false) {}
Resolved(false), IsValid(false) {}

/// Retrieve the controlling macro for this header file, if
/// any.
Expand Down
3 changes: 0 additions & 3 deletions clang/include/clang/Lex/HeaderSearchOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ enum IncludeDirGroup {
/// Paths for '\#include <>' added by '-I'.
Angled,

/// Like Angled, but marks header maps used when building frameworks.
IndexHeaderMap,

/// Like Angled, but marks system directories.
System,

Expand Down
3 changes: 1 addition & 2 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1185,8 +1185,7 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,

Args.addAllArgs(CmdArgs,
{options::OPT_D, options::OPT_U, options::OPT_I_Group,
options::OPT_F, options::OPT_index_header_map,
options::OPT_embed_dir_EQ});
options::OPT_F, options::OPT_embed_dir_EQ});

// Add -Wp, and -Xpreprocessor if using the preprocessor.

Expand Down
30 changes: 6 additions & 24 deletions clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3190,24 +3190,17 @@ static void GenerateHeaderSearchArgs(const HeaderSearchOptions &Opts,
auto It = Opts.UserEntries.begin();
auto End = Opts.UserEntries.end();

// Add -I..., -F..., and -index-header-map options in order.
for (; It < End && Matches(*It, {frontend::IndexHeaderMap, frontend::Angled},
std::nullopt, true);
// Add -I... and -F... options in order.
for (; It < End && Matches(*It, {frontend::Angled}, std::nullopt, true);
++It) {
OptSpecifier Opt = [It, Matches]() {
if (Matches(*It, frontend::IndexHeaderMap, true, true))
return OPT_F;
if (Matches(*It, frontend::IndexHeaderMap, false, true))
return OPT_I;
if (Matches(*It, frontend::Angled, true, true))
return OPT_F;
if (Matches(*It, frontend::Angled, false, true))
return OPT_I;
llvm_unreachable("Unexpected HeaderSearchOptions::Entry.");
}();

if (It->Group == frontend::IndexHeaderMap)
GenerateArg(Consumer, OPT_index_header_map);
GenerateArg(Consumer, Opt, It->Path);
};

Expand Down Expand Up @@ -3319,8 +3312,7 @@ static bool ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
llvm::CachedHashString(MacroDef.split('=').first));
}

// Add -I..., -F..., and -index-header-map options in order.
bool IsIndexHeaderMap = false;
// Add -I... and -F... options in order.
bool IsSysrootSpecified =
Args.hasArg(OPT__sysroot_EQ) || Args.hasArg(OPT_isysroot);

Expand All @@ -3339,20 +3331,10 @@ static bool ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
return A->getValue();
};

for (const auto *A : Args.filtered(OPT_I, OPT_F, OPT_index_header_map)) {
if (A->getOption().matches(OPT_index_header_map)) {
// -index-header-map applies to the next -I or -F.
IsIndexHeaderMap = true;
continue;
}

frontend::IncludeDirGroup Group =
IsIndexHeaderMap ? frontend::IndexHeaderMap : frontend::Angled;

for (const auto *A : Args.filtered(OPT_I, OPT_F)) {
bool IsFramework = A->getOption().matches(OPT_F);
Opts.AddPath(PrefixHeaderPath(A, IsFramework), Group, IsFramework,
/*IgnoreSysroot*/ true);
IsIndexHeaderMap = false;
Opts.AddPath(PrefixHeaderPath(A, IsFramework), frontend::Angled,
IsFramework, /*IgnoreSysroot=*/true);
}

// Add -iprefix/-iwithprefix/-iwithprefixbefore options.
Expand Down
47 changes: 1 addition & 46 deletions clang/lib/Lex/HeaderSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -974,12 +974,10 @@ OptionalFileEntryRef HeaderSearch::LookupFile(
const HeaderFileInfo *FromHFI = getExistingFileInfo(*Includer);
assert(FromHFI && "includer without file info");
unsigned DirInfo = FromHFI->DirInfo;
bool IndexHeaderMapHeader = FromHFI->IndexHeaderMapHeader;
StringRef Framework = FromHFI->Framework;

HeaderFileInfo &ToHFI = getFileInfo(*FE);
ToHFI.DirInfo = DirInfo;
ToHFI.IndexHeaderMapHeader = IndexHeaderMapHeader;
ToHFI.Framework = Framework;

if (SearchPath) {
Expand Down Expand Up @@ -1125,14 +1123,7 @@ OptionalFileEntryRef HeaderSearch::LookupFile(
// Set the `Framework` info if this file is in a header map with framework
// style include spelling or found in a framework dir. The header map case
// is possible when building frameworks which use header maps.
if (CurDir->isHeaderMap() && isAngled) {
size_t SlashPos = Filename.find('/');
if (SlashPos != StringRef::npos)
HFI.Framework =
getUniqueFrameworkName(StringRef(Filename.begin(), SlashPos));
if (CurDir->isIndexHeaderMap())
HFI.IndexHeaderMapHeader = 1;
} else if (CurDir->isFramework()) {
if ((CurDir->isHeaderMap() && isAngled) || CurDir->isFramework()) {
size_t SlashPos = Filename.find('/');
if (SlashPos != StringRef::npos)
HFI.Framework =
Expand All @@ -1156,41 +1147,6 @@ OptionalFileEntryRef HeaderSearch::LookupFile(
return File;
}

// If we are including a file with a quoted include "foo.h" from inside
// a header in a framework that is currently being built, and we couldn't
// resolve "foo.h" any other way, change the include to <Foo/foo.h>, where
// "Foo" is the name of the framework in which the including header was found.
if (!Includers.empty() && Includers.front().first && !isAngled &&
!Filename.contains('/')) {
const HeaderFileInfo *IncludingHFI =
getExistingFileInfo(*Includers.front().first);
assert(IncludingHFI && "includer without file info");
if (IncludingHFI->IndexHeaderMapHeader) {
SmallString<128> ScratchFilename;
ScratchFilename += IncludingHFI->Framework;
ScratchFilename += '/';
ScratchFilename += Filename;

OptionalFileEntryRef File = LookupFile(
ScratchFilename, IncludeLoc, /*isAngled=*/true, FromDir, &CurDir,
Includers.front(), SearchPath, RelativePath, RequestingModule,
SuggestedModule, IsMapped, /*IsFrameworkFound=*/nullptr);

if (checkMSVCHeaderSearch(Diags, MSFE,
File ? &File->getFileEntry() : nullptr,
IncludeLoc)) {
if (SuggestedModule)
*SuggestedModule = MSSuggestedModule;
return MSFE;
}

cacheLookupSuccess(LookupFileCache[Filename],
LookupFileCache[ScratchFilename].HitIt, IncludeLoc);
// FIXME: SuggestedModule.
return File;
}
}

if (checkMSVCHeaderSearch(Diags, MSFE, nullptr, IncludeLoc)) {
if (SuggestedModule)
*SuggestedModule = MSSuggestedModule;
Expand Down Expand Up @@ -1358,7 +1314,6 @@ static void mergeHeaderFileInfo(HeaderFileInfo &HFI,
HFI.DirInfo = OtherHFI.DirInfo;
HFI.External = (!HFI.IsValid || HFI.External);
HFI.IsValid = true;
HFI.IndexHeaderMapHeader = OtherHFI.IndexHeaderMapHeader;

if (HFI.Framework.empty())
HFI.Framework = OtherHFI.Framework;
Expand Down
9 changes: 4 additions & 5 deletions clang/lib/Lex/InitHeaderSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ bool InitHeaderSearch::AddUnmappedPath(const Twine &Path, IncludeDirGroup Group,

// Compute the DirectoryLookup type.
SrcMgr::CharacteristicKind Type;
if (Group == Quoted || Group == Angled || Group == IndexHeaderMap) {
if (Group == Quoted || Group == Angled) {
Type = SrcMgr::C_User;
} else if (Group == ExternCSystem) {
Type = SrcMgr::C_ExternCSystem;
Expand All @@ -170,9 +170,8 @@ bool InitHeaderSearch::AddUnmappedPath(const Twine &Path, IncludeDirGroup Group,
if (auto FE = FM.getOptionalFileRef(MappedPathStr)) {
if (const HeaderMap *HM = Headers.CreateHeaderMap(*FE)) {
// It is a headermap, add it to the search path.
IncludePath.emplace_back(
Group, DirectoryLookup(HM, Type, Group == IndexHeaderMap),
UserEntryIdx);
IncludePath.emplace_back(Group, DirectoryLookup(HM, Type),
UserEntryIdx);
return true;
}
}
Expand Down Expand Up @@ -488,7 +487,7 @@ void InitHeaderSearch::Realize(const LangOptions &Lang) {
unsigned NumQuoted = SearchList.size();

for (auto &Include : IncludePath)
if (Include.Group == Angled || Include.Group == IndexHeaderMap)
if (Include.Group == Angled)
SearchList.push_back(Include);

RemoveDuplicates(SearchList, NumQuoted, Verbose);
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Serialization/ASTReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2123,7 +2123,6 @@ HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d,
HFI.isImport |= (Flags >> 5) & 0x01;
HFI.isPragmaOnce |= (Flags >> 4) & 0x01;
HFI.DirInfo = (Flags >> 1) & 0x07;
HFI.IndexHeaderMapHeader = Flags & 0x01;
HFI.LazyControllingMacro = Reader.getGlobalIdentifierID(
M, endian::readNext<IdentifierID, llvm::endianness::little>(d));
if (unsigned FrameworkOffset =
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/Serialization/ASTWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2036,8 +2036,7 @@ namespace {
| (Data.HFI.isImport << 5)
| (Writer.isWritingStdCXXNamedModules() ? 0 :
Data.HFI.isPragmaOnce << 4)
| (Data.HFI.DirInfo << 1)
| Data.HFI.IndexHeaderMapHeader;
| (Data.HFI.DirInfo << 1);
LE.write<uint8_t>(Flags);

if (Data.HFI.LazyControllingMacro.isID())
Expand Down
4 changes: 0 additions & 4 deletions clang/test/Driver/index-header-map.c

This file was deleted.

3 changes: 1 addition & 2 deletions clang/unittests/Lex/HeaderSearchTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ class HeaderSearchTest : public ::testing::Test {
// Test class supports only one HMap at a time.
assert(!HMap);
HMap = HeaderMap::Create(*FE, FileMgr);
auto DL =
DirectoryLookup(HMap.get(), SrcMgr::C_User, /*isFramework=*/false);
auto DL = DirectoryLookup(HMap.get(), SrcMgr::C_User);
Search.AddSearchPath(DL, isAngled);
}

Expand Down
Loading