Skip to content

Commit e50accf

Browse files
authored
Merge pull request llvm#340 from AMD-Lightning-Internal/amd/merge/upstream_merge_20250128055910
merge main into amd-staging
2 parents 291d625 + b864c2b commit e50accf

File tree

273 files changed

+15352
-6604
lines changed

Some content is hidden

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

273 files changed

+15352
-6604
lines changed

clang-tools-extra/clangd/Diagnostics.cpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,17 @@ std::vector<Diag> StoreDiags::take(const clang::tidy::ClangTidyContext *Tidy) {
577577
for (auto &Diag : Output) {
578578
if (const char *ClangDiag = getDiagnosticCode(Diag.ID)) {
579579
// Warnings controlled by -Wfoo are better recognized by that name.
580-
StringRef Warning = DiagnosticIDs::getWarningOptionForDiag(Diag.ID);
580+
StringRef Warning = [&] {
581+
if (OrigSrcMgr) {
582+
return OrigSrcMgr->getDiagnostics()
583+
.getDiagnosticIDs()
584+
->getWarningOptionForDiag(Diag.ID);
585+
}
586+
if (!DiagnosticIDs::IsCustomDiag(Diag.ID))
587+
return DiagnosticIDs{}.getWarningOptionForDiag(Diag.ID);
588+
return StringRef{};
589+
}();
590+
581591
if (!Warning.empty()) {
582592
Diag.Name = ("-W" + Warning).str();
583593
} else {
@@ -894,20 +904,23 @@ void StoreDiags::flushLastDiag() {
894904
Output.push_back(std::move(*LastDiag));
895905
}
896906

897-
bool isBuiltinDiagnosticSuppressed(unsigned ID,
898-
const llvm::StringSet<> &Suppress,
899-
const LangOptions &LangOpts) {
907+
bool isDiagnosticSuppressed(const clang::Diagnostic &Diag,
908+
const llvm::StringSet<> &Suppress,
909+
const LangOptions &LangOpts) {
900910
// Don't complain about header-only stuff in mainfiles if it's a header.
901911
// FIXME: would be cleaner to suppress in clang, once we decide whether the
902912
// behavior should be to silently-ignore or respect the pragma.
903-
if (ID == diag::pp_pragma_sysheader_in_main_file && LangOpts.IsHeaderFile)
913+
if (Diag.getID() == diag::pp_pragma_sysheader_in_main_file &&
914+
LangOpts.IsHeaderFile)
904915
return true;
905916

906-
if (const char *CodePtr = getDiagnosticCode(ID)) {
917+
if (const char *CodePtr = getDiagnosticCode(Diag.getID())) {
907918
if (Suppress.contains(normalizeSuppressedCode(CodePtr)))
908919
return true;
909920
}
910-
StringRef Warning = DiagnosticIDs::getWarningOptionForDiag(ID);
921+
StringRef Warning =
922+
Diag.getDiags()->getDiagnosticIDs()->getWarningOptionForDiag(
923+
Diag.getID());
911924
if (!Warning.empty() && Suppress.contains(Warning))
912925
return true;
913926
return false;

clang-tools-extra/clangd/Diagnostics.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,11 @@ class StoreDiags : public DiagnosticConsumer {
181181
};
182182

183183
/// Determine whether a (non-clang-tidy) diagnostic is suppressed by config.
184-
bool isBuiltinDiagnosticSuppressed(unsigned ID,
185-
const llvm::StringSet<> &Suppressed,
186-
const LangOptions &);
184+
bool isDiagnosticSuppressed(const clang::Diagnostic &Diag,
185+
const llvm::StringSet<> &Suppressed,
186+
const LangOptions &);
187187
/// Take a user-specified diagnostic code, and convert it to a normalized form
188-
/// stored in the config and consumed by isBuiltinDiagnosticsSuppressed.
188+
/// stored in the config and consumed by isDiagnosticsSuppressed.
189189
///
190190
/// (This strips err_ and -W prefix so we can match with or without them.)
191191
llvm::StringRef normalizeSuppressedCode(llvm::StringRef);

clang-tools-extra/clangd/ParsedAST.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ void applyWarningOptions(llvm::ArrayRef<std::string> ExtraArgs,
342342
if (Enable) {
343343
if (Diags.getDiagnosticLevel(ID, SourceLocation()) <
344344
DiagnosticsEngine::Warning) {
345-
auto Group = DiagnosticIDs::getGroupForDiag(ID);
345+
auto Group = Diags.getDiagnosticIDs()->getGroupForDiag(ID);
346346
if (!Group || !EnabledGroups(*Group))
347347
continue;
348348
Diags.setSeverity(ID, diag::Severity::Warning, SourceLocation());
@@ -585,8 +585,8 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
585585
ASTDiags.setLevelAdjuster([&](DiagnosticsEngine::Level DiagLevel,
586586
const clang::Diagnostic &Info) {
587587
if (Cfg.Diagnostics.SuppressAll ||
588-
isBuiltinDiagnosticSuppressed(Info.getID(), Cfg.Diagnostics.Suppress,
589-
Clang->getLangOpts()))
588+
isDiagnosticSuppressed(Info, Cfg.Diagnostics.Suppress,
589+
Clang->getLangOpts()))
590590
return DiagnosticsEngine::Ignored;
591591

592592
auto It = OverriddenSeverity.find(Info.getID());

clang-tools-extra/clangd/Preamble.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,8 @@ buildPreamble(PathRef FileName, CompilerInvocation CI,
622622
PreambleDiagnostics.setLevelAdjuster([&](DiagnosticsEngine::Level DiagLevel,
623623
const clang::Diagnostic &Info) {
624624
if (Cfg.Diagnostics.SuppressAll ||
625-
isBuiltinDiagnosticSuppressed(Info.getID(), Cfg.Diagnostics.Suppress,
626-
CI.getLangOpts()))
625+
isDiagnosticSuppressed(Info, Cfg.Diagnostics.Suppress,
626+
CI.getLangOpts()))
627627
return DiagnosticsEngine::Ignored;
628628
switch (Info.getID()) {
629629
case diag::warn_no_newline_eof:

clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -298,20 +298,41 @@ TEST_F(ConfigCompileTests, DiagnosticSuppression) {
298298
"unreachable-code", "unused-variable",
299299
"typecheck_bool_condition",
300300
"unexpected_friend", "warn_alloca"));
301-
EXPECT_TRUE(isBuiltinDiagnosticSuppressed(
302-
diag::warn_unreachable, Conf.Diagnostics.Suppress, LangOptions()));
301+
clang::DiagnosticsEngine DiagEngine(new DiagnosticIDs, nullptr,
302+
new clang::IgnoringDiagConsumer);
303+
304+
using Diag = clang::Diagnostic;
305+
{
306+
auto D = DiagEngine.Report(diag::warn_unreachable);
307+
EXPECT_TRUE(isDiagnosticSuppressed(
308+
Diag{&DiagEngine, D}, Conf.Diagnostics.Suppress, LangOptions()));
309+
}
303310
// Subcategory not respected/suppressed.
304-
EXPECT_FALSE(isBuiltinDiagnosticSuppressed(
305-
diag::warn_unreachable_break, Conf.Diagnostics.Suppress, LangOptions()));
306-
EXPECT_TRUE(isBuiltinDiagnosticSuppressed(
307-
diag::warn_unused_variable, Conf.Diagnostics.Suppress, LangOptions()));
308-
EXPECT_TRUE(isBuiltinDiagnosticSuppressed(diag::err_typecheck_bool_condition,
309-
Conf.Diagnostics.Suppress,
310-
LangOptions()));
311-
EXPECT_TRUE(isBuiltinDiagnosticSuppressed(
312-
diag::err_unexpected_friend, Conf.Diagnostics.Suppress, LangOptions()));
313-
EXPECT_TRUE(isBuiltinDiagnosticSuppressed(
314-
diag::warn_alloca, Conf.Diagnostics.Suppress, LangOptions()));
311+
{
312+
auto D = DiagEngine.Report(diag::warn_unreachable_break);
313+
EXPECT_FALSE(isDiagnosticSuppressed(
314+
Diag{&DiagEngine, D}, Conf.Diagnostics.Suppress, LangOptions()));
315+
}
316+
{
317+
auto D = DiagEngine.Report(diag::warn_unused_variable);
318+
EXPECT_TRUE(isDiagnosticSuppressed(
319+
Diag{&DiagEngine, D}, Conf.Diagnostics.Suppress, LangOptions()));
320+
}
321+
{
322+
auto D = DiagEngine.Report(diag::err_typecheck_bool_condition);
323+
EXPECT_TRUE(isDiagnosticSuppressed(
324+
Diag{&DiagEngine, D}, Conf.Diagnostics.Suppress, LangOptions()));
325+
}
326+
{
327+
auto D = DiagEngine.Report(diag::err_unexpected_friend);
328+
EXPECT_TRUE(isDiagnosticSuppressed(
329+
Diag{&DiagEngine, D}, Conf.Diagnostics.Suppress, LangOptions()));
330+
}
331+
{
332+
auto D = DiagEngine.Report(diag::warn_alloca);
333+
EXPECT_TRUE(isDiagnosticSuppressed(
334+
Diag{&DiagEngine, D}, Conf.Diagnostics.Suppress, LangOptions()));
335+
}
315336

316337
Frag.Diagnostics.Suppress.emplace_back("*");
317338
EXPECT_TRUE(compileAndApply());

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5198,6 +5198,11 @@ the configuration (without a prefix: ``Auto``).
51985198
**PenaltyBreakBeforeFirstCallParameter** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`<PenaltyBreakBeforeFirstCallParameter>`
51995199
The penalty for breaking a function call after ``call(``.
52005200

5201+
.. _PenaltyBreakBeforeMemberAccess:
5202+
5203+
**PenaltyBreakBeforeMemberAccess** (``Unsigned``) :versionbadge:`clang-format 20` :ref:`<PenaltyBreakBeforeMemberAccess>`
5204+
The penalty for breaking before a member access operator (``.``, ``->``).
5205+
52015206
.. _PenaltyBreakComment:
52025207

52035208
**PenaltyBreakComment** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`<PenaltyBreakComment>`

clang/docs/ReleaseNotes.rst

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,15 @@ code bases.
7979
Undefined behavior due to pointer addition overflow can be reliably detected
8080
using ``-fsanitize=pointer-overflow``. It is also possible to use
8181
``-fno-strict-overflow`` to opt-in to a language dialect where signed integer
82-
and pointer overflow are well-defined.
82+
and pointer overflow are well-defined. Since Clang 20, it is also possible
83+
to use ``-fwrapv-pointer`` to only make pointer overflow well-defined, while
84+
not affecting the behavior of signed integer overflow.
85+
86+
- The ``-fwrapv`` flag now only makes signed integer overflow well-defined,
87+
without affecting pointer overflow, which is controlled by a new
88+
``-fwrapv-pointer`` flag. The ``-fno-strict-overflow`` flag now implies
89+
both ``-fwrapv`` and ``-fwrapv-pointer`` and as such retains its old meaning.
90+
The new behavior matches GCC.
8391

8492
C/C++ Language Potentially Breaking Changes
8593
-------------------------------------------
@@ -519,6 +527,20 @@ New Compiler Flags
519527
only for thread-local variables, and none (which corresponds to the
520528
existing ``-fno-c++-static-destructors`` flag) skips all static
521529
destructors registration.
530+
- The ``-fextend-variable-liveness`` flag has been added to allow for improved
531+
debugging of optimized code. Using ``-fextend-variable-liveness`` will cause
532+
Clang to generate code that tries to preserve the liveness of source variables
533+
through optimizations, meaning that variables will typically be visible in a
534+
debugger more often. The flag has two levels: ``-fextend-variable-liveness``,
535+
or ``-fextend-variable-liveness=all``, extendes the liveness of all user
536+
variables and the ``this`` pointer. Alternatively ``-fextend-this-ptr``, or
537+
``-fextend-variable-liveness=this``, has the same behaviour but applies only
538+
to the ``this`` variable in C++ class member functions, meaning its effect is
539+
a strict subset of ``-fextend-variable-liveness``. Note that this flag
540+
modifies the results of optimizations that Clang performs, which will result
541+
in reduced performance in generated code; however, this feature will not
542+
extend the liveness of some variables in cases where doing so would likely
543+
have a severe impact on generated code performance.
522544

523545
- The ``-Warray-compare`` warning has been added to warn about array comparison
524546
on versions older than C++20.
@@ -529,6 +551,11 @@ New Compiler Flags
529551
- clang-cl and clang-dxc now support ``-fdiagnostics-color=[auto|never|always]``
530552
in addition to ``-f[no-]color-diagnostics``.
531553

554+
- The new ``-fwrapv-pointer`` flag opts-in to a language dialect where pointer
555+
overflow is well-defined. The ``-fwrapv`` flag previously implied
556+
``-fwrapv-pointer`` as well, but no longer does. ``-fno-strict-overflow``
557+
implies ``-fwrapv -fwrapv-pointer``. The flags now match GCC.
558+
532559
Deprecated Compiler Flags
533560
-------------------------
534561

@@ -1328,6 +1355,7 @@ clang-format
13281355
- Adds support for bash globstar in ``.clang-format-ignore``.
13291356
- Adds ``WrapNamespaceBodyWithEmptyLines`` option.
13301357
- Adds the ``IndentExportBlock`` option.
1358+
- Adds ``PenaltyBreakBeforeMemberAccess`` option.
13311359

13321360
libclang
13331361
--------

clang/include/clang/Basic/Attr.td

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3458,18 +3458,16 @@ def DiagnoseIf : InheritableAttr {
34583458
let Spellings = [GNU<"diagnose_if">];
34593459
let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty]>;
34603460
let Args = [ExprArgument<"Cond">, StringArgument<"Message">,
3461-
EnumArgument<"DiagnosticType", "DiagnosticType",
3461+
EnumArgument<"DefaultSeverity",
3462+
"DefaultSeverity",
34623463
/*is_string=*/true,
3463-
["error", "warning"],
3464-
["DT_Error", "DT_Warning"]>,
3464+
["error", "warning"],
3465+
["DS_error", "DS_warning"]>,
3466+
StringArgument<"WarningGroup", /*optional*/ 1>,
34653467
BoolArgument<"ArgDependent", 0, /*fake*/ 1>,
34663468
DeclArgument<Named, "Parent", 0, /*fake*/ 1>];
34673469
let InheritEvenIfAlreadyPresent = 1;
34683470
let LateParsed = LateAttrParseStandard;
3469-
let AdditionalMembers = [{
3470-
bool isError() const { return diagnosticType == DT_Error; }
3471-
bool isWarning() const { return diagnosticType == DT_Warning; }
3472-
}];
34733471
let TemplateDependent = 1;
34743472
let Documentation = [DiagnoseIfDocs];
34753473
}

clang/include/clang/Basic/Builtins.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4795,6 +4795,12 @@ def HLSLWaveActiveCountBits : LangBuiltin<"HLSL_LANG"> {
47954795
let Prototype = "unsigned int(bool)";
47964796
}
47974797

4798+
def HLSLWaveActiveMax : LangBuiltin<"HLSL_LANG"> {
4799+
let Spellings = ["__builtin_hlsl_wave_active_max"];
4800+
let Attributes = [NoThrow, Const];
4801+
let Prototype = "void (...)";
4802+
}
4803+
47984804
def HLSLWaveActiveSum : LangBuiltin<"HLSL_LANG"> {
47994805
let Spellings = ["__builtin_hlsl_wave_active_sum"];
48004806
let Attributes = [NoThrow, Const];

0 commit comments

Comments
 (0)