Skip to content

Commit df9e85b

Browse files
authored
Merge pull request #198 from AMD-Lightning-Internal/upstream_merge_202501190707
merge main into amd-staging
2 parents cc80fbf + 00c8a9e commit df9e85b

File tree

262 files changed

+2942
-1408
lines changed

Some content is hidden

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

262 files changed

+2942
-1408
lines changed

.github/workflows/premerge.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
fetch-depth: 2
3131
- name: Setup ccache
3232
uses: hendrikmuhs/[email protected]
33+
with:
34+
max-size: "2000M"
3335
- name: Build and Test
3436
# Mark the job as a success even if the step fails so that people do
3537
# not get notified while the new premerge pipeline is in an

clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class UnusedUsingDeclsCheck : public ClangTidyCheck {
5151
std::vector<UsingDeclContext> Contexts;
5252
llvm::SmallPtrSet<const Decl *, 32> UsingTargetDeclsCache;
5353

54-
StringRef RawStringHeaderFileExtensions;
5554
FileExtensionsSet HeaderFileExtensions;
5655
};
5756

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3946,6 +3946,21 @@ the configuration (without a prefix: ``Auto``).
39463946
This is an experimental flag, that might go away or be renamed. Do
39473947
not use this in config files, etc. Use at your own risk.
39483948

3949+
.. _ExportBlockIndentation:
3950+
3951+
**ExportBlockIndentation** (``Boolean``) :versionbadge:`clang-format 20` :ref:`<ExportBlockIndentation>`
3952+
If ``true``, clang-format will indent the body of an ``export { ... }``
3953+
block. This doesn't affect the formatting of anything else related to
3954+
exported declarations.
3955+
3956+
.. code-block:: c++
3957+
3958+
true: false:
3959+
export { vs. export {
3960+
void foo(); void foo();
3961+
void bar(); void bar();
3962+
} }
3963+
39493964
.. _FixNamespaceComments:
39503965

39513966
**FixNamespaceComments** (``Boolean``) :versionbadge:`clang-format 5` :ref:`<FixNamespaceComments>`

clang/docs/LanguageExtensions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1697,7 +1697,7 @@ The following type trait primitives are supported by Clang. Those traits marked
16971697
* ``__is_referenceable`` (C++, GNU, Microsoft, Embarcadero):
16981698
Returns true if a type is referenceable, and false otherwise. A referenceable
16991699
type is a type that's either an object type, a reference type, or an unqualified
1700-
function type.
1700+
function type. This trait is deprecated and will be removed in Clang 21.
17011701
* ``__is_rvalue_reference`` (C++, Embarcadero)
17021702
* ``__is_same`` (C++, Embarcadero)
17031703
* ``__is_same_as`` (GCC): Synonym for ``__is_same``.

clang/docs/ReleaseNotes.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ C++ Specific Potentially Breaking Changes
9393
few users and can be written as ``__is_same(__remove_cv(T), decltype(nullptr))``,
9494
which GCC supports as well.
9595

96+
- The type trait builtin ``__is_referenceable`` has been deprecated, since it has
97+
very few users and all the type traits that could benefit from it in the
98+
standard library already have their own bespoke builtins. It will be removed in
99+
Clang 21.
100+
96101
- Clang will now correctly diagnose as ill-formed a constant expression where an
97102
enum without a fixed underlying type is set to a value outside the range of
98103
the enumeration's values.
@@ -315,7 +320,7 @@ C++23 Feature Support
315320

