Skip to content

Commit 263e606

Browse files
authored
Merge branch 'main' into fix/125810
2 parents 0d61f13 + 395bdeb commit 263e606

File tree

1,196 files changed

+123297
-121749
lines changed

Some content is hidden

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

1,196 files changed

+123297
-121749
lines changed

.ci/metrics/metrics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
# This means we essentially have a list of workflows sorted by creation date,
4444
# and that's all we can deduce from it. So for each iteration, we'll blindly
4545
# process the last N workflows.
46-
GITHUB_WORKFLOWS_MAX_PROCESS_COUNT = 1000
46+
GITHUB_WORKFLOWS_MAX_PROCESS_COUNT = 2000
4747
# Second reason for the cut: reaching a workflow older than X.
4848
# This means we will miss long-tails (exceptional jobs running for more than
4949
# X hours), but that's also the case with the count cutoff above.

bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
244244
Inst.clear();
245245
Inst.addOperand(MCOperand::createExpr(RISCVMCExpr::create(
246246
MCSymbolRefExpr::create(Target, MCSymbolRefExpr::VK_None, *Ctx),
247-
RISCVMCExpr::VK_RISCV_CALL, *Ctx)));
247+
RISCVMCExpr::VK_CALL, *Ctx)));
248248
}
249249

250250
void createCall(MCInst &Inst, const MCSymbol *Target,
@@ -434,19 +434,19 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
434434
case ELF::R_RISCV_TLS_GOT_HI20:
435435
// The GOT is reused so no need to create GOT relocations
436436
case ELF::R_RISCV_PCREL_HI20:
437-
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_RISCV_PCREL_HI, Ctx);
437+
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_PCREL_HI, Ctx);
438438
case ELF::R_RISCV_PCREL_LO12_I:
439439
case ELF::R_RISCV_PCREL_LO12_S:
440-
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_RISCV_PCREL_LO, Ctx);
440+
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_PCREL_LO, Ctx);
441441
case ELF::R_RISCV_HI20:
442-
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_RISCV_HI, Ctx);
442+
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_HI, Ctx);
443443
case ELF::R_RISCV_LO12_I:
444444
case ELF::R_RISCV_LO12_S:
445-
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_RISCV_LO, Ctx);
445+
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_LO, Ctx);
446446
case ELF::R_RISCV_CALL:
447-
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_RISCV_CALL, Ctx);
447+
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_CALL, Ctx);
448448
case ELF::R_RISCV_CALL_PLT:
449-
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_RISCV_CALL_PLT, Ctx);
449+
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_CALL_PLT, Ctx);
450450
}
451451
}
452452

@@ -471,8 +471,8 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
471471
switch (cast<RISCVMCExpr>(ImmExpr)->getKind()) {
472472
default:
473473
return false;
474-
case RISCVMCExpr::VK_RISCV_CALL:
475-
case RISCVMCExpr::VK_RISCV_CALL_PLT:
474+
case RISCVMCExpr::VK_CALL:
475+
case RISCVMCExpr::VK_CALL_PLT:
476476
return true;
477477
}
478478
}

clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
namespace clang::tidy::bugprone {
2020
using ast_matchers::MatchFinder;
2121
using dataflow::UncheckedOptionalAccessDiagnoser;
22+
using dataflow::UncheckedOptionalAccessDiagnostic;
2223
using dataflow::UncheckedOptionalAccessModel;
2324

2425
static constexpr llvm::StringLiteral FuncID("fun");
@@ -52,14 +53,16 @@ void UncheckedOptionalAccessCheck::check(
5253
UncheckedOptionalAccessDiagnoser Diagnoser(ModelOptions);
5354
// FIXME: Allow user to set the (defaulted) SAT iterations max for
5455
// `diagnoseFunction` with config options.
55-
if (llvm::Expected<llvm::SmallVector<SourceLocation>> Locs =
56-
dataflow::diagnoseFunction<UncheckedOptionalAccessModel,
57-
SourceLocation>(*FuncDecl, *Result.Context,
58-
Diagnoser))
59-
for (const SourceLocation &Loc : *Locs)
60-
diag(Loc, "unchecked access to optional value");
56+
if (llvm::Expected<llvm::SmallVector<UncheckedOptionalAccessDiagnostic>>
57+
Diags = dataflow::diagnoseFunction<UncheckedOptionalAccessModel,
58+
UncheckedOptionalAccessDiagnostic>(
59+
*FuncDecl, *Result.Context, Diagnoser))
60+
for (const UncheckedOptionalAccessDiagnostic &Diag : *Diags) {
61+
diag(Diag.Range.getBegin(), "unchecked access to optional value")
62+
<< Diag.Range;
63+
}
6164
else
62-
llvm::consumeError(Locs.takeError());
65+
llvm::consumeError(Diags.takeError());
6366
}
6467

6568
} // namespace clang::tidy::bugprone

