Skip to content

Commit e17e7b1

Browse files
committed
Merge from 'main' to 'sycl-web' (117 commits)
CONFLICT (content): Merge conflict in clang/lib/CodeGen/CGDebugInfo.cpp
2 parents a8ce719 + 831484e commit e17e7b1

File tree

455 files changed

+194578
-8177
lines changed

Some content is hidden

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

455 files changed

+194578
-8177
lines changed

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ jobs:
160160
'generic-no-tzdb',
161161
'generic-no-unicode',
162162
'generic-no-wide-characters',
163+
'generic-no-rtti',
163164
'generic-static',
164165
'generic-with_llvm_unwinder',
165166
# TODO Find a better place for the benchmark and bootstrapping builds to live. They're either very expensive

.github/workflows/new-prs.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,19 @@ jobs:
2020
permissions:
2121
pull-requests: write
2222
# Only comment on PRs that have been opened for the first time, by someone
23-
# new to LLVM or to GitHub as a whole.
23+
# new to LLVM or to GitHub as a whole. Ideally we'd look for FIRST_TIMER
24+
# or FIRST_TIME_CONTRIBUTOR, but this does not appear to work. Instead check
25+
# that we do not have any of the other author associations.
26+
# See https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=opened#pull_request
27+
# for all the possible values.
2428
if: >-
2529
(github.repository == 'llvm/llvm-project') &&
2630
(github.event.action == 'opened') &&
27-
(github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' ||
28-
github.event.pull_request.author_association == 'FIRST_TIMER')
31+
(github.event.pull_request.author_association != 'COLLABORATOR') &&
32+
(github.event.pull_request.author_association != 'CONTRIBUTOR') &&
33+
(github.event.pull_request.author_association != 'MANNEQUIN') &&
34+
(github.event.pull_request.author_association != 'MEMBER') &&
35+
(github.event.pull_request.author_association != 'OWNER')
2936
steps:
3037
- name: Setup Automation Script
3138
run: |

.github/workflows/pr-code-format.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,14 @@ jobs:
6767
START_REV: ${{ github.event.pull_request.base.sha }}
6868
END_REV: ${{ github.event.pull_request.head.sha }}
6969
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
70+
# TODO(boomanaiden154): Once clang v18 is released, we should be able
71+
# to take advantage of the new --diff_from_common_commit option
72+
# explicitly in code-format-helper.py and not have to diff starting at
73+
# the merge base.
7074
run: |
7175
python ./code-format-tools/llvm/utils/git/code-format-helper.py \
7276
--token ${{ secrets.GITHUB_TOKEN }} \
7377
--issue-number $GITHUB_PR_NUMBER \
74-
--start-rev $START_REV \
78+
--start-rev $(git merge-base $START_REV $END_REV) \
7579
--end-rev $END_REV \
7680
--changed-files "$CHANGED_FILES"

clang/docs/LanguageExtensions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,7 @@ Relaxed constexpr __cpp_constexpr C++14
14701470
``if constexpr`` __cpp_if_constexpr C++17 C++11
14711471
fold expressions __cpp_fold_expressions C++17 C++03
14721472
Lambda capture of \*this by value __cpp_capture_star_this C++17 C++11
1473-
Attributes on enums __cpp_enumerator_attributes C++17 C++11
1473+
Attributes on enums __cpp_enumerator_attributes C++17 C++03
14741474
Guaranteed copy elision __cpp_guaranteed_copy_elision C++17 C++03
14751475
Hexadecimal floating literals __cpp_hex_float C++17 C++03
14761476
``inline`` variables __cpp_inline_variables C++17 C++03

clang/docs/ReleaseNotes.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,10 @@ Miscellaneous Clang Crashes Fixed
870870
`Issue 41302 <https://github.com/llvm/llvm-project/issues/41302>`_
871871
- Fixed a crash when ``-ast-dump=json`` was used for code using class
872872
template deduction guides.
873+
- Fixed a crash when a lambda marked as ``static`` referenced a captured
874+
variable in an expression.
875+
`Issue 74608 <https://github.com/llvm/llvm-project/issues/74608>`_
876+
873877

