Skip to content

Commit b4f6afc

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:ddf1de20a3f7 into amd-gfx:756ea0fac61f
Local branch amd-gfx 756ea0f Merged main:b0b8e83e668a into amd-gfx:b9f9dea74514 Remote branch main ddf1de2 [hwasan] Fix rare false negative (zero tag) in stack-uar.c (llvm#69374)
2 parents 756ea0f + ddf1de2 commit b4f6afc

File tree

100 files changed

+1743
-464
lines changed

Some content is hidden

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

100 files changed

+1743
-464
lines changed

clang-tools-extra/docs/clang-tidy/checks/list.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ Clang-Tidy Checks
241241
:doc:`llvmlibc-restrict-system-libc-headers <llvmlibc/restrict-system-libc-headers>`, "Yes"
242242
:doc:`misc-confusable-identifiers <misc/confusable-identifiers>`,
243243
:doc:`misc-const-correctness <misc/const-correctness>`, "Yes"
244-
:doc:`misc-coroutine-hostile-raii <misc/coroutine-hostile-raii.html>`_,
244+
:doc:`misc-coroutine-hostile-raii <misc/coroutine-hostile-raii>`,
245245
:doc:`misc-definitions-in-headers <misc/definitions-in-headers>`, "Yes"
246246
:doc:`misc-header-include-cycle <misc/header-include-cycle>`,
247247
:doc:`misc-include-cleaner <misc/include-cleaner>`, "Yes"

clang-tools-extra/docs/clang-tidy/checks/misc/coroutine-hostile-raii.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
.. title:: clang-tidy - misc-coroutine-hostile-raii
22

33
misc-coroutine-hostile-raii
4-
====================
4+
===========================
55

66
Detects when objects of certain hostile RAII types persists across suspension
77
points in a coroutine. Such hostile types include scoped-lockable types and
88
types belonging to a configurable denylist.
99

10-
Some objects require that they be destroyed on the same thread that created them.
10+
Some objects require that they be destroyed on the same thread that created them.
1111
Traditionally this requirement was often phrased as "must be a local variable",
1212
under the assumption that local variables always work this way. However this is
1313
incorrect with C++20 coroutines, since an intervening ``co_await`` may cause the
1414
coroutine to suspend and later be resumed on another thread.
1515

16-
The lifetime of an object that requires being destroyed on the same thread must
16+
The lifetime of an object that requires being destroyed on the same thread must
1717
not encompass a ``co_await`` or ``co_yield`` point. If you create/destroy an object,
1818
you must do so without allowing the coroutine to suspend in the meantime.
1919

2020
Following types are considered as hostile:
2121

2222
- Scoped-lockable types: A scoped-lockable object persisting across a suspension
23-
point is problematic as the lock held by this object could be unlocked by a
24-
different thread. This would be undefined behaviour.
25-
This includes all types annotated with the ``scoped_lockable`` attribute.
23+
point is problematic as the lock held by this object could be unlocked by a
24+
different thread. This would be undefined behaviour.
25+
This includes all types annotated with the ``scoped_lockable`` attribute.
2626

2727
- Types belonging to a configurable denylist.
2828

@@ -44,7 +44,7 @@ Options
4444

4545
.. option:: RAIITypesList
4646

47-
A semicolon-separated list of qualified types which should not be allowed to
47+
A semicolon-separated list of qualified types which should not be allowed to
4848
persist across suspension points.
4949
Eg: ``my::lockable; a::b;::my::other::lockable;``
50-
The default value of this option is `"std::lock_guard;std::scoped_lock"`.
50+
The default value of this option is `"std::lock_guard;std::scoped_lock"`.

clang/docs/ReleaseNotes.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ C++ Language Changes
117117

118118
C++20 Feature Support
119119
^^^^^^^^^^^^^^^^^^^^^
120-
- Fix a bug in conversion sequence of arguments to a function with reversed parameter order.
121-
Fixes `GH <https://github.com/llvm/llvm-project/issues/53954>`_.
122120

123121
C++23 Feature Support
124122
^^^^^^^^^^^^^^^^^^^^^
@@ -199,6 +197,9 @@ New Compiler Flags
199197
the preprocessed text to the output. This can greatly reduce the size of the
200198
preprocessed output, which can be helpful when trying to reduce a test case.
201199

200+
* ``-Wbitfield-conversion`` was added to detect assignments of integral
201+
types to a bitfield that may change the value.
202+
202203
Deprecated Compiler Flags
203204
-------------------------
204205

@@ -522,6 +523,10 @@ Bug Fixes to C++ Support
522523
with non-type template parameters of reference type. Fixes:
523524
(`#65153 <https://github.com/llvm/llvm-project/issues/65153>`_)
524525

526+
- Clang now properly compares constraints on an out of line class template
527+
declaration definition. Fixes:
528+
(`#61763 <https://github.com/llvm/llvm-project/issues/61763>`_)
529+
525530
Bug Fixes to AST Handling
526531
^^^^^^^^^^^^^^^^^^^^^^^^^
527532
- Fixed an import failure of recursive friend class template.

clang/include/clang/AST/Expr.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,13 @@ class Expr : public ValueStmt {
607607
/// foldable. If the expression is foldable, but not a constant expression,
608608
/// the notes will describes why it isn't a constant expression. If the
609609
/// expression *is* a constant expression, no notes will be produced.
610+
///
611+
/// FIXME: this causes significant performance concerns and should be
612+
/// refactored at some point. Not all evaluations of the constant
613+
/// expression interpreter will display the given diagnostics, this means
614+
/// those kinds of uses are paying the expense of generating a diagnostic
615+
/// (which may include expensive operations like converting APValue objects
616+
/// to a string representation).
610617
SmallVectorImpl<PartialDiagnosticAt> *Diag = nullptr;
611618

612619
EvalStatus() = default;

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def SingleBitBitFieldConstantConversion :
5353
def BitFieldConstantConversion : DiagGroup<"bitfield-constant-conversion",
5454
[SingleBitBitFieldConstantConversion]>;
5555
def BitFieldEnumConversion : DiagGroup<"bitfield-enum-conversion">;
56+
def BitFieldConversion : DiagGroup<"bitfield-conversion">;
5657
def BitFieldWidth : DiagGroup<"bitfield-width">;
5758
def CompoundTokenSplitByMacro : DiagGroup<"compound-token-split-by-macro">;
5859
def CompoundTokenSplitBySpace : DiagGroup<"compound-token-split-by-space">;
@@ -933,6 +934,7 @@ def Conversion : DiagGroup<"conversion",
933934
ConstantConversion,
934935
EnumConversion,
935936
BitFieldEnumConversion,
937+
BitFieldConversion,
936938
FloatConversion,
937939
Shorten64To32,
938940
IntConversion,

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6171,6 +6171,9 @@ def warn_signed_bitfield_enum_conversion : Warning<
61716171
"signed bit-field %0 needs an extra bit to represent the largest positive "
61726172
"enumerators of %1">,
61736173
InGroup<BitFieldEnumConversion>, DefaultIgnore;
6174+
def warn_bitfield_too_small_for_integral_type : Warning<
6175+
"conversion from %2 (%3 bits) to bit-field %0 (%1 bits) may change value">,
6176+
InGroup<BitFieldConversion>, DefaultIgnore;
61746177
def note_change_bitfield_sign : Note<
61756178
"consider making the bitfield type %select{unsigned|signed}0">;
61766179

clang/include/clang/Basic/arm_sve.td

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,10 +1865,21 @@ def SVPTRUE_COUNT : SInst<"svptrue_{d}", "}v", "QcQsQiQl", MergeNone, "aarch64_
18651865

18661866
def SVPEXT_SINGLE : SInst<"svpext_lane_{d}", "P}i", "QcQsQiQl", MergeNone, "aarch64_sve_pext", [], [ImmCheck<1, ImmCheck0_3>]>;
18671867
def SVPEXT_X2 : SInst<"svpext_lane_{d}_x2", "2.P}i", "QcQsQiQl", MergeNone, "aarch64_sve_pext_x2", [], [ImmCheck<1, ImmCheck0_1>]>;
1868+
1869+
def SVPSEL_COUNT_ALIAS_B : SInst<"svpsel_lane_c8", "}}Pm", "Pc", MergeNone, "", [], []>;
1870+
def SVPSEL_COUNT_ALIAS_H : SInst<"svpsel_lane_c16", "}}Pm", "Ps", MergeNone, "", [], []>;
1871+
def SVPSEL_COUNT_ALIAS_S : SInst<"svpsel_lane_c32", "}}Pm", "Pi", MergeNone, "", [], []>;
1872+
def SVPSEL_COUNT_ALIAS_D : SInst<"svpsel_lane_c64", "}}Pm", "Pl", MergeNone, "", [], []>;
18681873
}
18691874

18701875
let TargetGuard = "sve2p1" in {
18711876
def SVSCLAMP : SInst<"svclamp[_{d}]", "dddd", "csil", MergeNone, "aarch64_sve_sclamp", [], []>;
18721877
def SVUCLAMP : SInst<"svclamp[_{d}]", "dddd", "UcUsUiUl", MergeNone, "aarch64_sve_uclamp", [], []>;
1878+
1879+
def SVPSEL_B : SInst<"svpsel_lane_b8", "PPPm", "Pc", MergeNone, "", [], []>;
1880+
def SVPSEL_H : SInst<"svpsel_lane_b16", "PPPm", "Ps", MergeNone, "", [], []>;
1881+
def SVPSEL_S : SInst<"svpsel_lane_b32", "PPPm", "Pi", MergeNone, "", [], []>;
1882+
def SVPSEL_D : SInst<"svpsel_lane_b64", "PPPm", "Pl", MergeNone, "", [], []>;
1883+
18731884
def SVCNTP_COUNT : SInst<"svcntp_{d}", "n}i", "QcQsQiQl", MergeNone, "aarch64_sve_cntp_{d}", [IsOverloadNone], [ImmCheck<1, ImmCheck2_4_Mul2>]>;
18741885
}

clang/include/clang/Sema/Sema.h

Lines changed: 58 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3809,17 +3809,6 @@ class Sema final {
38093809
// the purposes of [temp.friend] p9.
38103810
bool FriendConstraintsDependOnEnclosingTemplate(const FunctionDecl *FD);
38113811

3812-
// Calculates whether two constraint expressions are equal irrespective of a
3813-
// difference in 'depth'. This takes a pair of optional 'NamedDecl's 'Old' and
3814-
// 'New', which are the "source" of the constraint, since this is necessary
3815-
// for figuring out the relative 'depth' of the constraint. The depth of the
3816-
// 'primary template' and the 'instantiated from' templates aren't necessarily
3817-
// the same, such as a case when one is a 'friend' defined in a class.
3818-
bool AreConstraintExpressionsEqual(const NamedDecl *Old,
3819-
const Expr *OldConstr,
3820-
const NamedDecl *New,
3821-
const Expr *NewConstr);
3822-
38233812
enum class AllowedExplicit {
38243813
/// Allow no explicit functions to be used.
38253814
None,
@@ -8615,8 +8604,48 @@ class Sema final {
86158604
TPL_TemplateParamsEquivalent,
86168605
};
86178606

8607+
// A struct to represent the 'new' declaration, which is either itself just
8608+
// the named decl, or the important information we need about it in order to
8609+
// do constraint comparisons.
8610+
class TemplateCompareNewDeclInfo {
8611+
const NamedDecl *ND = nullptr;
8612+
const DeclContext *DC = nullptr;
8613+
const DeclContext *LexicalDC = nullptr;
8614+
SourceLocation Loc;
8615+
8616+
public:
8617+
TemplateCompareNewDeclInfo(const NamedDecl *ND) : ND(ND) {}
8618+
TemplateCompareNewDeclInfo(const DeclContext *DeclCtx,
8619+
const DeclContext *LexicalDeclCtx,
8620+
SourceLocation Loc)
8621+
8622+
: DC(DeclCtx), LexicalDC(LexicalDeclCtx), Loc(Loc) {
8623+
assert(DC && LexicalDC &&
8624+
"Constructor only for cases where we have the information to put "
8625+
"in here");
8626+
}
8627+
8628+
// If this was constructed with no information, we cannot do substitution
8629+
// for constraint comparison, so make sure we can check that.
8630+
bool isInvalid() const { return !ND && !DC; }
8631+
8632+
const NamedDecl *getDecl() const { return ND; }
8633+
8634+
bool ContainsDecl(const NamedDecl *ND) const { return this->ND == ND; }
8635+
8636+
const DeclContext *getLexicalDeclContext() const {
8637+
return ND ? ND->getLexicalDeclContext() : LexicalDC;
8638+
}
8639+
8640+
const DeclContext *getDeclContext() const {
8641+
return ND ? ND->getDeclContext() : DC;
8642+
}
8643+
8644+
SourceLocation getLocation() const { return ND ? ND->getLocation() : Loc; }
8645+
};
8646+
86188647
bool TemplateParameterListsAreEqual(
8619-
const NamedDecl *NewInstFrom, TemplateParameterList *New,
8648+
const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New,
86208649
const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain,
86218650
TemplateParameterListEqualKind Kind,
86228651
SourceLocation TemplateArgLoc = SourceLocation());
@@ -8629,6 +8658,17 @@ class Sema final {
86298658
Kind, TemplateArgLoc);
86308659
}
86318660

8661+
// Calculates whether two constraint expressions are equal irrespective of a
8662+
// difference in 'depth'. This takes a pair of optional 'NamedDecl's 'Old' and
8663+
// 'New', which are the "source" of the constraint, since this is necessary
8664+
// for figuring out the relative 'depth' of the constraint. The depth of the
8665+
// 'primary template' and the 'instantiated from' templates aren't necessarily
8666+
// the same, such as a case when one is a 'friend' defined in a class.
8667+
bool AreConstraintExpressionsEqual(const NamedDecl *Old,
8668+
const Expr *OldConstr,
8669+
const TemplateCompareNewDeclInfo &New,
8670+
const Expr *NewConstr);
8671+
86328672
bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams);
86338673

86348674
/// Called when the parser has parsed a C++ typename
@@ -9368,13 +9408,12 @@ class Sema final {
93689408
// C++ Template Instantiation
93699409
//
93709410

9371-
MultiLevelTemplateArgumentList
9372-
getTemplateInstantiationArgs(const NamedDecl *D, bool Final = false,
9373-
const TemplateArgumentList *Innermost = nullptr,
9374-
bool RelativeToPrimary = false,
9375-
const FunctionDecl *Pattern = nullptr,
9376-
bool ForConstraintInstantiation = false,
9377-
bool SkipForSpecialization = false);
9411+
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(
9412+
const NamedDecl *D, const DeclContext *DC = nullptr, bool Final = false,
9413+
const TemplateArgumentList *Innermost = nullptr,
9414+
bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr,
9415+
bool ForConstraintInstantiation = false,
9416+
bool SkipForSpecialization = false);
93789417

93799418
/// A context in which code is being synthesized (where a source location
93809419
/// alone is not sufficient to identify the context). This covers template

clang/include/clang/Sema/Template.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,9 @@ enum class TemplateSubstitutionKind : char {
213213
"substituted args outside retained args?");
214214
assert(getKind() == TemplateSubstitutionKind::Specialization);
215215
TemplateArgumentLists.push_back(
216-
{{AssociatedDecl->getCanonicalDecl(), Final}, Args});
216+
{{AssociatedDecl ? AssociatedDecl->getCanonicalDecl() : nullptr,
217+
Final},
218+
Args});
217219
}
218220