clang/docs/ClangOffloadBundler.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,15 +266,14 @@ without differentiation based on offload kind.
266266
The target triple of the code object. See `Target Triple
267267
<https://clang.llvm.org/docs/CrossCompilation.html#target-triple>`_.
268268

269-
The bundler accepts target triples with or without the optional environment
270-
field:
269+
LLVM target triples can be with or without the optional environment field:
271270

272271
``<arch><sub>-<vendor>-<sys>``, or
273272
``<arch><sub>-<vendor>-<sys>-<env>``
274273

275-
However, in order to standardize outputs for tools that consume bitcode
276-
bundles, bundles written by the bundler internally use only the 4-field
277-
target triple:
274+
However, in order to standardize outputs for tools that consume bitcode bundles
275+
and to parse target ID containing dashes, the bundler only accepts target
276+
triples in the 4-field format:
278277

279278
``<arch><sub>-<vendor>-<sys>-<env>``
280279

@@ -543,4 +542,4 @@ The compressed offload bundle begins with a header followed by the compressed bi
543542
- **Compressed Data**:
544543
The actual compressed binary data follows the header. Its size can be inferred from the total size of the file minus the header size.
545544

546-
> **Note**: Version 3 of the format is under development. It uses 64-bit fields for Total File Size and Uncompressed Binary Size to support files larger than 4GB. To experiment with version 3, set the environment variable `COMPRESSED_BUNDLE_FORMAT_VERSION=3`. This support is experimental and not recommended for production use.
545+
> **Note**: Version 3 of the format is under development. It uses 64-bit fields for Total File Size and Uncompressed Binary Size to support files larger than 4GB. To experiment with version 3, set the environment variable `COMPRESSED_BUNDLE_FORMAT_VERSION=3`. This support is experimental and not recommended for production use.

clang/docs/LanguageExtensions.rst

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,6 +1652,7 @@ Designated initializers (N494) C
16521652
Array & element qualification (N2607) C23 C89
16531653
Attributes (N2335) C23 C89
16541654
``#embed`` (N3017) C23 C89, C++
1655+
Octal literals prefixed with ``0o`` or ``0O`` C2y C89, C++
16551656
============================================= ================================ ============= =============
16561657

16571658
Builtin type aliases
@@ -1911,6 +1912,40 @@ A simplistic usage example as might be seen in standard C++ headers follows:
19111912
// Emulate type trait for compatibility with other compilers.
19121913
#endif
19131914

1915+
1916+
.. _builtin_structured_binding_size-doc:
1917+
1918+
__builtin_structured_binding_size (C++)
1919+
---------------------------------------
1920+
1921+
The ``__builtin_structured_binding_size(T)`` type trait returns
1922+
the *structured binding size* ([dcl.struct.bind]) of type ``T``
1923+
1924+
This is equivalent to the size of the pack ``p`` in ``auto&& [...p] = declval<T&>();``.
1925+
If the argument cannot be decomposed, ``__builtin_structured_binding_size(T)``
1926+
is not a valid expression (``__builtin_structured_binding_size`` is SFINAE-friendly).
1927+
1928+
builtin arrays, builtin SIMD vectors,
1929+
builtin complex types, *tuple-like* types, and decomposable class types
1930+
are decomposable types.
1931+
1932+
A type is considered a valid *tuple-like* if ``std::tuple_size_v<T>`` is a valid expression,
1933+
even if there is no valid ``std::tuple_element`` specialization or suitable
1934+
``get`` function for that type.
1935+
1936+
.. code-block:: c++
1937+
1938+
template<std::size_t Idx, typename T>
1939+
requires (Idx < __builtin_structured_binding_size(T))
1940+
decltype(auto) constexpr get_binding(T&& obj) {
1941+
auto && [...p] = std::forward<T>(obj);
1942+
return p...[Idx];
1943+
}
1944+
struct S { int a = 0, b = 42; };
1945+
static_assert(__builtin_structured_binding_size(S) == 2);
1946+
static_assert(get_binding<1>(S{}) == 42);
1947+
1948+
19141949
Blocks
19151950
======
19161951