874878
OpenACC Specific Changes
875879
------------------------
@@ -1069,6 +1073,9 @@ Static Analyzer
10691073
`#65888 <https://github.com/llvm/llvm-project/pull/65888>`_, and
10701074
`#65887 <https://github.com/llvm/llvm-project/pull/65887>`_
10711075

1076+
- Move checker ``alpha.cplusplus.EnumCastOutOfRange`` out of the ``alpha``
1077+
package to ``optin.core.EnumCastOutOfRange``.
1078+
10721079
.. _release-notes-sanitizers:
10731080

10741081
Sanitizers

clang/docs/analyzer/checkers.rst

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,52 @@ optin
535535
536536
Checkers for portability, performance or coding style specific rules.
537537
538+
.. _optin-core-EnumCastOutOfRange:
539+
540+
optin.core.EnumCastOutOfRange (C, C++)
541+
""""""""""""""""""""""""""""""""""""""
542+
Check for integer to enumeration casts that would produce a value with no
543+
corresponding enumerator. This is not necessarily undefined behavior, but can
544+
lead to nasty surprises, so projects may decide to use a coding standard that
545+
disallows these "unusual" conversions.
546+
547+
Note that no warnings are produced when the enum type (e.g. `std::byte`) has no
548+
enumerators at all.
549+
550+
.. code-block:: cpp
551+
552+
enum WidgetKind { A=1, B, C, X=99 };
553+
554+
void foo() {
555+
WidgetKind c = static_cast<WidgetKind>(3); // OK
556+
WidgetKind x = static_cast<WidgetKind>(99); // OK
557+
WidgetKind d = static_cast<WidgetKind>(4); // warn
558+
}
559+
560+
**Limitations**
561+
562+
This checker does not accept the coding pattern where an enum type is used to
563+
store combinations of flag values:
564+
565+
.. code-block:: cpp
566+
567+
enum AnimalFlags
568+
{
569+
HasClaws = 1,
570+
CanFly = 2,
571+
EatsFish = 4,
572+
Endangered = 8
573+
};
574+
575+
AnimalFlags operator|(AnimalFlags a, AnimalFlags b)
576+
{
577+
return static_cast<AnimalFlags>(static_cast<int>(a) | static_cast<int>(b));
578+
}
579+
580+
auto flags = HasClaws | CanFly;
581+
582+
Projects that use this pattern should not enable this optin checker.
583+
538584
.. _optin-cplusplus-UninitializedObject:
539585
540586
optin.cplusplus.UninitializedObject (C++)
@@ -2113,23 +2159,6 @@ Reports destructions of polymorphic objects with a non-virtual destructor in the
21132159
// destructor
21142160
}
21152161
2116-
.. _alpha-cplusplus-EnumCastOutOfRange:
2117-
2118-
alpha.cplusplus.EnumCastOutOfRange (C++)
2119-
""""""""""""""""""""""""""""""""""""""""
2120-
Check for integer to enumeration casts that could result in undefined values.
2121-
2122-
.. code-block:: cpp
2123-
2124-
enum TestEnum {
2125-
A = 0
2126-
};
2127-
2128-
void foo() {
2129-
TestEnum t = static_cast(-1);
2130-
// warn: the value provided to the cast expression is not in
2131-
// the valid range of values for the enum
2132-
21332162
.. _alpha-cplusplus-InvalidatedIterator:
21342163
21352164
alpha.cplusplus.InvalidatedIterator (C++)

clang/include/clang/Basic/arm_sve.td

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2262,3 +2262,14 @@ let TargetGuard = "sme2" in {
22622262
def SVQCVTN_U16_U64_X4 : SInst<"svqcvtn_u16[_{d}_x4]", "b4.d", "Ul", MergeNone, "aarch64_sve_uqcvtn_x4", [IsStreaming], []>;
22632263
def SVQCVTN_U16_S64_X4 : SInst<"svqcvtn_u16[_{d}_x4]", "b4.d", "l", MergeNone, "aarch64_sve_sqcvtun_x4", [IsStreaming], []>;
22642264
}
2265+
2266+
//
2267+
// Multi-vector unpack
2268+
//
2269+
2270+
let TargetGuard = "sme2" in {
2271+
def SVSUNPK_X2 : SInst<"svunpk_{d}[_{1}_x2]", "2h", "sil", MergeNone, "aarch64_sve_sunpk_x2", [IsStreaming], []>;
2272+
def SVUUNPK_X2 : SInst<"svunpk_{d}[_{1}_x2]", "2h", "UsUiUl", MergeNone, "aarch64_sve_uunpk_x2", [IsStreaming], []>;
2273+
def SVSUNPK_X4 : SInst<"svunpk_{d}[_{3}_x4]", "42.h", "sil", MergeNone, "aarch64_sve_sunpk_x4", [IsStreaming], []>;
2274+
def SVUUNPK_X4 : SInst<"svunpk_{d}[_{3}_x4]", "42.h", "UsUiUl", MergeNone, "aarch64_sve_uunpk_x4", [IsStreaming], []>;
2275+
}

clang/include/clang/Sema/Sema.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7590,8 +7590,7 @@ class Sema final {
75907590

75917591
/// ActOnLambdaExpr - This is called when the body of a lambda expression
75927592
/// was successfully completed.
7593-
ExprResult ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body,
7594-
Scope *CurScope);
7593+
ExprResult ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body);
75957594

75967595
/// Does copying/destroying the captured variable have side effects?
75977596
bool CaptureHasSideEffects(const sema::Capture &From);

clang/include/clang/StaticAnalyzer/Checkers/Checkers.td

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def CoreAlpha : Package<"core">, ParentPackage<Alpha>;
3636
// Note: OptIn is *not* intended for checkers that are too noisy to be on by
3737
// default. Such checkers belong in the alpha package.
3838
def OptIn : Package<"optin">;
39+
def CoreOptIn : Package<"core">, ParentPackage<OptIn>;
3940

4041
// In the Portability package reside checkers for finding code that relies on
4142
// implementation-defined behavior. Such checks are wanted for cross-platform
@@ -439,6 +440,18 @@ def UndefinedNewArraySizeChecker : Checker<"NewArraySize">,
439440

440441
} // end "core.uninitialized"
441442

443+
//===----------------------------------------------------------------------===//
444+
// Optin checkers for core language features
445+
//===----------------------------------------------------------------------===//
446+
447+
let ParentPackage = CoreOptIn in {
448+
449+
def EnumCastOutOfRangeChecker : Checker<"EnumCastOutOfRange">,
450+
HelpText<"Check integer to enumeration casts for out of range values">,
451+
Documentation<HasDocumentation>;
452+
453+
} // end "optin.core"
454+
442455
//===----------------------------------------------------------------------===//
443456
// Unix API checkers.
444457
//===----------------------------------------------------------------------===//
@@ -774,10 +787,6 @@ def DeleteWithNonVirtualDtorChecker : Checker<"DeleteWithNonVirtualDtor">,
774787
"destructor in their base class">,
775788
Documentation<HasDocumentation>;
776789

777-
def EnumCastOutOfRangeChecker : Checker<"EnumCastOutOfRange">,
778-
HelpText<"Check integer to enumeration casts for out of range values">,
779-
Documentation<HasDocumentation>;
780-
781790
def IteratorModeling : Checker<"IteratorModeling">,
782791
HelpText<"Models iterators of C++ containers">,
783792
Dependencies<[ContainerModeling]>,

clang/lib/AST/ExprConstant.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8514,14 +8514,24 @@ bool LValueExprEvaluator::VisitVarDecl(const Expr *E, const VarDecl *VD) {
85148514
return false;
85158515

85168516
if (auto *FD = Info.CurrentCall->LambdaCaptureFields.lookup(VD)) {
8517+
const auto *MD = cast<CXXMethodDecl>(Info.CurrentCall->Callee);
8518+
8519+
// Static lambda function call operators can't have captures. We already
8520+
// diagnosed this, so bail out here.
8521+
if (MD->isStatic()) {
8522+
assert(Info.CurrentCall->This == nullptr &&
8523+
"This should not be set for a static call operator");
8524+
return false;
8525+
}
8526+
85178527
// Start with 'Result' referring to the complete closure object...
8518-
if (auto *MD = cast<CXXMethodDecl>(Info.CurrentCall->Callee);
8519-
MD->isExplicitObjectMemberFunction()) {
8528+
if (MD->isExplicitObjectMemberFunction()) {
85208529
APValue *RefValue =
85218530
Info.getParamSlot(Info.CurrentCall->Arguments, MD->getParamDecl(0));
85228531
Result.setFrom(Info.Ctx, *RefValue);
85238532
} else
85248533
Result = *Info.CurrentCall->This;
8534+
85258535
// ... then update it to refer to the field of the closure object
85268536
// that represents the capture.
85278537
if (!HandleLValueMember(Info, E, Result, FD))

clang/lib/AST/Interp/ByteCodeEmitter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ ByteCodeEmitter::compileFunc(const FunctionDecl *FuncDecl) {
6161
MD->getParent()->getCaptureFields(LC, LTC);
6262

6363
for (auto Cap : LC) {
64+
// Static lambdas cannot have any captures. If this one does,
65+
// it has already been diagnosed and we can only ignore it.
66+
if (MD->isStatic())
67+
return nullptr;
68+
6469
unsigned Offset = R->getField(Cap.second)->Offset;
6570
this->LambdaCaptures[Cap.first] = {
6671
Offset, Cap.second->getType()->isReferenceType()};

clang/lib/AST/Interp/Context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ bool Context::Run(State &Parent, const Function *Func, APValue &Result) {
168168
}
169169

170170
// State gets destroyed here, so the Stk.clear() below doesn't accidentally
171-
// remove values the State's destructor might accedd.
171+
// remove values the State's destructor might access.
172172
}
173173

174174
Stk.clear();

clang/lib/AST/Interp/IntegralAP.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,17 +182,13 @@ template <bool Signed> class IntegralAP final {
182182
}
183183

184184
static bool increment(IntegralAP A, IntegralAP *R) {
185-
// FIXME: Implement.
186-
assert(false);
187-
*R = IntegralAP(A.V - 1);
188-
return false;
185+
IntegralAP<Signed> One(1, A.bitWidth());
186+
return add(A, One, A.bitWidth() + 1, R);
189187
}
190188

191189
static bool decrement(IntegralAP A, IntegralAP *R) {
192-
// FIXME: Implement.
193-
assert(false);
194-
*R = IntegralAP(A.V - 1);
195-
return false;
190+
IntegralAP<Signed> One(1, A.bitWidth());
191+
return sub(A, One, A.bitWidth() + 1, R);
196192
}
197193

198194
static bool add(IntegralAP A, IntegralAP B, unsigned OpBits, IntegralAP *R) {

clang/lib/AST/Interp/Interp.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,10 +1826,12 @@ inline bool ArrayElemPtr(InterpState &S, CodePtr OpPC) {
18261826
/// Just takes a pointer and checks if its' an incomplete
18271827
/// array type.
18281828
inline bool ArrayDecay(InterpState &S, CodePtr OpPC) {
1829-
const Pointer &Ptr = S.Stk.peek<Pointer>();
1829+
const Pointer &Ptr = S.Stk.pop<Pointer>();
18301830

1831-
if (!Ptr.isUnknownSizeArray())
1831+
if (!Ptr.isUnknownSizeArray()) {
1832+
S.Stk.push<Pointer>(Ptr.atIndex(0));
18321833
return true;
1834+
}
18331835

18341836
const SourceInfo &E = S.Current->getSource(OpPC);
18351837
S.FFDiag(E, diag::note_constexpr_unsupported_unsized_array);

clang/lib/AST/Interp/InterpBuiltin.cpp

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,40 @@ static bool interp__builtin_expect(InterpState &S, CodePtr OpPC,
579579
return true;
580580
}
581581

582+
/// rotateleft(value, amount)
583+
static bool interp__builtin_rotate(InterpState &S, CodePtr OpPC,
584+
const InterpFrame *Frame,
585+
const Function *Func, const CallExpr *Call,
586+
bool Right) {
587+
PrimType ArgT = *S.getContext().classify(Call->getArg(0)->getType());
588+
assert(ArgT == *S.getContext().classify(Call->getArg(1)->getType()));
589+
590+
APSInt Amount = peekToAPSInt(S.Stk, ArgT);
591+
APSInt Value = peekToAPSInt(S.Stk, ArgT, align(primSize(ArgT)) * 2);
592+
593+
APSInt Result;
594+
if (Right)
595+
Result = APSInt(Value.rotr(Amount.urem(Value.getBitWidth())),
596+
/*IsUnsigned=*/true);
597+
else // Left.
598+
Result = APSInt(Value.rotl(Amount.urem(Value.getBitWidth())),
599+
/*IsUnsigned=*/true);
600+
601+
pushAPSInt(S, Result);
602+
return true;
603+
}
604+
605+
static bool interp__builtin_ffs(InterpState &S, CodePtr OpPC,
606+
const InterpFrame *Frame, const Function *Func,
607+
const CallExpr *Call) {
608+
PrimType ArgT = *S.getContext().classify(Call->getArg(0)->getType());
609+
APSInt Value = peekToAPSInt(S.Stk, ArgT);
610+
611+
uint64_t N = Value.countr_zero();
612+
pushInt(S, N == Value.getBitWidth() ? 0 : N + 1);
613+
return true;
614+
}
615+
582616
bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F,
583617
const CallExpr *Call) {
584618
InterpFrame *Frame = S.Current;
@@ -754,6 +788,39 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F,
754788
return false;
755789
break;
756790

791+
case Builtin::BI__builtin_rotateleft8:
792+
case Builtin::BI__builtin_rotateleft16:
793+
case Builtin::BI__builtin_rotateleft32:
794+
case Builtin::BI__builtin_rotateleft64:
795+
case Builtin::BI_rotl8: // Microsoft variants of rotate left
796+
case Builtin::BI_rotl16:
797+
case Builtin::BI_rotl:
798+
case Builtin::BI_lrotl:
799+
case Builtin::BI_rotl64:
800+
if (!interp__builtin_rotate(S, OpPC, Frame, F, Call, /*Right=*/false))
801+
return false;
802+
break;
803+
804+
case Builtin::BI__builtin_rotateright8:
805+
case Builtin::BI__builtin_rotateright16:
806+
case Builtin::BI__builtin_rotateright32:
807+
case Builtin::BI__builtin_rotateright64:
808+
case Builtin::BI_rotr8: // Microsoft variants of rotate right
809+
case Builtin::BI_rotr16:
810+
case Builtin::BI_rotr:
811+
case Builtin::BI_lrotr:
812+
case Builtin::BI_rotr64:
813+
if (!interp__builtin_rotate(S, OpPC, Frame, F, Call, /*Right=*/true))
814+
return false;
815+
break;
816+
817+
case Builtin::BI__builtin_ffs:
818+
case Builtin::BI__builtin_ffsl:
819+
case Builtin::BI__builtin_ffsll:
820+
if (!interp__builtin_ffs(S, OpPC, Frame, F, Call))
821+
return false;
822+
break;
823+
757824
default:
758825
return false;
759826
}

clang/lib/Analysis/UnsafeBufferUsage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1534,7 +1534,7 @@ static bool hasUnsupportedSpecifiers(const VarDecl *VD,
15341534
// returned by this function is the last location of the last token.
15351535
static SourceRange getSourceRangeToTokenEnd(const Decl *D,
15361536
const SourceManager &SM,
1537-
LangOptions LangOpts) {
1537+
const LangOptions &LangOpts) {
15381538
SourceLocation Begin = D->getBeginLoc();
15391539
SourceLocation
15401540
End = // `D->getEndLoc` should always return the starting location of the

0 commit comments

Comments
 (0)