316321
- Extend lifetime of temporaries in mem-default-init for P2718R0. Clang now fully
317322
supports `P2718R0 Lifetime extension in range-based for loops <https://wg21.link/P2718R0>`_.
318-
323+
319324
- ``__cpp_explicit_this_parameter`` is now defined. (#GH82780)
320325

321326
C++20 Feature Support
@@ -747,7 +752,7 @@ Improvements to Clang's diagnostics
747752

748753
- Clang now diagnoses dangling references for C++20's parenthesized aggregate initialization (#101957).
749754

750-
- Fixed a bug where Clang would not emit ``-Wunused-private-field`` warnings when an unrelated class
755+
- Fixed a bug where Clang would not emit ``-Wunused-private-field`` warnings when an unrelated class
751756
defined a defaulted comparison operator (#GH116270).
752757

753758
.. code-block:: c++
@@ -969,7 +974,7 @@ Bug Fixes to C++ Support
969974
- Fixed an assertion failure caused by invalid default argument substitutions in non-defining
970975
friend declarations. (#GH113324)
971976
- Fix a crash caused by incorrect argument position in merging deduced template arguments. (#GH113659)
972-
- Fixed a parser crash when using pack indexing as a nested name specifier. (#GH119072)
977+
- Fixed a parser crash when using pack indexing as a nested name specifier. (#GH119072)
973978
- Fixed a null pointer dereference issue when heuristically computing ``sizeof...(pack)`` expressions. (#GH81436)
974979
- Fixed an assertion failure caused by mangled names with invalid identifiers. (#GH112205)
975980
- Fixed an incorrect lambda scope of generic lambdas that caused Clang to crash when computing potential lambda
@@ -1258,6 +1263,7 @@ clang-format
12581263
- Adds ``VariableTemplates`` option.
12591264
- Adds support for bash globstar in ``.clang-format-ignore``.
12601265
- Adds ``WrapNamespaceBodyWithEmptyLines`` option.
1266+
- Adds the ``ExportBlockIndentation`` option.
12611267

12621268
libclang
12631269
--------

clang/include/clang/AST/DeclTemplate.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,11 @@ class DefaultArgStorage {
367367
if (!isSet())
368368
ValueOrInherited = InheritedFrom;
369369
else if ([[maybe_unused]] auto *D =
370-
ValueOrInherited.template dyn_cast<ParmDecl *>()) {
370+
dyn_cast<ParmDecl *>(ValueOrInherited)) {
371371
assert(C.isSameDefaultTemplateArgument(D, InheritedFrom));
372372
ValueOrInherited =
373373
new (allocateDefaultArgStorageChain(C)) Chain{InheritedFrom, get()};
374-
} else if (auto *Inherited =
375-
ValueOrInherited.template dyn_cast<Chain *>()) {
374+
} else if (auto *Inherited = dyn_cast<Chain *>(ValueOrInherited)) {
376375
assert(C.isSameDefaultTemplateArgument(Inherited->PrevDeclWithDefaultArg,
377376
InheritedFrom));
378377
Inherited->PrevDeclWithDefaultArg = InheritedFrom;

clang/include/clang/Format/Format.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2676,6 +2676,19 @@ struct FormatStyle {
26762676
/// \version 3.7
26772677
bool ExperimentalAutoDetectBinPacking;
26782678

2679+
/// If ``true``, clang-format will indent the body of an ``export { ... }``
2680+
/// block. This doesn't affect the formatting of anything else related to
2681+
/// exported declarations.
2682+
/// \code
2683+
/// true: false:
2684+
/// export { vs. export {
2685+
/// void foo(); void foo();
2686+
/// void bar(); void bar();
2687+
/// } }
2688+
/// \endcode
2689+
/// \version 20
2690+
bool ExportBlockIndentation;
2691+
26792692
/// If ``true``, clang-format adds missing namespace end comments for
26802693
/// namespaces and fixes invalid existing ones. This doesn't affect short
26812694
/// namespaces, which are controlled by ``ShortNamespaceLines``.
@@ -5254,6 +5267,7 @@ struct FormatStyle {
52545267
EmptyLineBeforeAccessModifier == R.EmptyLineBeforeAccessModifier &&
52555268
ExperimentalAutoDetectBinPacking ==
52565269
R.ExperimentalAutoDetectBinPacking &&
5270+
ExportBlockIndentation == R.ExportBlockIndentation &&
52575271
FixNamespaceComments == R.FixNamespaceComments &&
52585272
ForEachMacros == R.ForEachMacros &&
52595273
IncludeStyle.IncludeBlocks == R.IncludeStyle.IncludeBlocks &&

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 56 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6194,60 +6194,67 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
61946194
return revisit(VD);
61956195
}
61966196

6197-
if (D != InitializingDecl) {
6198-
// Try to lazily visit (or emit dummy pointers for) declarations
6199-
// we haven't seen yet.
6200-
if (Ctx.getLangOpts().CPlusPlus) {
6201-
if (const auto *VD = dyn_cast<VarDecl>(D)) {
6202-
const auto typeShouldBeVisited = [&](QualType T) -> bool {
6203-
if (T.isConstant(Ctx.getASTContext()))
6204-
return true;
6205-
return T->isReferenceType();
6206-
};
6197+
// Avoid infinite recursion.
6198+
if (D == InitializingDecl)
6199+
return this->emitDummyPtr(D, E);
6200+
6201+
// Try to lazily visit (or emit dummy pointers for) declarations
6202+
// we haven't seen yet.
6203+
// For C.
6204+
if (!Ctx.getLangOpts().CPlusPlus) {
6205+
if (const auto *VD = dyn_cast<VarDecl>(D);
6206+
VD && VD->getAnyInitializer() &&
6207+
VD->getType().isConstant(Ctx.getASTContext()) && !VD->isWeak())
6208+
return revisit(VD);
6209+
return this->emitDummyPtr(D, E);
6210+
}
62076211

6208-
// DecompositionDecls are just proxies for us.
6209-
if (isa<DecompositionDecl>(VD))
6210-
return revisit(VD);
6211-
6212-
if ((VD->hasGlobalStorage() || VD->isStaticDataMember()) &&
6213-
typeShouldBeVisited(VD->getType())) {
6214-
if (const Expr *Init = VD->getAnyInitializer();
6215-
Init && !Init->isValueDependent()) {
6216-
// Whether or not the evaluation is successul doesn't really matter
6217-
// here -- we will create a global variable in any case, and that
6218-
// will have the state of initializer evaluation attached.
6219-
APValue V;
6220-
SmallVector<PartialDiagnosticAt> Notes;
6221-
(void)Init->EvaluateAsInitializer(V, Ctx.getASTContext(), VD, Notes,
6222-
true);
6223-
return this->visitDeclRef(D, E);
6224-
}
6225-
return revisit(VD);
6226-
}
6212+
// ... and C++.
6213+
const auto *VD = dyn_cast<VarDecl>(D);
6214+
if (!VD)
6215+
return this->emitDummyPtr(D, E);
62276216

6228-
// FIXME: The evaluateValue() check here is a little ridiculous, since
6229-
// it will ultimately call into Context::evaluateAsInitializer(). In
6230-
// other words, we're evaluating the initializer, just to know if we can
6231-
// evaluate the initializer.
6232-
if (VD->isLocalVarDecl() && typeShouldBeVisited(VD->getType()) &&
6233-
VD->getInit() && !VD->getInit()->isValueDependent()) {
6217+
const auto typeShouldBeVisited = [&](QualType T) -> bool {
6218+
if (T.isConstant(Ctx.getASTContext()))
6219+
return true;
6220+
return T->isReferenceType();
6221+
};
62346222

6235-
if (VD->evaluateValue())
6236-
return revisit(VD);
6223+
// DecompositionDecls are just proxies for us.
6224+
if (isa<DecompositionDecl>(VD))
6225+
return revisit(VD);
6226+
6227+
if ((VD->hasGlobalStorage() || VD->isStaticDataMember()) &&
6228+
typeShouldBeVisited(VD->getType())) {
6229+
if (const Expr *Init = VD->getAnyInitializer();
6230+
Init && !Init->isValueDependent()) {
6231+
// Whether or not the evaluation is successul doesn't really matter
6232+
// here -- we will create a global variable in any case, and that
6233+
// will have the state of initializer evaluation attached.
6234+
APValue V;
6235+
SmallVector<PartialDiagnosticAt> Notes;
6236+
(void)Init->EvaluateAsInitializer(V, Ctx.getASTContext(), VD, Notes,
6237+
true);
6238+
return this->visitDeclRef(D, E);
6239+
}
6240+
return revisit(VD);
6241+
}
6242+
6243+
// FIXME: The evaluateValue() check here is a little ridiculous, since
6244+
// it will ultimately call into Context::evaluateAsInitializer(). In
6245+
// other words, we're evaluating the initializer, just to know if we can
6246+
// evaluate the initializer.
6247+
if (VD->isLocalVarDecl() && typeShouldBeVisited(VD->getType()) &&
6248+
VD->getInit() && !VD->getInit()->isValueDependent()) {
6249+
6250+
if (VD->evaluateValue())
6251+
return revisit(VD);
62376252

6238-
if (!D->getType()->isReferenceType())
6239-
return this->emitDummyPtr(D, E);
6253+
if (!D->getType()->isReferenceType())
6254+
return this->emitDummyPtr(D, E);
62406255

6241-
return this->emitInvalidDeclRef(cast<DeclRefExpr>(E),
6242-
/*InitializerFailed=*/true, E);
6243-
}
6244-
}
6245-
} else {
6246-
if (const auto *VD = dyn_cast<VarDecl>(D);
6247-
VD && VD->getAnyInitializer() &&
6248-
VD->getType().isConstant(Ctx.getASTContext()) && !VD->isWeak())
6249-
return revisit(VD);
6250-
}
6256+
return this->emitInvalidDeclRef(cast<DeclRefExpr>(E),
6257+
/*InitializerFailed=*/true, E);
62516258
}
62526259

62536260
return this->emitDummyPtr(D, E);

clang/lib/AST/ByteCode/Program.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ unsigned Program::getOrCreateDummy(const DeclTy &D) {
155155

156156
QualType QT;
157157
bool IsWeak = false;
158-
if (const auto *E = D.dyn_cast<const Expr *>()) {
158+
if (const auto *E = dyn_cast<const Expr *>(D)) {
159159
QT = E->getType();
160160
} else {
161161
const ValueDecl *VD = cast<ValueDecl>(cast<const Decl *>(D));

clang/lib/Format/ContinuationIndenter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ static bool startsNextOperand(const FormatToken &Current) {
148148
static bool mustBreakBinaryOperation(const FormatToken &Current,
149149
const FormatStyle &Style) {
150150
return Style.BreakBinaryOperations != FormatStyle::BBO_Never &&
151+
Current.CanBreakBefore &&
151152
(Style.BreakBeforeBinaryOperators == FormatStyle::BOS_None
152153
? startsNextOperand
153154
: isAlignableBinaryOperator)(Current);

0 commit comments

Comments
 (0)