@@ -1959,6 +1994,32 @@ references can be used instead of numeric references.
19591994
return -1;
19601995
}
19611996

1997+
1998+
Constexpr strings in GNU ASM statememts
1999+
=======================================
2000+
2001+
In C++11 mode (and greater), Clang supports specifying the template,
2002+
constraints, and clobber strings with a parenthesized constant expression
2003+
producing an object with the following member functions
2004+
2005+
.. code-block:: c++
2006+
2007+
constexpr const char* data() const;
2008+
constexpr size_t size() const;
2009+
2010+
such as ``std::string``, ``std::string_view``, ``std::vector<char>``.
2011+
This mechanism follow the same rules as ``static_assert`` messages in
2012+
C++26, see ``[dcl.pre]/p12``.
2013+
2014+
Query for this feature with ``__has_extension(gnu_asm_constexpr_strings)``.
2015+
2016+
.. code-block:: c++
2017+
2018+
int foo() {
2019+
asm((std::string_view("nop")) ::: (std::string_view("memory")));
2020+
}
2021+
2022+
19622023
Objective-C Features
19632024
====================
19642025

clang/docs/ReleaseNotes.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ What's New in Clang |release|?
7474
C++ Language Changes
7575
--------------------
7676

77+
- Added a :ref:`__builtin_structured_binding_size <builtin_structured_binding_size-doc>` (T)
78+
builtin that returns the number of structured bindings that would be produced by destructuring ``T``.
79+
80+
- Similarly to GCC, Clang now supports constant expressions in
81+
the strings of a GNU ``asm`` statement.
82+
83+
.. code-block:: c++
84+
85+
int foo() {
86+
asm((std::string_view("nop")) ::: (std::string_view("memory")));
87+
}
88+
7789
C++2c Feature Support
7890
^^^^^^^^^^^^^^^^^^^^^
7991

@@ -120,6 +132,13 @@ C2y Feature Support
120132
- Implemented `WG14 N3411 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3411.pdf>`_
121133
which allows a source file to not end with a newline character. This is still
122134
reported as a conforming extension in earlier language modes.
135+
- Implemented `WG14 N3353 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3353.htm>_`
136+
which adds the new ``0o`` and ``0O`` ocal literal prefixes and deprecates
137+
octal literals other than ``0`` which do not start with the new prefix. This
138+
feature is exposed in earlier language modes and in C++ as an extension. The
139+
paper also introduced octal and hexadecimal delimited escape sequences (e.g.,
140+
``"\x{12}\o{12}"``) which are also supported as an extension in older C
141+
language modes.
123142

