Skip to content

Commit 658cd57

Browse files
committed
merge main into amd-staging
Change-Id: I310fabad3dce488c25dfea6d8d0c96d692afa072
2 parents f5f8c05 + cf0b6cc commit 658cd57

File tree

191 files changed

+4859
-2782
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

191 files changed

+4859
-2782
lines changed

clang-tools-extra/clangd/index/SymbolCollector.cpp

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,10 @@ class SymbolCollector::HeaderFileURICache {
335335
}
336336

337337
struct FrameworkHeaderPath {
338-
// Path to the framework directory containing the Headers/PrivateHeaders
339-
// directories e.g. /Frameworks/Foundation.framework/
340-
llvm::StringRef HeadersParentDir;
338+
// Path to the frameworks directory containing the .framework directory.
339+
llvm::StringRef FrameworkParentDir;
340+
// Name of the framework.
341+
llvm::StringRef FrameworkName;
341342
// Subpath relative to the Headers or PrivateHeaders dir, e.g. NSObject.h
342343
// Note: This is NOT relative to the `HeadersParentDir`.
343344
llvm::StringRef HeaderSubpath;
@@ -351,19 +352,17 @@ class SymbolCollector::HeaderFileURICache {
351352
path::reverse_iterator I = path::rbegin(Path);
352353
path::reverse_iterator Prev = I;
353354
path::reverse_iterator E = path::rend(Path);
355+
FrameworkHeaderPath HeaderPath;
354356
while (I != E) {
355-
if (*I == "Headers") {
356-
FrameworkHeaderPath HeaderPath;
357-
HeaderPath.HeadersParentDir = Path.substr(0, I - E);
357+
if (*I == "Headers" || *I == "PrivateHeaders") {
358358
HeaderPath.HeaderSubpath = Path.substr(Prev - E);
359-
HeaderPath.IsPrivateHeader = false;
360-
return HeaderPath;
361-
}
362-
if (*I == "PrivateHeaders") {
363-
FrameworkHeaderPath HeaderPath;
364-
HeaderPath.HeadersParentDir = Path.substr(0, I - E);
365-
HeaderPath.HeaderSubpath = Path.substr(Prev - E);
366-
HeaderPath.IsPrivateHeader = true;
359+
HeaderPath.IsPrivateHeader = *I == "PrivateHeaders";
360+
if (++I == E)
361+
break;
362+
HeaderPath.FrameworkName = *I;
363+
if (!HeaderPath.FrameworkName.consume_back(".framework"))
364+
break;
365+
HeaderPath.FrameworkParentDir = Path.substr(0, I - E);
367366
return HeaderPath;
368367
}
369368
Prev = I;
@@ -379,26 +378,27 @@ class SymbolCollector::HeaderFileURICache {
379378
// <Foundation/NSObject_Private.h> which should be used instead of directly
380379
// importing the header.
381380
std::optional<std::string>
382-
getFrameworkUmbrellaSpelling(llvm::StringRef Framework,
383-
const HeaderSearch &HS,
381+
getFrameworkUmbrellaSpelling(const HeaderSearch &HS,
384382
FrameworkHeaderPath &HeaderPath) {
383+
StringRef Framework = HeaderPath.FrameworkName;
385384
auto Res = CacheFrameworkToUmbrellaHeaderSpelling.try_emplace(Framework);
386385
auto *CachedSpelling = &Res.first->second;
387386
if (!Res.second) {
388387
return HeaderPath.IsPrivateHeader ? CachedSpelling->PrivateHeader
389388
: CachedSpelling->PublicHeader;
390389
}
391-
SmallString<256> UmbrellaPath(HeaderPath.HeadersParentDir);
392-
llvm::sys::path::append(UmbrellaPath, "Headers", Framework + ".h");
390+
SmallString<256> UmbrellaPath(HeaderPath.FrameworkParentDir);
391+
llvm::sys::path::append(UmbrellaPath, Framework + ".framework", "Headers",
392+
Framework + ".h");
393393

394394
llvm::vfs::Status Status;
395395
auto StatErr = HS.getFileMgr().getNoncachedStatValue(UmbrellaPath, Status);
396396
if (!StatErr)
397397
CachedSpelling->PublicHeader = llvm::formatv("<{0}/{0}.h>", Framework);
398398

399-
UmbrellaPath = HeaderPath.HeadersParentDir;
400-
llvm::sys::path::append(UmbrellaPath, "PrivateHeaders",
401-
Framework + "_Private.h");
399+
UmbrellaPath = HeaderPath.FrameworkParentDir;
400+
llvm::sys::path::append(UmbrellaPath, Framework + ".framework",
401+
"PrivateHeaders", Framework + "_Private.h");
402402

403403
StatErr = HS.getFileMgr().getNoncachedStatValue(UmbrellaPath, Status);
404404
if (!StatErr)
@@ -414,8 +414,7 @@ class SymbolCollector::HeaderFileURICache {
414414
// give <Foundation/Foundation.h> if the umbrella header exists, otherwise
415415
// <Foundation/NSObject.h>.
416416
std::optional<llvm::StringRef>
417-
getFrameworkHeaderIncludeSpelling(FileEntryRef FE, llvm::StringRef Framework,
418-
HeaderSearch &HS) {
417+
getFrameworkHeaderIncludeSpelling(FileEntryRef FE, HeaderSearch &HS) {
419418
auto Res = CachePathToFrameworkSpelling.try_emplace(FE.getName());
420419
auto *CachedHeaderSpelling = &Res.first->second;
421420
if (!Res.second)
@@ -429,13 +428,15 @@ class SymbolCollector::HeaderFileURICache {
429428
return std::nullopt;
430429
}
431430
if (auto UmbrellaSpelling =
432-
getFrameworkUmbrellaSpelling(Framework, HS, *HeaderPath)) {
431+
getFrameworkUmbrellaSpelling(HS, *HeaderPath)) {
433432
*CachedHeaderSpelling = *UmbrellaSpelling;
434433
return llvm::StringRef(*CachedHeaderSpelling);
435434
}
436435

437436
*CachedHeaderSpelling =
438-
llvm::formatv("<{0}/{1}>", Framework, HeaderPath->HeaderSubpath).str();
437+
llvm::formatv("<{0}/{1}>", HeaderPath->FrameworkName,
438+
HeaderPath->HeaderSubpath)
439+
.str();
439440
return llvm::StringRef(*CachedHeaderSpelling);
440441
}
441442

@@ -454,11 +455,8 @@ class SymbolCollector::HeaderFileURICache {
454455
// Framework headers are spelled as <FrameworkName/Foo.h>, not
455456
// "path/FrameworkName.framework/Headers/Foo.h".
456457
auto &HS = PP->getHeaderSearchInfo();
457-
if (const auto *HFI = HS.getExistingFileInfo(*FE))
458-
if (!HFI->Framework.empty())
459-
if (auto Spelling =
460-
getFrameworkHeaderIncludeSpelling(*FE, HFI->Framework, HS))
461-
return *Spelling;
458+
if (auto Spelling = getFrameworkHeaderIncludeSpelling(*FE, HS))
459+
return *Spelling;
462460

463461
if (!tooling::isSelfContainedHeader(*FE, PP->getSourceManager(),
464462
PP->getHeaderSearchInfo())) {

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ def warn_drv_invalid_arch_name_with_suggestion : Warning<
3737
"ignoring invalid /arch: argument '%0'; for %select{64|32}1-bit expected one of %2">,
3838
InGroup<UnusedCommandLineArgument>;
3939
def warn_drv_avr_mcu_not_specified : Warning<
40-
"no target microcontroller specified on command line, cannot "
41-
"link standard libraries, please pass -mmcu=<mcu name>">,
40+
"no target microcontroller specified, please pass -mmcu=<mcu name>">,
4241
InGroup<AVRRtlibLinkingQuirks>;
4342
def warn_drv_avr_libc_not_found: Warning<
4443
"no avr-libc installation can be found on the system, "

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4669,9 +4669,6 @@ def ibuiltininc : Flag<["-"], "ibuiltininc">, Group<clang_i_Group>,
46694669
HelpText<"Enable builtin #include directories even when -nostdinc is used "
46704670
"before or after -ibuiltininc. "
46714671
"Using -nobuiltininc after the option disables it">;
4672-
def index_header_map : Flag<["-"], "index-header-map">,
4673-
Visibility<[ClangOption, CC1Option]>,
4674-
HelpText<"Make the next included directory (-I or -F) an indexer header map">;
46754672
def iapinotes_modules : JoinedOrSeparate<["-"], "iapinotes-modules">, Group<clang_i_Group>,
46764673
Visibility<[ClangOption, CC1Option]>,
46774674
HelpText<"Add directory to the API notes search path referenced by module name">, MetaVarName<"<directory>">;

clang/include/clang/Lex/DirectoryLookup.h

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ class DirectoryLookup {
5858
LLVM_PREFERRED_TYPE(LookupType_t)
5959
unsigned LookupType : 2;
6060

61-
/// Whether this is a header map used when building a framework.
62-
LLVM_PREFERRED_TYPE(bool)
63-
unsigned IsIndexHeaderMap : 1;
64-
6561
/// Whether we've performed an exhaustive search for module maps
6662
/// within the subdirectories of this directory.
6763
LLVM_PREFERRED_TYPE(bool)
@@ -73,13 +69,12 @@ class DirectoryLookup {
7369
bool isFramework)
7470
: u(Dir), DirCharacteristic(DT),
7571
LookupType(isFramework ? LT_Framework : LT_NormalDir),
76-
IsIndexHeaderMap(false), SearchedAllModuleMaps(false) {}
72+
SearchedAllModuleMaps(false) {}
7773

7874
/// This ctor *does not take ownership* of 'Map'.
79-
DirectoryLookup(const HeaderMap *Map, SrcMgr::CharacteristicKind DT,
80-
bool isIndexHeaderMap)
75+
DirectoryLookup(const HeaderMap *Map, SrcMgr::CharacteristicKind DT)
8176
: u(Map), DirCharacteristic(DT), LookupType(LT_HeaderMap),
82-
IsIndexHeaderMap(isIndexHeaderMap), SearchedAllModuleMaps(false) {}
77+
SearchedAllModuleMaps(false) {}
8378

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

149-
/// Whether this header map is building a framework or not.
150-
bool isIndexHeaderMap() const {
151-
return isHeaderMap() && IsIndexHeaderMap;
152-
}
153-
154144
/// LookupFile - Lookup the specified file in this search path, returning it
155145
/// if it exists or returning null if not.
156146
///

clang/include/clang/Lex/HeaderSearch.h

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,6 @@ struct HeaderFileInfo {
108108
LLVM_PREFERRED_TYPE(bool)
109109
unsigned Resolved : 1;
110110

111-
/// Whether this is a header inside a framework that is currently
112-
/// being built.
113-
///
114-
/// When a framework is being built, the headers have not yet been placed
115-
/// into the appropriate framework subdirectories, and therefore are
116-
/// provided via a header map. This bit indicates when this is one of
117-
/// those framework headers.
118-
LLVM_PREFERRED_TYPE(bool)
119-
unsigned IndexHeaderMapHeader : 1;
120-
121111
/// Whether this file has been looked up as a header.
122112
LLVM_PREFERRED_TYPE(bool)
123113
unsigned IsValid : 1;
@@ -132,15 +122,11 @@ struct HeaderFileInfo {
132122
/// external storage.
133123
LazyIdentifierInfoPtr LazyControllingMacro;
134124

135-
/// If this header came from a framework include, this is the name
136-
/// of the framework.
137-
StringRef Framework;
138-
139125
HeaderFileInfo()
140126
: IsLocallyIncluded(false), isImport(false), isPragmaOnce(false),
141127
DirInfo(SrcMgr::C_User), External(false), isModuleHeader(false),
142128
isTextualModuleHeader(false), isCompilingModuleHeader(false),
143-
Resolved(false), IndexHeaderMapHeader(false), IsValid(false) {}
129+
Resolved(false), IsValid(false) {}
144130

145131
/// Retrieve the controlling macro for this header file, if
146132
/// any.
@@ -154,6 +140,8 @@ struct HeaderFileInfo {
154140
void mergeModuleMembership(ModuleMap::ModuleHeaderRole Role);
155141
};
156142

143+
static_assert(sizeof(HeaderFileInfo) <= 16);
144+
157145
/// An external source of header file information, which may supply
158146
/// information about header files already included.
159147
class ExternalHeaderFileInfoSource {

clang/include/clang/Lex/HeaderSearchOptions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ enum IncludeDirGroup {
3535
/// Paths for '\#include <>' added by '-I'.
3636
Angled,
3737

38-
/// Like Angled, but marks header maps used when building frameworks.
39-
IndexHeaderMap,
40-
4138
/// Like Angled, but marks system directories.
4239
System,
4340

clang/include/clang/Serialization/ASTBitCodes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace serialization {
4444
/// Version 4 of AST files also requires that the version control branch and
4545
/// revision match exactly, since there is no backward compatibility of
4646
/// AST files at this time.
47-
const unsigned VERSION_MAJOR = 32;
47+
const unsigned VERSION_MAJOR = 33;
4848

4949
/// AST file minor version number supported by this version of
5050
/// Clang.

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,8 +1235,7 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
12351235

12361236
Args.addAllArgs(CmdArgs,
12371237
{options::OPT_D, options::OPT_U, options::OPT_I_Group,
1238-
options::OPT_F, options::OPT_index_header_map,
1239-
options::OPT_embed_dir_EQ});
1238+
options::OPT_F, options::OPT_embed_dir_EQ});
12401239

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

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3198,24 +3198,17 @@ static void GenerateHeaderSearchArgs(const HeaderSearchOptions &Opts,
31983198
auto It = Opts.UserEntries.begin();
31993199
auto End = Opts.UserEntries.end();
32003200

3201-
// Add -I..., -F..., and -index-header-map options in order.
3202-
for (; It < End && Matches(*It, {frontend::IndexHeaderMap, frontend::Angled},
3203-
std::nullopt, true);
3201+
// Add -I... and -F... options in order.
3202+
for (; It < End && Matches(*It, {frontend::Angled}, std::nullopt, true);
32043203
++It) {
32053204
OptSpecifier Opt = [It, Matches]() {
3206-
if (Matches(*It, frontend::IndexHeaderMap, true, true))
3207-
return OPT_F;
3208-
if (Matches(*It, frontend::IndexHeaderMap, false, true))
3209-
return OPT_I;
32103205
if (Matches(*It, frontend::Angled, true, true))
32113206
return OPT_F;
32123207
if (Matches(*It, frontend::Angled, false, true))
32133208
return OPT_I;
32143209
llvm_unreachable("Unexpected HeaderSearchOptions::Entry.");
32153210
}();
32163211

3217-
if (It->Group == frontend::IndexHeaderMap)
3218-
GenerateArg(Consumer, OPT_index_header_map);
32193212
GenerateArg(Consumer, Opt, It->Path);
32203213
};
32213214

@@ -3327,8 +3320,7 @@ static bool ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
33273320
llvm::CachedHashString(MacroDef.split('=').first));
33283321
}
33293322

3330-
// Add -I..., -F..., and -index-header-map options in order.
3331-
bool IsIndexHeaderMap = false;
3323+
// Add -I... and -F... options in order.
33323324
bool IsSysrootSpecified =
33333325
Args.hasArg(OPT__sysroot_EQ) || Args.hasArg(OPT_isysroot);
33343326

@@ -3347,20 +3339,10 @@ static bool ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
33473339
return A->getValue();
33483340
};
33493341

3350-
for (const auto *A : Args.filtered(OPT_I, OPT_F, OPT_index_header_map)) {
3351-
if (A->getOption().matches(OPT_index_header_map)) {
3352-
// -index-header-map applies to the next -I or -F.
3353-
IsIndexHeaderMap = true;
3354-
continue;
3355-
}
3356-
3357-
frontend::IncludeDirGroup Group =
3358-
IsIndexHeaderMap ? frontend::IndexHeaderMap : frontend::Angled;
3359-
3342+
for (const auto *A : Args.filtered(OPT_I, OPT_F)) {
33603343
bool IsFramework = A->getOption().matches(OPT_F);
3361-
Opts.AddPath(PrefixHeaderPath(A, IsFramework), Group, IsFramework,
3362-
/*IgnoreSysroot*/ true);
3363-
IsIndexHeaderMap = false;
3344+
Opts.AddPath(PrefixHeaderPath(A, IsFramework), frontend::Angled,
3345+
IsFramework, /*IgnoreSysroot=*/true);
33643346
}
33653347

33663348
// Add -iprefix/-iwithprefix/-iwithprefixbefore options.

0 commit comments

Comments
 (0)