Skip to content

Commit 414f388

Browse files
Merge branch 'main' into test5
2 parents b19b7cd + 3291372 commit 414f388

File tree

475 files changed

+13854
-8913
lines changed

Some content is hidden

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

475 files changed

+13854
-8913
lines changed

bolt/lib/Core/BinaryEmitter.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -959,9 +959,9 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, const FunctionFragment &FF) {
959959
if (NeedsLPAdjustment)
960960
LPOffsetExpr = MCBinaryExpr::createAdd(
961961
LPOffsetExpr, MCConstantExpr::create(1, *BC.Ctx), *BC.Ctx);
962-
Streamer.emitValue(LPOffsetExpr, 4);
962+
Streamer.emitULEB128Value(LPOffsetExpr);
963963
} else {
964-
Streamer.emitIntValue(0, 4);
964+
Streamer.emitULEB128IntValue(0);
965965
}
966966
};
967967
}
@@ -976,10 +976,12 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, const FunctionFragment &FF) {
976976
Streamer.emitLabel(TTBaseRefLabel);
977977
}
978978

979-
// Emit the landing pad call site table. We use signed data4 since we can emit
980-
// a landing pad in a different part of the split function that could appear
981-
// earlier in the address space than LPStart.
982-
Streamer.emitIntValue(dwarf::DW_EH_PE_sdata4, 1);
979+
// Emit encoding of entries in the call site table. The format is used for the
980+
// call site start, length, and corresponding landing pad.
981+
if (BC.HasFixedLoadAddress)
982+
Streamer.emitIntValue(dwarf::DW_EH_PE_sdata4, 1);
983+
else
984+
Streamer.emitIntValue(dwarf::DW_EH_PE_uleb128, 1);
983985

984986
MCSymbol *CSTStartLabel = BC.Ctx->createTempSymbol("CSTStart");
985987
MCSymbol *CSTEndLabel = BC.Ctx->createTempSymbol("CSTEnd");
@@ -996,8 +998,13 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, const FunctionFragment &FF) {
996998

997999
// Start of the range is emitted relative to the start of current
9981000
// function split part.
999-
Streamer.emitAbsoluteSymbolDiff(BeginLabel, StartSymbol, 4);
1000-
Streamer.emitAbsoluteSymbolDiff(EndLabel, BeginLabel, 4);
1001+
if (BC.HasFixedLoadAddress) {
1002+
Streamer.emitAbsoluteSymbolDiff(BeginLabel, StartSymbol, 4);
1003+
Streamer.emitAbsoluteSymbolDiff(EndLabel, BeginLabel, 4);
1004+
} else {
1005+
Streamer.emitAbsoluteSymbolDiffAsULEB128(BeginLabel, StartSymbol);
1006+
Streamer.emitAbsoluteSymbolDiffAsULEB128(EndLabel, BeginLabel);
1007+
}
10011008
emitLandingPad(CallSite.LP);
10021009
Streamer.emitULEB128IntValue(CallSite.Action);
10031010
}

clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ getFunctionSourceCode(const FunctionDecl *FD, const DeclContext *TargetContext,
239239
return;
240240

241241
for (const NamedDecl *ND : Ref.Targets) {
242+
if (ND->getKind() == Decl::TemplateTypeParm)
243+
return;
242244
if (ND->getDeclContext() != Ref.Targets.front()->getDeclContext()) {
243245
elog("Targets from multiple contexts: {0}, {1}",
244246
printQualifiedName(*Ref.Targets.front()),

clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,29 +411,29 @@ inline typename O1<T, U...>::template O2<V, A>::E O1<T, U...>::template O2<V, A>
411411
R"cpp(
412412
struct Foo {
413413
template <typename T, bool B = true>
414-
void ^bar() {}
414+
T ^bar() { return {}; }
415415
};)cpp",
416416
R"cpp(
417417
struct Foo {
418418
template <typename T, bool B = true>
419-
void bar() ;
419+
T bar() ;
420420
};template <typename T, bool B>
421-
inline void Foo::bar() {}
421+
inline T Foo::bar() { return {}; }
422422
)cpp",
423423
""},
424424

425425
// Class template with member template
426426
{
427427
R"cpp(
428428
template <typename T> struct Foo {
429-
template <typename U> void ^bar(const T& t, const U& u) {}
429+
template <typename U> T ^bar(const T& t, const U& u) { return {}; }
430430
};)cpp",
431431
R"cpp(
432432
template <typename T> struct Foo {
433-
template <typename U> void bar(const T& t, const U& u) ;
433+
template <typename U> T bar(const T& t, const U& u) ;
434434
};template <typename T>
435435
template <typename U>
436-
inline void Foo<T>::bar(const T& t, const U& u) {}
436+
inline T Foo<T>::bar(const T& t, const U& u) { return {}; }
437437
)cpp",
438438
""},
439439
};