124143
C23 Feature Support
125144
^^^^^^^^^^^^^^^^^^^
@@ -251,6 +270,9 @@ Improvements to Clang's diagnostics
251270
- The ``-Wsign-compare`` warning now treats expressions with bitwise not(~) and minus(-) as signed integers
252271
except for the case where the operand is an unsigned integer
253272
and throws warning if they are compared with unsigned integers (##18878).
273+
- The ``-Wunnecessary-virtual-specifier`` warning has been added to warn about
274+
methods which are marked as virtual inside a ``final`` class, and hence can
275+
never be overridden.
254276

255277
- Improve the diagnostics for chained comparisons to report actual expressions and operators (#GH129069).
256278

clang/include/clang/AST/Expr.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,10 @@ class Expr : public ValueStmt {
787787
const Expr *PtrExpression, ASTContext &Ctx,
788788
EvalResult &Status) const;
789789

790+
bool EvaluateCharRangeAsString(APValue &Result, const Expr *SizeExpression,
791+
const Expr *PtrExpression, ASTContext &Ctx,
792+
EvalResult &Status) const;
793+
790794
/// If the current Expr can be evaluated to a pointer to a null-terminated
791795
/// constant string, return the constant string (without the terminating
792796
/// null).

clang/include/clang/AST/ExprCXX.h

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include <cstdint>
5252
#include <memory>
5353
#include <optional>
54+
#include <variant>
5455

5556
namespace clang {
5657

@@ -2765,27 +2766,27 @@ class CXXPseudoDestructorExpr : public Expr {
27652766
/// \endcode
27662767
class TypeTraitExpr final
27672768
: public Expr,
2768-
private llvm::TrailingObjects<TypeTraitExpr, TypeSourceInfo *> {
2769+
private llvm::TrailingObjects<TypeTraitExpr, APValue, TypeSourceInfo *> {
27692770
/// The location of the type trait keyword.
27702771
SourceLocation Loc;
27712772

27722773
/// The location of the closing parenthesis.
27732774
SourceLocation RParenLoc;
27742775

2775-
// Note: The TypeSourceInfos for the arguments are allocated after the
2776-
// TypeTraitExpr.
2777-
27782776
TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind,
2779-
ArrayRef<TypeSourceInfo *> Args,
2780-
SourceLocation RParenLoc,
2781-
bool Value);
2777+
ArrayRef<TypeSourceInfo *> Args, SourceLocation RParenLoc,
2778+
std::variant<bool, APValue> Value);
27822779

27832780
TypeTraitExpr(EmptyShell Empty) : Expr(TypeTraitExprClass, Empty) {}
27842781

27852782
size_t numTrailingObjects(OverloadToken<TypeSourceInfo *>) const {
27862783
return getNumArgs();
27872784
}
27882785

2786+
size_t numTrailingObjects(OverloadToken<APValue>) const {
2787+
return TypeTraitExprBits.IsBooleanTypeTrait ? 0 : 1;
2788+
}
2789+
27892790
public:
27902791
friend class ASTStmtReader;
27912792
friend class ASTStmtWriter;
@@ -2798,19 +2799,34 @@ class TypeTraitExpr final
27982799
SourceLocation RParenLoc,
27992800
bool Value);
28002801

2802+
static TypeTraitExpr *Create(const ASTContext &C, QualType T,
2803+
SourceLocation Loc, TypeTrait Kind,
2804+
ArrayRef<TypeSourceInfo *> Args,
2805+
SourceLocation RParenLoc, APValue Value);
2806+
28012807
static TypeTraitExpr *CreateDeserialized(const ASTContext &C,
2808+
bool IsStoredAsBool,
28022809
unsigned NumArgs);
28032810

28042811
/// Determine which type trait this expression uses.
28052812
TypeTrait getTrait() const {
28062813
return static_cast<TypeTrait>(TypeTraitExprBits.Kind);
28072814
}
28082815

2809-
bool getValue() const {
2810-
assert(!isValueDependent());
2816+
bool isStoredAsBoolean() const {
2817+
return TypeTraitExprBits.IsBooleanTypeTrait;
2818+
}
2819+
2820+
bool getBoolValue() const {
2821+
assert(!isValueDependent() && TypeTraitExprBits.IsBooleanTypeTrait);
28112822
return TypeTraitExprBits.Value;
28122823
}
28132824

2825+
const APValue &getAPValue() const {
2826+
assert(!isValueDependent() && !TypeTraitExprBits.IsBooleanTypeTrait);
2827+
return *getTrailingObjects<APValue>();
2828+
}
2829+
28142830
/// Determine the number of arguments to this type trait.
28152831
unsigned getNumArgs() const { return TypeTraitExprBits.NumArgs; }
28162832

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2410,15 +2410,15 @@ DEF_TRAVERSE_DECL(ImplicitConceptSpecializationDecl, {
24102410
}
24112411

24122412
DEF_TRAVERSE_STMT(GCCAsmStmt, {
2413-
TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getAsmString());
2413+
TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getAsmStringExpr());
24142414
for (unsigned I = 0, E = S->getNumInputs(); I < E; ++I) {
2415-
TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getInputConstraintLiteral(I));
2415+
TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getInputConstraintExpr(I));
24162416
}
24172417
for (unsigned I = 0, E = S->getNumOutputs(); I < E; ++I) {
2418-
TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOutputConstraintLiteral(I));
2418+
TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOutputConstraintExpr(I));
24192419
}
24202420
for (unsigned I = 0, E = S->getNumClobbers(); I < E; ++I) {
2421-
TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getClobberStringLiteral(I));
2421+
TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getClobberExpr(I));
24222422
}
24232423
// children() iterates over inputExpr and outputExpr.
24242424
})

0 commit comments

Comments
 (0)