Skip to content

Commit 7d0e1cb

Browse files
authored
Merge branch 'main' into loop-vectorize/simplify-or-and
2 parents 7661966 + 8e4bda1 commit 7d0e1cb

File tree

257 files changed

+7869
-3546
lines changed

Some content is hidden

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

257 files changed

+7869
-3546
lines changed

bolt/test/link_fdata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
# Regexes to extract FDATA lines from input and parse FDATA and pre-aggregated
3434
# profile data
35-
prefix_pat = re.compile(f"^# {args.prefix}: (.*)")
35+
prefix_pat = re.compile(f"^(#|//) {args.prefix}: (.*)")
3636

3737
# FDATA records:
3838
# <is symbol?> <closest elf symbol or DSO name> <relative FROM address>
@@ -61,7 +61,7 @@
6161
prefix_match = prefix_pat.match(line)
6262
if not prefix_match:
6363
continue
64-
profile_line = prefix_match.group(1)
64+
profile_line = prefix_match.group(2)
6565
fdata_match = fdata_pat.match(profile_line)
6666
preagg_match = preagg_pat.match(profile_line)
6767
nolbr_match = nolbr_pat.match(profile_line)

bolt/test/timers.c

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
/* This test checks timers for metadata manager phases.
2-
# RUN: %clang %cflags %s -o %t.exe
3-
# RUN: link_fdata %s %t.exe %t.fdata
4-
# RUN: llvm-bolt %t.exe -o %t.null --data %t.fdata -w %t.yaml --time-rewrite \
5-
# RUN: 2>&1 | FileCheck %s
6-
# RUN: link_fdata %s %t.exe %t.preagg PREAGG
7-
# RUN: perf2bolt %t.exe -o %t.null -p %t.preagg --pa --time-rewrite \
8-
# RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-P2B
1+
// This test checks timers for metadata manager phases.
2+
// RUN: %clang %cflags %s -o %t.exe
3+
// RUN: link_fdata %s %t.exe %t.fdata
4+
// RUN: llvm-bolt %t.exe -o %t.null --data %t.fdata -w %t.yaml --time-rewrite \
5+
// RUN: 2>&1 | FileCheck %s
6+
// RUN: link_fdata %s %t.exe %t.preagg PREAGG
7+
// RUN: perf2bolt %t.exe -o %t.null -p %t.preagg --pa --time-rewrite \
8+
// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-P2B
99

10-
# CHECK-DAG: update metadata post-emit
11-
# CHECK-DAG: process section metadata
12-
# CHECK-DAG: process metadata pre-CFG
13-
# CHECK-DAG: process metadata post-CFG
14-
# CHECK-DAG: finalize metadata pre-emit
10+
// CHECK-DAG: update metadata post-emit
11+
// CHECK-DAG: process section metadata
12+
// CHECK-DAG: process metadata pre-CFG
13+
// CHECK-DAG: process metadata post-CFG
14+
// CHECK-DAG: finalize metadata pre-emit
1515

16-
# CHECK-P2B-DAG: process section metadata
17-
# CHECK-P2B-DAG: process metadata pre-CFG
16+
// CHECK-P2B-DAG: process section metadata
17+
// CHECK-P2B-DAG: process metadata pre-CFG
1818

19-
# FDATA: 0 [unknown] 0 1 main 0 1 0
20-
# PREAGG: B X:0 #main# 1 0
21-
*/
19+
// FDATA: 0 [unknown] 0 1 main 0 1 0
20+
// PREAGG: B X:0 #main# 1 0
2221
int main() { return 0; }

clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-optional-access.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,17 @@ void nullable_value_after_swap(BloombergLP::bdlb::NullableValue<int> &opt1, Bloo
141141
}
142142
}
143143