clang-tools-extra/test/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ set(CLANG_TOOLS_TEST_DEPS
5050
clang-resource-headers
5151

5252
clang-tidy
53-
# Clang-tidy tests need clang for building modules.
54-
clang
5553
)
5654

5755
# Add lit test dependencies.

clang/docs/InternalsManual.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ wording a diagnostic.
160160
named in a diagnostic message. e.g., prefer wording like ``'this' pointer
161161
cannot be null in well-defined C++ code`` over wording like ``this pointer
162162
cannot be null in well-defined C++ code``.
163+
* Prefer diagnostic wording without contractions whenever possible. The single
164+
quote in a contraction can be visually distracting due to its use with
165+
syntactic constructs and contractions can be harder to understand for non-
166+
native English speakers.
163167

164168
The Format String
165169
^^^^^^^^^^^^^^^^^

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ Non-comprehensive list of changes in this release
357357

358358
- ``__builtin_reduce_add`` function can now be used in constant expressions.
359359
- ``__builtin_reduce_mul`` function can now be used in constant expressions.
360+
- ``__builtin_reduce_and`` function can now be used in constant expressions.
360361

361362
New Compiler Flags
362363
------------------
@@ -558,6 +559,8 @@ Improvements to Clang's diagnostics
558559

559560
- Clang now diagnoses ``= delete("reason")`` extension warnings only in pedantic mode rather than on by default. (#GH109311).
560561

562+
- Clang now diagnoses missing return value in functions containing ``if consteval`` (#GH116485).
563+
561564
Improvements to Clang's time-trace
562565
----------------------------------
563566

clang/include/clang/Basic/Attr.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4888,3 +4888,10 @@ def ClspvLibclcBuiltin: InheritableAttr {
48884888
let Documentation = [ClspvLibclcBuiltinDoc];
48894889
let SimpleHandler = 1;
48904890
}
4891+
4892+
def NoTrivialAutoVarInit: InheritableAttr {
4893+
let Spellings = [Declspec<"no_init_all">];
4894+
let Subjects = SubjectList<[Function, Tag]>;
4895+
let Documentation = [NoTrivialAutoVarInitDocs];
4896+
let SimpleHandler = 1;
4897+
}

clang/include/clang/Basic/AttrDocs.td

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3921,17 +3921,42 @@ have their lifetimes extended.
39213921
def LifetimeCaptureByDocs : Documentation {
39223922
let Category = DocCatFunction;
39233923
let Content = [{
3924-
Similar to `lifetimebound`_, the ``lifetime_capture_by(X)`` attribute on a function
3925-
parameter or implicit object parameter indicates that that objects that are referred to
3926-
by that parameter may also be referred to by the capturing entity ``X``.
3924+
Similar to `lifetimebound`_, the ``lifetime_capture_by(X)`` attribute on a
3925+
function parameter or implicit object parameter indicates that the capturing
3926+
entity ``X`` may refer to the object referred by that parameter.
3927+
3928+
Below is a list of types of the parameters and what they're considered to refer to:
3929+
3930+
- A reference param (of non-view type) is considered to refer to its referenced object.
3931+
- A pointer param (of non-view type) is considered to refer to its pointee.
3932+
- View type param (type annotated with ``[[gsl::Pointer()]]``) is considered to refer
3933+
to its pointee (gsl owner). This holds true even if the view type appears as a reference
3934+
in the parameter. For example, both ``std::string_view`` and
3935+
``const std::string_view &`` are considered to refer to a ``std::string``.
3936+
- A ``std::initializer_list<T>`` is considered to refer to its underlying array.
3937+
- Aggregates (arrays and simple ``struct``\s) are considered to refer to all
3938+
objects that their transitive subobjects refer to.
3939+
3940+
Clang would diagnose when a temporary object is used as an argument to such an
3941+
annotated parameter.
3942+
In this case, the capturing entity ``X`` could capture a dangling reference to this
3943+
temporary object.
39273944

3928-
By default, a reference is considered to refer to its referenced object, a
3929-
pointer is considered to refer to its pointee, a ``std::initializer_list<T>``
3930-
is considered to refer to its underlying array, and aggregates (arrays and
3931-
simple ``struct``\s) are considered to refer to all objects that their
3932-
transitive subobjects refer to.
3945+
.. code-block:: c++
3946+
3947+
void addToSet(std::string_view a [[clang::lifetime_capture_by(s)]], std::set<std::string_view>& s) {
3948+
s.insert(a);
3949+
}
3950+
void use() {
3951+
std::set<std::string_view> s;
3952+
addToSet(std::string(), s); // Warning: object whose reference is captured by 's' will be destroyed at the end of the full-expression.
3953+
// ^^^^^^^^^^^^^
3954+
std::string local;
3955+
addToSet(local, s); // Ok.
3956+
}
39333957

39343958
The capturing entity ``X`` can be one of the following:
3959+
39353960
- Another (named) function parameter.
39363961

39373962
.. code-block:: c++
@@ -3951,7 +3976,7 @@ The capturing entity ``X`` can be one of the following:
39513976
std::set<std::string_view> s;
39523977
};
39533978

3954-
- 'global', 'unknown' (without quotes).
3979+
- `global`, `unknown`.
39553980

39563981
.. code-block:: c++
39573982

@@ -3983,6 +4008,22 @@ The attribute supports specifying more than one capturing entities:
39834008
s2.insert(a);
39844009
}
39854010

4011+
Limitation: The capturing entity ``X`` is not used by the analysis and is
4012+
used for documentation purposes only. This is because the analysis is
4013+
statement-local and only detects use of a temporary as an argument to the
4014+
annotated parameter.
4015+
4016+
.. code-block:: c++
4017+
4018+
void addToSet(std::string_view a [[clang::lifetime_capture_by(s)]], std::set<std::string_view>& s);
4019+
void use() {
4020+
std::set<std::string_view> s;
4021+
if (foo()) {
4022+
std::string str;
4023+
addToSet(str, s); // Not detected.
4024+
}
4025+
}
4026+
39864027
.. _`lifetimebound`: https://clang.llvm.org/docs/AttributeReference.html#lifetimebound
39874028
}];
39884029
}
@@ -8719,6 +8760,18 @@ Attribute used by `clspv`_ (OpenCL-C to Vulkan SPIR-V compiler) to identify func
87198760
}];
87208761
}
87218762

