Skip to content

Commit 0b30020

Browse files
authored
merge main into amd-staging (llvm#742)
2 parents ee252b6 + 0d46d00 commit 0b30020

File tree

126 files changed

+1583
-954
lines changed

Some content is hidden

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

126 files changed

+1583
-954
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ Bug Fixes to C++ Support
168168
^^^^^^^^^^^^^^^^^^^^^^^^
169169

170170
- Clang is now better at keeping track of friend function template instance contexts. (#GH55509)
171+
- Clang now prints the correct instantiation context for diagnostics suppressed
172+
by template argument deduction.
171173
- The initialization kind of elements of structured bindings
172174
direct-list-initialized from an array is corrected to direct-initialization.
173175
- Clang no longer crashes when a coroutine is declared ``[[noreturn]]``. (#GH127327)
@@ -275,7 +277,7 @@ Code Completion
275277
Static Analyzer
276278
---------------
277279

278-
- Clang currently support extending lifetime of object bound to
280+
- Clang currently support extending lifetime of object bound to
279281
reference members of aggregates in CFG and ExprEngine, that are
280282
created from default member initializer.
281283

clang/docs/UsersManual.rst

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,19 +1681,27 @@ for more details.
16811681
permitted to produce more precise results than performing the same
16821682
operations separately.
16831683

1684-
The C standard permits intermediate floating-point results within an
1684+
The C and C++ standards permit intermediate floating-point results within an
16851685
expression to be computed with more precision than their type would
16861686
normally allow. This permits operation fusing, and Clang takes advantage
1687-
of this by default. This behavior can be controlled with the ``FP_CONTRACT``
1688-
and ``clang fp contract`` pragmas. Please refer to the pragma documentation
1689-
for a description of how the pragmas interact with this option.
1687+
of this by default (``on``). Fusion across statements is not compliant with
1688+
the C and C++ standards but can be enabled using ``-ffp-contract=fast``.
1689+
1690+
Fusion can be controlled with the ``FP_CONTRACT`` and ``clang fp contract``
1691+
pragmas. Please note that pragmas will be ingored with
1692+
``-ffp-contract=fast``, and refer to the pragma documentation for a
1693+
description of how the pragmas interact with the different ``-ffp-contract``
1694+
option values.
16901695

16911696
Valid values are:
16921697

1693-
* ``fast`` (fuse across statements disregarding pragmas, default for CUDA)
1694-
* ``on`` (fuse in the same statement unless dictated by pragmas, default for languages other than CUDA/HIP)
1695-
* ``off`` (never fuse)
1696-
* ``fast-honor-pragmas`` (fuse across statements unless dictated by pragmas, default for HIP)
1698+
* ``fast``: enable fusion across statements disregarding pragmas, breaking
1699+
compliance with the C and C++ standards (default for CUDA).
1700+
* ``on``: enable C and C++ standard complaint fusion in the same statement
1701+
unless dictated by pragmas (default for languages other than CUDA/HIP)
1702+
* ``off``: disable fusion
1703+
* ``fast-honor-pragmas``: fuse across statements unless dictated by pragmas
1704+
(default for HIP)
16971705

16981706
.. option:: -f[no-]honor-infinities
16991707

clang/include/clang/Sema/Sema.h

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,7 +1908,23 @@ class Sema final : public SemaBase {
19081908
/// '\#pragma clang attribute push' directives to the given declaration.
19091909
void AddPragmaAttributes(Scope *S, Decl *D);
19101910

1911-
void PrintPragmaAttributeInstantiationPoint();
1911+
using InstantiationContextDiagFuncRef =
1912+
llvm::function_ref<void(SourceLocation, PartialDiagnostic)>;
1913+
auto getDefaultDiagFunc() {
1914+
return [this](SourceLocation Loc, PartialDiagnostic PD) {
1915+
// This bypasses a lot of the filters in the diag engine, as it's
1916+
// to be used to attach notes to diagnostics which have already
1917+
// been filtered through.
1918+
DiagnosticBuilder Builder(Diags.Report(Loc, PD.getDiagID()));
1919+
PD.Emit(Builder);
1920+
};
1921+
}
1922+
1923+
void PrintPragmaAttributeInstantiationPoint(
1924+
InstantiationContextDiagFuncRef DiagFunc);
1925+
void PrintPragmaAttributeInstantiationPoint() {
1926+
PrintPragmaAttributeInstantiationPoint(getDefaultDiagFunc());
1927+
}
19121928

19131929
void DiagnoseUnterminatedPragmaAttribute();
19141930

@@ -13263,18 +13279,22 @@ class Sema final : public SemaBase {
1326313279
void pushCodeSynthesisContext(CodeSynthesisContext Ctx);
1326413280
void popCodeSynthesisContext();
1326513281

13266-
void PrintContextStack() {
13282+
void PrintContextStack(InstantiationContextDiagFuncRef DiagFunc) {
1326713283
if (!CodeSynthesisContexts.empty() &&
1326813284
CodeSynthesisContexts.size() != LastEmittedCodeSynthesisContextDepth) {
13269-
PrintInstantiationStack();
13285+
PrintInstantiationStack(DiagFunc);
1327013286
LastEmittedCodeSynthesisContextDepth = CodeSynthesisContexts.size();
1327113287
}
1327213288
if (PragmaAttributeCurrentTargetDecl)
13273-
PrintPragmaAttributeInstantiationPoint();
13289+
PrintPragmaAttributeInstantiationPoint(DiagFunc);
1327413290
}
13291+
void PrintContextStack() { PrintContextStack(getDefaultDiagFunc()); }
1327513292
/// Prints the current instantiation stack through a series of
1327613293
/// notes.
13277-
void PrintInstantiationStack();
13294+
void PrintInstantiationStack(InstantiationContextDiagFuncRef DiagFunc);
13295+
void PrintInstantiationStack() {
13296+
PrintInstantiationStack(getDefaultDiagFunc());
13297+
}
1327813298

1327913299
/// Determines whether we are currently in a context where
1328013300
/// template argument substitution failures are not considered

clang/lib/AST/APValue.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,6 @@ APValue &APValue::operator=(const APValue &RHS) {
390390
if (this != &RHS)
391391
*this = APValue(RHS);
392392

393-
AllowConstexprUnknown = RHS.AllowConstexprUnknown;
394393
return *this;
395394
}
396395

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -859,24 +859,6 @@ static void emitSincosBuiltin(CodeGenFunction &CGF, const CallExpr *E,
859859
StoreCos->setMetadata(LLVMContext::MD_noalias, AliasScopeList);
860860
}
861861

862-
static llvm::Value *emitModfBuiltin(CodeGenFunction &CGF, const CallExpr *E,
863-
llvm::Intrinsic::ID IntrinsicID) {
864-
llvm::Value *Val = CGF.EmitScalarExpr(E->getArg(0));
865-
llvm::Value *IntPartDest = CGF.EmitScalarExpr(E->getArg(1));
866-
867-
llvm::Value *Call =
868-
CGF.Builder.CreateIntrinsic(IntrinsicID, {Val->getType()}, Val);
869-
870-
llvm::Value *FractionalResult = CGF.Builder.CreateExtractValue(Call, 0);
871-
llvm::Value *IntegralResult = CGF.Builder.CreateExtractValue(Call, 1);
872-
873-
QualType DestPtrType = E->getArg(1)->getType()->getPointeeType();
874-
LValue IntegralLV = CGF.MakeNaturalAlignAddrLValue(IntPartDest, DestPtrType);
875-
CGF.EmitStoreOfScalar(IntegralResult, IntegralLV);
876-
877-
return FractionalResult;
878-
}
879-
880862
/// EmitFAbs - Emit a call to @llvm.fabs().
881863
static Value *EmitFAbs(CodeGenFunction &CGF, Value *V) {
882864
Function *F = CGF.CGM.getIntrinsic(Intrinsic::fabs, V->getType());
@@ -4130,15 +4112,6 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
41304112
case Builtin::BI__builtin_frexpf128:
41314113
case Builtin::BI__builtin_frexpf16:
41324114
return RValue::get(emitFrexpBuiltin(*this, E, Intrinsic::frexp));
4133-
case Builtin::BImodf:
4134-
case Builtin::BImodff:
4135-
case Builtin::BImodfl:
4136-
case Builtin::BI__builtin_modf:
4137-
case Builtin::BI__builtin_modff:
4138-
case Builtin::BI__builtin_modfl:
4139-
if (Builder.getIsFPConstrained())
4140-
break; // TODO: Emit constrained modf intrinsic once one exists.
4141-
return RValue::get(emitModfBuiltin(*this, E, Intrinsic::modf));
41424115
case Builtin::BI__builtin_isgreater:
41434116
case Builtin::BI__builtin_isgreaterequal:
41444117
case Builtin::BI__builtin_isless:

clang/lib/Sema/Sema.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,11 +1655,20 @@ void Sema::EmitDiagnostic(unsigned DiagID, const DiagnosticBuilder &DB) {
16551655
}
16561656

16571657
case DiagnosticIDs::SFINAE_Suppress:
1658+
if (DiagnosticsEngine::Level Level = getDiagnostics().getDiagnosticLevel(
1659+
DiagInfo.getID(), DiagInfo.getLocation());
1660+
Level == DiagnosticsEngine::Ignored)
1661+
return;
16581662
// Make a copy of this suppressed diagnostic and store it with the
16591663
// template-deduction information;
16601664
if (*Info) {
1661-
(*Info)->addSuppressedDiagnostic(DiagInfo.getLocation(),
1662-
PartialDiagnostic(DiagInfo, Context.getDiagAllocator()));
1665+
(*Info)->addSuppressedDiagnostic(
1666+
DiagInfo.getLocation(),
1667+
PartialDiagnostic(DiagInfo, Context.getDiagAllocator()));
1668+
if (!Diags.getDiagnosticIDs()->isNote(DiagID))
1669+
PrintContextStack([Info](SourceLocation Loc, PartialDiagnostic PD) {
1670+
(*Info)->addSuppressedDiagnostic(Loc, std::move(PD));
1671+
});
16631672
}
16641673

16651674
// Suppress this diagnostic.

clang/lib/Sema/SemaAttr.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,10 +1221,11 @@ void Sema::AddPragmaAttributes(Scope *S, Decl *D) {
12211221
}
12221222
}
12231223

1224-
void Sema::PrintPragmaAttributeInstantiationPoint() {
1224+
void Sema::PrintPragmaAttributeInstantiationPoint(
1225+
InstantiationContextDiagFuncRef DiagFunc) {
12251226
assert(PragmaAttributeCurrentTargetDecl && "Expected an active declaration");
1226-
Diags.Report(PragmaAttributeCurrentTargetDecl->getBeginLoc(),
1227-
diag::note_pragma_attribute_applied_decl_here);
1227+
DiagFunc(PragmaAttributeCurrentTargetDecl->getBeginLoc(),
1228+
PDiag(diag::note_pragma_attribute_applied_decl_here));
12281229
}
12291230

12301231
void Sema::DiagnosePrecisionLossInComplexDivision() {

clang/lib/Sema/SemaExpr.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,10 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
225225
// emit them now.
226226
auto Pos = SuppressedDiagnostics.find(D->getCanonicalDecl());
227227
if (Pos != SuppressedDiagnostics.end()) {
228-
for (const PartialDiagnosticAt &Suppressed : Pos->second)
229-
Diag(Suppressed.first, Suppressed.second);
230-
228+
for (const auto &[DiagLoc, PD] : Pos->second) {
229+
DiagnosticBuilder Builder(Diags.Report(DiagLoc, PD.getDiagID()));
230+
PD.Emit(Builder);
231+
}
231232
// Clear out the list of suppressed diagnostics, so that we don't emit
232233
// them again for this specialization. However, we don't obsolete this
233234
// entry from the table, because we want to avoid ever emitting these

clang/lib/Sema/SemaInit.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4577,7 +4577,6 @@ static void TryConstructorInitialization(Sema &S,
45774577
if (!IsListInit &&
45784578
(Kind.getKind() == InitializationKind::IK_Default ||
45794579
Kind.getKind() == InitializationKind::IK_Direct) &&
4580-
DestRecordDecl != nullptr &&
45814580
!(CtorDecl->isCopyOrMoveConstructor() && CtorDecl->isImplicit()) &&
45824581
DestRecordDecl->isAggregate() &&
45834582
DestRecordDecl->hasUninitializedExplicitInitFields()) {

0 commit comments

Comments
 (0)