144+
void assertion_handler() __attribute__((analyzer_noreturn));
145+
146+
void function_calling_analyzer_noreturn(const bsl::optional<int>& opt)
147+
{
148+
if (!opt) {
149+
assertion_handler();
150+
}
151+
152+
*opt; // no-warning: The previous condition guards this dereference.
153+
}
154+
144155
template <typename T>
145156
void function_template_without_user(const absl::optional<T> &opt) {
146157
opt.value(); // no-warning

clang/docs/LanguageExtensions.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,6 +2049,9 @@ The following type trait primitives are supported by Clang. Those traits marked
20492049
Returns true if a reference ``T`` can be copy-initialized from a temporary of type
20502050
a non-cv-qualified ``U``.
20512051
* ``__underlying_type`` (C++, GNU, Microsoft)
2052+
* ``__builtin_lt_synthesises_from_spaceship``, ``__builtin_gt_synthesises_from_spaceship``,
2053+
``__builtin_le_synthesises_from_spaceship``, ``__builtin_ge_synthesises_from_spaceship`` (Clang):
2054+
These builtins can be used to determine whether the corresponding operator is synthesised from a spaceship operator.
20522055

20532056
In addition, the following expression traits are supported:
20542057

clang/docs/ReleaseNotes.rst

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ What's New in Clang |release|?
109109
C++ Language Changes
110110
--------------------
111111

112+
- A new family of builtins ``__builtin_*_synthesises_from_spaceship`` has been added. These can be queried to know
113+
whether the ``<`` (``lt``), ``>`` (``gt``), ``<=`` (``le``), or ``>=`` (``ge``) operators are synthesised from a
114+
``<=>``. This makes it possible to optimize certain facilities by using the ``<=>`` operation directly instead of
115+
doing multiple comparisons.
116+
112117
C++2c Feature Support
113118
^^^^^^^^^^^^^^^^^^^^^
114119

@@ -241,11 +246,13 @@ Improvements to Clang's diagnostics
241246
"format specifies type 'unsigned int' but the argument has type 'int', which differs in signedness [-Wformat-signedness]"
242247
"signedness of format specifier 'u' is incompatible with 'c' [-Wformat-signedness]"
243248
and the API-visible diagnostic id will be appropriate.
244-
249+
245250
- Fixed false positives in ``-Waddress-of-packed-member`` diagnostics when
246251
potential misaligned members get processed before they can get discarded.
247252
(#GH144729)
248253

254+
- Clang now emits dignostic with correct message in case of assigning to const reference captured in lambda. (#GH105647)
255+
249256
- Fixed false positive in ``-Wmissing-noreturn`` diagnostic when it was requiring the usage of
250257
``[[noreturn]]`` on lambdas before C++23 (#GH154493).
251258

@@ -263,6 +270,10 @@ Improvements to Clang's diagnostics
263270
decorated with the ``alloc_size`` attribute don't allocate enough space for
264271
the target pointer type.
265272

273+
- The :doc:`ThreadSafetyAnalysis` attributes ``ACQUIRED_BEFORE(...)`` and
274+
``ACQUIRED_AFTER(...)`` have been moved to the stable feature set and no
275+
longer require ``-Wthread-safety-beta`` to be used.
276+
266277
Improvements to Clang's time-trace
267278
----------------------------------
268279

@@ -273,7 +284,7 @@ Bug Fixes in This Version
273284
-------------------------
274285
- Fix a crash when marco name is empty in ``#pragma push_macro("")`` or
275286
``#pragma pop_macro("")``. (#GH149762).
276-
- Fix a crash in variable length array (e.g. ``int a[*]``) function parameter type
287+
- Fix a crash in variable length array (e.g. ``int a[*]``) function parameter type
277288
being used in ``_Countof`` expression. (#GH152826).
278289
- ``-Wunreachable-code`` now diagnoses tautological or contradictory
279290
comparisons such as ``x != 0 || x != 1.0`` and ``x == 0 && x == 1.0`` on
@@ -358,7 +369,7 @@ X86 Support
358369
arithmetic can now be used in C++ constant expressions.
359370
- Some SSE, AVX and AVX512 intrinsics have been converted to wrap
360371
generic __builtin intrinsics.
361-
- NOTE: Please avoid use of the __builtin_ia32_* intrinsics - these are not
372+
- NOTE: Please avoid use of the __builtin_ia32_* intrinsics - these are not
362373
guaranteed to exist in future releases, or match behaviour with previous
363374
releases of clang or other compilers.
364375

clang/include/clang/AST/Decl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2668,6 +2668,10 @@ class FunctionDecl : public DeclaratorDecl,
26682668
/// an attribute on its declaration or its type.
26692669
bool isNoReturn() const;
26702670

2671+
/// Determines whether this function is known to be 'noreturn' for analyzer,
2672+
/// through an `analyzer_noreturn` attribute on its declaration.
2673+
bool isAnalyzerNoReturn() const;
2674+
26712675
/// True if the function was a definition but its body was skipped.
26722676
bool hasSkippedBody() const { return FunctionDeclBits.HasSkippedBody; }
26732677
void setHasSkippedBody(bool Skipped = true) {

clang/include/clang/Basic/TokenKinds.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,10 @@ TYPE_TRAIT_1(__can_pass_in_regs, CanPassInRegs, KEYCXX)
552552
TYPE_TRAIT_2(__reference_binds_to_temporary, ReferenceBindsToTemporary, KEYCXX)
553553
TYPE_TRAIT_2(__reference_constructs_from_temporary, ReferenceConstructsFromTemporary, KEYCXX)
554554
TYPE_TRAIT_2(__reference_converts_from_temporary, ReferenceConvertsFromTemporary, KEYCXX)
555+
TYPE_TRAIT_2(__builtin_lt_synthesises_from_spaceship, LtSynthesisesFromSpaceship, KEYCXX)
556+
TYPE_TRAIT_2(__builtin_le_synthesises_from_spaceship, LeSynthesisesFromSpaceship, KEYCXX)
557+
TYPE_TRAIT_2(__builtin_gt_synthesises_from_spaceship, GtSynthesisesFromSpaceship, KEYCXX)
558+
TYPE_TRAIT_2(__builtin_ge_synthesises_from_spaceship, GeSynthesisesFromSpaceship, KEYCXX)
555559
// IsDeducible is only used internally by clang for CTAD implementation and
556560
// is not exposed to users.
557561
TYPE_TRAIT_2(/*EmptySpellingName*/, IsDeducible, KEYCXX)

clang/include/clang/Frontend/ASTUnit.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,17 @@ class ASTUnit {
629629
return StoredDiagnostics.end();
630630
}
631631

632+
using diags_range = llvm::iterator_range<stored_diag_iterator>;
633+
using const_diags_range = llvm::iterator_range<stored_diag_const_iterator>;
634+
635+
diags_range storedDiagnostics() {
636+
return {stored_diag_begin(), stored_diag_end()};
637+
}
638+
639+
const_diags_range storedDiagnostics() const {
640+
return {stored_diag_begin(), stored_diag_end()};
641+
}
642+
632643
unsigned stored_diag_size() const { return StoredDiagnostics.size(); }
633644

634645
stored_diag_iterator stored_diag_afterDriver_begin() {

clang/include/clang/Tooling/Tooling.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "clang/AST/ASTConsumer.h"
3333
#include "clang/Basic/FileManager.h"
3434
#include "clang/Basic/LLVM.h"
35+
#include "clang/Frontend/ASTUnit.h"
3536
#include "clang/Frontend/FrontendAction.h"
3637
#include "clang/Frontend/PCHContainerOperations.h"
3738
#include "clang/Tooling/ArgumentsAdjusters.h"
@@ -239,7 +240,8 @@ std::unique_ptr<ASTUnit> buildASTFromCodeWithArgs(
239240
const FileContentMappings &VirtualMappedFiles = FileContentMappings(),
240241
DiagnosticConsumer *DiagConsumer = nullptr,
241242
IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS =
242-
llvm::vfs::getRealFileSystem());
243+
llvm::vfs::getRealFileSystem(),
244+
CaptureDiagsKind CaptureKind = CaptureDiagsKind::None);
243245

244246
/// Utility to run a FrontendAction in a single clang invocation.
245247
class ToolInvocation {

clang/lib/AST/Decl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3600,6 +3600,10 @@ bool FunctionDecl::isNoReturn() const {
36003600
return false;
36013601
}
36023602

3603+
bool FunctionDecl::isAnalyzerNoReturn() const {
3604+
return hasAttr<AnalyzerNoReturnAttr>();
3605+
}
3606+
36033607
bool FunctionDecl::isMemberLikeConstrainedFriend() const {
36043608
// C++20 [temp.friend]p9:
36053609
// A non-template friend declaration with a requires-clause [or]

0 commit comments

Comments
 (0)