8763+
def NoTrivialAutoVarInitDocs : Documentation {
8764+
let Category = DocCatDecl;
8765+
let Content = [{
8766+
The ``__declspec(no_init_all)`` attribute disables the automatic initialization that the
8767+
`-ftrivial-auto-var-init`_ flag would have applied to locals in a marked function, or instances of
8768+
a marked type. Note that this attribute has no effect for locals that are automatically initialized
8769+
without the `-ftrivial-auto-var-init`_ flag.
8770+
8771+
.. _`-ftrivial-auto-var-init`: ClangCommandLineReference.html#cmdoption-clang-ftrivial-auto-var-init
8772+
}];
8773+
}
8774+
87228775
def DocCatNonBlockingNonAllocating : DocumentationCategory<"Performance Constraint Attributes"> {
87238776
let Content = [{
87248777
The ``nonblocking``, ``blocking``, ``nonallocating`` and ``allocating`` attributes can be attached

clang/include/clang/Basic/Builtins.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1498,7 +1498,7 @@ def ReduceOr : Builtin {
14981498

14991499
def ReduceAnd : Builtin {
15001500
let Spellings = ["__builtin_reduce_and"];
1501-
let Attributes = [NoThrow, Const, CustomTypeChecking];
1501+
let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
15021502
let Prototype = "void(...)";
15031503
}
15041504

clang/include/clang/Basic/BuiltinsLoongArchLASX.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ TARGET_BUILTIN(__builtin_lasx_xvor_v, "V32UcV32UcV32Uc", "nc", "lasx")
371371
TARGET_BUILTIN(__builtin_lasx_xvxor_v, "V32UcV32UcV32Uc", "nc", "lasx")
372372
TARGET_BUILTIN(__builtin_lasx_xvnor_v, "V32UcV32UcV32Uc", "nc", "lasx")
373373
TARGET_BUILTIN(__builtin_lasx_xvandn_v, "V32UcV32UcV32Uc", "nc", "lasx")
374-
TARGET_BUILTIN(__builtin_lasx_xvorn_v, "V32ScV32ScV32Sc", "nc", "lasx")
374+
TARGET_BUILTIN(__builtin_lasx_xvorn_v, "V32UcV32UcV32Uc", "nc", "lasx")
375375

376376
TARGET_BUILTIN(__builtin_lasx_xvandi_b, "V32UcV32UcIUi", "nc", "lasx")
377377
TARGET_BUILTIN(__builtin_lasx_xvori_b, "V32UcV32UcIUi", "nc", "lasx")

0 commit comments

Comments
 (0)