Skip to content

Commit c76e145

Browse files
committed
merge main into amd-staging
2 parents d2a9726 + c81341f commit c76e145

File tree

252 files changed

+3694
-1421
lines changed

Some content is hidden

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

252 files changed

+3694
-1421
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,8 @@ Improvements to Clang's diagnostics
522522
behavior of the C99 feature as it was introduced into C++20. Fixes #GH47037
523523
- ``-Wreserved-identifier`` now fires on reserved parameter names in a function
524524
declaration which is not a definition.
525+
- Clang now prints the namespace for an attribute, if any,
526+
when emitting an unknown attribute diagnostic.
525527

526528
- Several compatibility diagnostics that were incorrectly being grouped under
527529
``-Wpre-c++20-compat`` are now part of ``-Wc++20-compat``. (#GH138775)
@@ -580,7 +582,7 @@ Bug Fixes in This Version
580582
- Fixed a bug where an attribute before a ``pragma clang attribute`` or
581583
``pragma clang __debug`` would cause an assertion. Instead, this now diagnoses
582584
the invalid attribute location appropriately. (#GH137861)
583-
- Fixed a crash when a malformed ``_Pragma`` directive appears as part of an
585+
- Fixed a crash when a malformed ``_Pragma`` directive appears as part of an
584586
``#include`` directive. (#GH138094)
585587
- Fixed a crash during constant evaluation involving invalid lambda captures
586588
(#GH138832)
@@ -689,7 +691,6 @@ Bug Fixes to C++ Support
689691
- Fixed an assertion when trying to constant-fold various builtins when the argument
690692
referred to a reference to an incomplete type. (#GH129397)
691693
- Fixed a crash when a cast involved a parenthesized aggregate initialization in dependent context. (#GH72880)
692-
- Fixed a crash when forming an invalid function type in a dependent context. (#GH138657) (#GH115725) (#GH68852)
693694
- No longer crashes when instantiating invalid variable template specialization
694695
whose type depends on itself. (#GH51347), (#GH55872)
695696
- Improved parser recovery of invalid requirement expressions. In turn, this

clang/include/clang/Basic/AttributeCommonInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ class AttributeCommonInfo {
196196
/// with surrounding underscores removed as appropriate (e.g.
197197
/// __gnu__::__attr__ will be normalized to gnu::attr).
198198
std::string getNormalizedFullName() const;
199+
SourceRange getNormalizedRange() const;
199200

200201
bool isDeclspecAttribute() const { return SyntaxUsed == AS_Declspec; }
201202
bool isMicrosoftAttribute() const { return SyntaxUsed == AS_Microsoft; }

clang/include/clang/Driver/Options.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8624,6 +8624,11 @@ def objc_isystem : Separate<["-"], "objc-isystem">,
86248624
def objcxx_isystem : Separate<["-"], "objcxx-isystem">,
86258625
MetaVarName<"<directory>">,
86268626
HelpText<"Add directory to the ObjC++ SYSTEM include search path">;
8627+
def internal_iframework : Separate<["-"], "internal-iframework">,
8628+
MetaVarName<"<directory>">,
8629+
HelpText<"Add directory to the internal system framework search path; these "
8630+
"are assumed to not be user-provided and are used to model system "
8631+
"and standard frameworks' paths.">;
86278632
def internal_isystem : Separate<["-"], "internal-isystem">,
86288633
MetaVarName<"<directory>">,
86298634
HelpText<"Add directory to the internal system include search path; these "

clang/include/clang/Driver/ToolChain.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ class ToolChain {
229229

230230
/// \name Utilities for implementing subclasses.
231231
///@{
232+
static void addSystemFrameworkInclude(const llvm::opt::ArgList &DriverArgs,
233+
llvm::opt::ArgStringList &CC1Args,
234+
const Twine &Path);
232235
static void addSystemInclude(const llvm::opt::ArgList &DriverArgs,
233236
llvm::opt::ArgStringList &CC1Args,
234237
const Twine &Path);
@@ -239,6 +242,9 @@ class ToolChain {
239242
addExternCSystemIncludeIfExists(const llvm::opt::ArgList &DriverArgs,
240243
llvm::opt::ArgStringList &CC1Args,
241244
const Twine &Path);
245+
static void addSystemFrameworkIncludes(const llvm::opt::ArgList &DriverArgs,
246+
llvm::opt::ArgStringList &CC1Args,
247+
ArrayRef<StringRef> Paths);
242248
static void addSystemIncludes(const llvm::opt::ArgList &DriverArgs,
243249
llvm::opt::ArgStringList &CC1Args,
244250
ArrayRef<StringRef> Paths);

clang/lib/Basic/Attributes.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ std::string AttributeCommonInfo::getNormalizedFullName() const {
181181
normalizeName(getAttrName(), getScopeName(), getSyntax()));
182182
}
183183

184+
SourceRange AttributeCommonInfo::getNormalizedRange() const {
185+
return hasScope() ? SourceRange(ScopeLoc, AttrRange.getEnd()) : AttrRange;
186+
}
187+
184188
static AttributeCommonInfo::Scope
185189
getScopeFromNormalizedScopeName(StringRef ScopeName) {
186190
return llvm::StringSwitch<AttributeCommonInfo::Scope>(ScopeName)

clang/lib/Driver/Job.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,15 @@ static bool skipArgs(const char *Flag, bool HaveCrashVFS, int &SkipNum,
7070
return true;
7171

7272
// Some include flags shouldn't be skipped if we have a crash VFS
73-
IsInclude = llvm::StringSwitch<bool>(Flag)
74-
.Cases("-include", "-header-include-file", true)
75-
.Cases("-idirafter", "-internal-isystem", "-iwithprefix", true)
76-
.Cases("-internal-externc-isystem", "-iprefix", true)
77-
.Cases("-iwithprefixbefore", "-isystem", "-iquote", true)
78-
.Cases("-isysroot", "-I", "-F", "-resource-dir", true)
79-
.Cases("-iframework", "-include-pch", true)
80-
.Default(false);
73+
IsInclude =
74+
llvm::StringSwitch<bool>(Flag)
75+
.Cases("-include", "-header-include-file", true)
76+
.Cases("-idirafter", "-internal-isystem", "-iwithprefix", true)
77+
.Cases("-internal-externc-isystem", "-iprefix", true)
78+
.Cases("-iwithprefixbefore", "-isystem", "-iquote", true)
79+
.Cases("-isysroot", "-I", "-F", "-resource-dir", true)
80+
.Cases("-internal-iframework", "-iframework", "-include-pch", true)
81+
.Default(false);
8182
if (IsInclude)
8283
return !HaveCrashVFS;
8384

clang/lib/Driver/ToolChain.cpp

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,10 +1373,17 @@ ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{
13731373
return *cxxStdlibType;
13741374
}
13751375

1376+
/// Utility function to add a system framework directory to CC1 arguments.
1377+
void ToolChain::addSystemFrameworkInclude(const llvm::opt::ArgList &DriverArgs,
1378+
llvm::opt::ArgStringList &CC1Args,
1379+
const Twine &Path) {
1380+
CC1Args.push_back("-internal-iframework");
1381+
CC1Args.push_back(DriverArgs.MakeArgString(Path));
1382+
}
1383+
13761384
/// Utility function to add a system include directory to CC1 arguments.
1377-
/*static*/ void ToolChain::addSystemInclude(const ArgList &DriverArgs,
1378-
ArgStringList &CC1Args,
1379-
const Twine &Path) {
1385+
void ToolChain::addSystemInclude(const ArgList &DriverArgs,
1386+
ArgStringList &CC1Args, const Twine &Path) {
13801387
CC1Args.push_back("-internal-isystem");
13811388
CC1Args.push_back(DriverArgs.MakeArgString(Path));
13821389
}
@@ -1389,9 +1396,9 @@ ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{
13891396
/// "C" semantics. These semantics are *ignored* by and large today, but its
13901397
/// important to preserve the preprocessor changes resulting from the
13911398
/// classification.
1392-
/*static*/ void ToolChain::addExternCSystemInclude(const ArgList &DriverArgs,
1393-
ArgStringList &CC1Args,
1394-
const Twine &Path) {
1399+
void ToolChain::addExternCSystemInclude(const ArgList &DriverArgs,
1400+
ArgStringList &CC1Args,
1401+
const Twine &Path) {
13951402
CC1Args.push_back("-internal-externc-isystem");
13961403
CC1Args.push_back(DriverArgs.MakeArgString(Path));
13971404
}
@@ -1403,19 +1410,28 @@ void ToolChain::addExternCSystemIncludeIfExists(const ArgList &DriverArgs,
14031410
addExternCSystemInclude(DriverArgs, CC1Args, Path);
14041411
}
14051412

1413+
/// Utility function to add a list of system framework directories to CC1.
1414+
void ToolChain::addSystemFrameworkIncludes(const ArgList &DriverArgs,
1415+
ArgStringList &CC1Args,
1416+
ArrayRef<StringRef> Paths) {
1417+
for (const auto &Path : Paths) {
1418+
CC1Args.push_back("-internal-iframework");
1419+
CC1Args.push_back(DriverArgs.MakeArgString(Path));
1420+
}
1421+
}
1422+
14061423
/// Utility function to add a list of system include directories to CC1.
1407-
/*static*/ void ToolChain::addSystemIncludes(const ArgList &DriverArgs,
1408-
ArgStringList &CC1Args,
1409-
ArrayRef<StringRef> Paths) {
1424+
void ToolChain::addSystemIncludes(const ArgList &DriverArgs,
1425+
ArgStringList &CC1Args,
1426+
ArrayRef<StringRef> Paths) {
14101427
for (const auto &Path : Paths) {
14111428
CC1Args.push_back("-internal-isystem");
14121429
CC1Args.push_back(DriverArgs.MakeArgString(Path));
14131430
}
14141431
}
14151432

1416-
/*static*/ std::string ToolChain::concat(StringRef Path, const Twine &A,
1417-
const Twine &B, const Twine &C,
1418-
const Twine &D) {
1433+
std::string ToolChain::concat(StringRef Path, const Twine &A, const Twine &B,
1434+
const Twine &C, const Twine &D) {
14191435
SmallString<128> Result(Path);
14201436
llvm::sys::path::append(Result, llvm::sys::path::Style::posix, A, B, C, D);
14211437
return std::string(Result);

clang/lib/Driver/ToolChains/Darwin.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,6 +2577,27 @@ void AppleMachO::AddClangSystemIncludeArgs(
25772577
}
25782578
}
25792579

2580+
void DarwinClang::AddClangSystemIncludeArgs(
2581+
const llvm::opt::ArgList &DriverArgs,
2582+
llvm::opt::ArgStringList &CC1Args) const {
2583+
AppleMachO::AddClangSystemIncludeArgs(DriverArgs, CC1Args);
2584+
2585+
if (DriverArgs.hasArg(options::OPT_nostdinc) ||
2586+
DriverArgs.hasArg(options::OPT_nostdlibinc))
2587+
return;
2588+
2589+
llvm::SmallString<128> Sysroot = GetEffectiveSysroot(DriverArgs);
2590+
2591+
// Add <sysroot>/System/Library/Frameworks
2592+
// Add <sysroot>/System/Library/SubFrameworks
2593+
// Add <sysroot>/Library/Frameworks
2594+
SmallString<128> P1(Sysroot), P2(Sysroot), P3(Sysroot);
2595+
llvm::sys::path::append(P1, "System", "Library", "Frameworks");
2596+
llvm::sys::path::append(P2, "System", "Library", "SubFrameworks");
2597+
llvm::sys::path::append(P3, "Library", "Frameworks");
2598+
addSystemFrameworkIncludes(DriverArgs, CC1Args, {P1, P2, P3});
2599+
}
2600+
25802601
bool DarwinClang::AddGnuCPlusPlusIncludePaths(const llvm::opt::ArgList &DriverArgs,
25812602
llvm::opt::ArgStringList &CC1Args,
25822603
llvm::SmallString<128> Base,

clang/lib/Driver/ToolChains/Darwin.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,10 @@ class LLVM_LIBRARY_VISIBILITY DarwinClang : public Darwin {
647647
/// @name Apple ToolChain Implementation
648648
/// {
649649

650+
void
651+
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
652+
llvm::opt::ArgStringList &CC1Args) const override;
653+
650654
RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const override;
651655

652656
void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3381,6 +3381,8 @@ static void GenerateHeaderSearchArgs(const HeaderSearchOptions &Opts,
33813381
: OPT_internal_externc_isystem;
33823382
GenerateArg(Consumer, Opt, It->Path);
33833383
}
3384+
for (; It < End && Matches(*It, {frontend::System}, true, true); ++It)
3385+
GenerateArg(Consumer, OPT_internal_iframework, It->Path);
33843386

33853387
assert(It == End && "Unhandled HeaderSearchOption::Entry.");
33863388

@@ -3513,6 +3515,8 @@ static bool ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
35133515
Group = frontend::ExternCSystem;
35143516
Opts.AddPath(A->getValue(), Group, false, true);
35153517
}
3518+
for (const auto *A : Args.filtered(OPT_internal_iframework))
3519+
Opts.AddPath(A->getValue(), frontend::System, true, true);
35163520

35173521
// Add the path prefixes which are implicitly treated as being system headers.
35183522
for (const auto *A :

0 commit comments

Comments
 (0)