219221
void addOuterTemplateArguments(ArgList Args) {

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10007,7 +10007,33 @@ Value *CodeGenFunction::EmitAArch64SVEBuiltinExpr(unsigned BuiltinID,
1000710007
switch (BuiltinID) {
1000810008
default:
1000910009
return nullptr;
10010-
10010+
case SVE::BI__builtin_sve_svpsel_lane_b8:
10011+
case SVE::BI__builtin_sve_svpsel_lane_b16:
10012+
case SVE::BI__builtin_sve_svpsel_lane_b32:
10013+
case SVE::BI__builtin_sve_svpsel_lane_b64:
10014+
case SVE::BI__builtin_sve_svpsel_lane_c8:
10015+
case SVE::BI__builtin_sve_svpsel_lane_c16:
10016+
case SVE::BI__builtin_sve_svpsel_lane_c32:
10017+
case SVE::BI__builtin_sve_svpsel_lane_c64: {
10018+
bool IsSVCount = isa<TargetExtType>(Ops[0]->getType());
10019+
assert(((!IsSVCount || cast<TargetExtType>(Ops[0]->getType())->getName() ==
10020+
"aarch64.svcount")) &&
10021+
"Unexpected TargetExtType");
10022+
auto SVCountTy =
10023+
llvm::TargetExtType::get(getLLVMContext(), "aarch64.svcount");
10024+
Function *CastFromSVCountF =
10025+
CGM.getIntrinsic(Intrinsic::aarch64_sve_convert_to_svbool, SVCountTy);
10026+
Function *CastToSVCountF =
10027+
CGM.getIntrinsic(Intrinsic::aarch64_sve_convert_from_svbool, SVCountTy);
10028+
10029+
auto OverloadedTy = getSVEType(SVETypeFlags(Builtin->TypeModifier));
10030+
Function *F = CGM.getIntrinsic(Intrinsic::aarch64_sve_psel, OverloadedTy);
10031+
llvm::Value *Ops0 =
10032+
IsSVCount ? Builder.CreateCall(CastFromSVCountF, Ops[0]) : Ops[0];
10033+
llvm::Value *Ops1 = EmitSVEPredicateCast(Ops[1], OverloadedTy);
10034+
llvm::Value *PSel = Builder.CreateCall(F, {Ops0, Ops1, Ops[2]});
10035+
return IsSVCount ? Builder.CreateCall(CastToSVCountF, PSel) : PSel;
10036+
}
1001110037
case SVE::BI__builtin_sve_svmov_b_z: {
1001210038
// svmov_b_z(pg, op) <=> svand_b_z(pg, op, op)
1001310039
SVETypeFlags TypeFlags(Builtin->TypeModifier);

clang/lib/Driver/ToolChains/Solaris.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,14 @@ void solaris::Linker::ConstructJob(Compilation &C, const JobAction &JA,
222222
getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
223223
CmdArgs.push_back("-lm");
224224
}
225+
// Additional linker set-up and flags for Fortran. This is required in order
226+
// to generate executables. As Fortran runtime depends on the C runtime,
227+
// these dependencies need to be listed before the C runtime below.
228+
if (D.IsFlangMode()) {
229+
addFortranRuntimeLibraryPath(getToolChain(), Args, CmdArgs);
230+
addFortranRuntimeLibs(getToolChain(), CmdArgs);
231+
CmdArgs.push_back("-lm");
232+
}
225233
if (Args.hasArg(options::OPT_fstack_protector) ||
226234
Args.hasArg(options::OPT_fstack_protector_strong) ||
227235
Args.hasArg(options::OPT_fstack_protector_all)) {

clang/lib/Sema/SemaChecking.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14331,6 +14331,18 @@ static bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init,
1433114331
S.Diag(WidthExpr->getExprLoc(), diag::note_widen_bitfield)
1433214332
<< BitsNeeded << ED << WidthExpr->getSourceRange();
1433314333
}
14334+
} else if (OriginalInit->getType()->isIntegralType(S.Context)) {
14335+
IntRange LikelySourceRange =
14336+
GetExprRange(S.Context, Init, S.isConstantEvaluatedContext(),
14337+
/*Approximate=*/true);
14338+
14339+
if (LikelySourceRange.Width > FieldWidth) {
14340+
Expr *WidthExpr = Bitfield->getBitWidth();
14341+
S.Diag(InitLoc, diag::warn_bitfield_too_small_for_integral_type)
14342+
<< Bitfield << FieldWidth << OriginalInit->getType()
14343+
<< LikelySourceRange.Width;
14344+
S.Diag(WidthExpr->getExprLoc(), diag::note_declared_at);
14345+
}
1433414346
}
1433514347

1433614348
return false;
@@ -15228,7 +15240,6 @@ static void CheckImplicitConversion(Sema &S, Expr *E, QualType T,
1522815240

1522915241
if (LikelySourceRange.Width > TargetRange.Width) {
1523015242
// If the source is a constant, use a default-on diagnostic.
15231-
// TODO: this should happen for bitfield stores, too.
1523215243
Expr::EvalResult Result;
1523315244
if (E->EvaluateAsInt(Result, S.Context, Expr::SE_AllowSideEffects,
1523415245
S.isConstantEvaluatedContext())) {

0 commit comments

Comments
 (0)