Skip to content

Commit 4600de9

Browse files
committed
Merge from 'main' to 'sycl-web' (90 commits)
CONFLICT (content): Merge conflict in libclc/generic/lib/SOURCES CONFLICT (content): Merge conflict in libclc/generic/lib/math/nextafter.cl
2 parents 9498fc2 + 9705500 commit 4600de9

File tree

437 files changed

+8256
-2952
lines changed

Some content is hidden

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

437 files changed

+8256
-2952
lines changed

.github/workflows/release-binaries.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
prepare:
5050
name: Prepare to build binaries
5151
runs-on: ${{ inputs.runs-on }}
52-
if: github.repository == 'llvm/llvm-project'
52+
if: github.repository_owner == 'llvm'
5353
outputs:
5454
release-version: ${{ steps.vars.outputs.release-version }}
5555
ref: ${{ steps.vars.outputs.ref }}
@@ -177,7 +177,7 @@ jobs:
177177
build-release-package:
178178
name: "Build Release Package"
179179
needs: prepare
180-
if: github.repository == 'llvm/llvm-project'
180+
if: github.repository_owner == 'llvm'
181181
runs-on: ${{ needs.prepare.outputs.build-runs-on }}
182182
steps:
183183

@@ -327,7 +327,7 @@ jobs:
327327
- prepare
328328
- build-release-package
329329
if: >-
330-
github.repository == 'llvm/llvm-project'
330+
github.repository_owner == 'llvm'
331331
runs-on: ${{ needs.prepare.outputs.test-runs-on }}
332332
steps:
333333
- name: Checkout Actions

clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "clang/AST/ASTContext.h"
1111
#include "clang/AST/Decl.h"
1212
#include "clang/ASTMatchers/ASTMatchFinder.h"
13+
#include "clang/ASTMatchers/ASTMatchers.h"
1314
#include "clang/Lex/Lexer.h"
1415

1516
using namespace clang::ast_matchers;

clang/docs/BoundsSafety.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,4 +996,11 @@ and the soundness of the type system. This may incur significant code size
996996
overhead in unoptimized builds and leaving some of the adoption mistakes to be
997997
caught only at run time. This is not a fundamental limitation, however, because
998998
incrementally adding necessary static analysis will allow us to catch issues
999-
early on and remove unnecessary bounds checks in unoptimized builds.
999+
early on and remove unnecessary bounds checks in unoptimized builds.
1000+
1001+
Try it out
1002+
==========
1003+
1004+
Your feedback on the programming model is valuable. You may want to follow the
1005+
instruction in :doc:`BoundsSafetyAdoptionGuide` to play with ``-fbounds-safety``
1006+
and please send your feedback to `Yeoul Na <mailto:yeoul_na@apple.com>`_.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
======================================
2+
Adoption Guide for ``-fbounds-safety``
3+
======================================
4+
5+
.. contents::
6+
:local:
7+
8+
Where to get ``-fbounds-safety``
9+
================================
10+
11+
The open sourcing to llvm.org's ``llvm-project`` is still on going and the
12+
feature is not available yet. In the mean time, the preview implementation is
13+
available
14+
`here <https://github.com/swiftlang/llvm-project/tree/stable/20240723>`_ in a
15+
fork of ``llvm-project``. Please follow
16+
`Building LLVM with CMake <https://llvm.org/docs/CMake.html>`_ to build the
17+
compiler.
18+
19+
Feature flag
20+
============
21+
22+
Pass ``-fbounds-safety`` as a Clang compilation flag for the C file that you
23+
want to adopt. We recommend adopting the model file by file, because adoption
24+
requires some effort to add bounds annotations and fix compiler diagnostics.
25+
26+
Include ``ptrcheck.h``
27+
======================
28+
29+
``ptrcheck.h`` is a Clang toolchain header to provide definition of the bounds
30+
annotations such as ``__counted_by``, ``__counted_by_or_null``, ``__sized_by``,
31+
etc. In the LLVM source tree, the header is located in
32+
``llvm-project/clang/lib/Headers/ptrcheck.h``.
33+
34+
35+
Add bounds annotations on pointers as necessary
36+
===============================================
37+
38+
Annotate pointers on struct fields and function parameters if they are pointing
39+
to an array of object, with appropriate bounds annotations. Please see
40+
:doc:`BoundsSafety` to learn what kind of bounds annotations are available and
41+
their semantics. Note that local pointer variables typically don't need bounds
42+
annotations because they are implicitely a wide pointer (``__bidi_indexable``)
43+
that automatically carries the bounds information.
44+
45+
Address compiler diagnostics
46+
============================
47+
48+
Once you pass ``-fbounds-safety`` to compiler a C file, you will see some new
49+
compiler warnings and errors, which guide adoption of ``-fbounds-safety``.
50+
Consider the following example:
51+
52+
.. code-block:: c
53+
54+
#include <ptrcheck.h>
55+
56+
void init_buf(int *p, int n) {
57+
for (int i = 0; i < n; ++i)
58+
p[i] = 0; // error: array subscript on single pointer 'p' must use a constant index of 0 to be in bounds
59+
}
60+
61+
The parameter ``int *p`` doesn't have a bounds annotation, so the compiler will
62+
complain about the code indexing into it (``p[i]``) as it assumes that ``p`` is
63+
pointing to a single ``int`` object or null. To address the diagnostics, you
64+
should add a bounds annotation on ``int *p`` so that the compiler can reason
65+
about the safety of the array subscript. In the following example, ``p`` is now
66+
``int *__counted_by(n)``, so the compiler will allow the array subscript with
67+
additional run-time checks as necessary.
68+
69+
.. code-block:: c
70+
71+
#include <ptrcheck.h>
72+
73+
void init_buf(int *__counted_by(n) p, int n) {
74+
for (int i = 0; i < n; ++i)
75+
p[i] = 0; // ok; `p` is now has a type with bounds annotation.
76+
}
77+
78+
Run test suites to fix new run-time traps
79+
=========================================
80+
81+
Adopting ``-fbounds-safety`` may cause your program to trap if it violates
82+
bounds safety or it has incorrect adoption. Thus, it is necessary to perform
83+
run-time testing of your program to gain confidence that it won't trap at
84+
run time.
85+
86+
Repeat the process for each remaining file
87+
==========================================
88+
89+
Once you've done with adopting a single C file, please repeat the same process
90+
for each remaining C file that you want to adopt.

clang/docs/ReleaseNotes.rst

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,6 @@ C++ Language Changes
294294
C++2c Feature Support
295295
^^^^^^^^^^^^^^^^^^^^^
296296

297-
- Add ``__builtin_is_implicit_lifetime`` intrinsic, which supports
298-
`P2647R1 A trait for implicit lifetime types <https://wg21.link/p2674r1>`_
299-
300297
- Add ``__builtin_is_virtual_base_of`` intrinsic, which supports
301298
`P2985R0 A type trait for detecting virtual base classes <https://wg21.link/p2985r0>`_
302299

@@ -318,6 +315,9 @@ C++23 Feature Support
318315

319316
- ``__cpp_explicit_this_parameter`` is now defined. (#GH82780)
320317

318+
- Add ``__builtin_is_implicit_lifetime`` intrinsic, which supports
319+
`P2674R1 A trait for implicit lifetime types <https://wg21.link/p2674r1>`_
320+
321321
- Add support for `P2280R4 Using unknown pointers and references in constant expressions <https://wg21.link/P2280R4>`_. (#GH63139)
322322

323323
C++20 Feature Support
@@ -363,6 +363,9 @@ Resolutions to C++ Defect Reports
363363
- Clang now allows trailing requires clause on explicit deduction guides.
364364
(`CWG2707: Deduction guides cannot have a trailing requires-clause <https://cplusplus.github.io/CWG/issues/2707.html>`_).
365365

366+
- Respect constructor constraints during CTAD.
367+
(`CWG2628: Implicit deduction guides should propagate constraints <https://cplusplus.github.io/CWG/issues/2628.html>`_).
368+
366369
- Clang now diagnoses a space in the first production of a ``literal-operator-id``
367370
by default.
368371
(`CWG2521: User-defined literals and reserved identifiers <https://cplusplus.github.io/CWG/issues/2521.html>`_).
@@ -972,6 +975,8 @@ Bug Fixes to C++ Support
972975
- Fixed a nested lambda substitution issue for constraint evaluation. (#GH123441)
973976
- Fixed various false diagnostics related to the use of immediate functions. (#GH123472)
974977
- Fix immediate escalation not propagating through inherited constructors. (#GH112677)
978+
- Fixed assertions or false compiler diagnostics in the case of C++ modules for
979+
lambda functions or inline friend functions defined inside templates (#GH122493).
975980

976981
Bug Fixes to AST Handling
977982
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1132,6 +1137,20 @@ Windows Support
11321137
LoongArch Support
11331138
^^^^^^^^^^^^^^^^^
11341139

1140+
- Types of parameters and return value of ``__builtin_lsx_vorn_v`` and ``__builtin_lasx_xvorn_v``
1141+
are changed from ``signed char`` to ``unsigned char``. (#GH114514)
1142+
1143+
- ``-mrelax`` and ``-mno-relax`` are supported now on LoongArch that can be used
1144+
to enable / disable the linker relaxation optimization. (#GH123587)
1145+
1146+
- Fine-grained la64v1.1 options are added including ``-m{no-,}frecipe``, ``-m{no-,}lam-bh``,
1147+
``-m{no-,}ld-seq-sa``, ``-m{no-,}div32``, ``-m{no-,}lamcas`` and ``-m{no-,}scq``.
1148+
1149+
- Two options ``-m{no-,}annotate-tablejump`` are added to enable / disable
1150+
annotating table jump instruction to correlate it with the jump table. (#GH102411)
1151+
1152+
- FreeBSD support is added for LoongArch64 and has been tested by building kernel-toolchain. (#GH119191)
1153+
11351154
RISC-V Support
11361155
^^^^^^^^^^^^^^
11371156

@@ -1255,6 +1274,13 @@ libclang
12551274
- Added ``clang_getOffsetOfBase``, which allows computing the offset of a base
12561275
class in a class's layout.
12571276

1277+
1278+
Code Completion
1279+
---------------
1280+
1281+
- Use ``HeuristicResolver`` (upstreamed from clangd) to improve code completion results
1282+
in dependent code
1283+
12581284
Static Analyzer
12591285
---------------
12601286

clang/docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Using Clang as a Compiler
4040
SanitizerStats
4141
SanitizerSpecialCaseList
4242
BoundsSafety
43+
BoundsSafetyAdoptionGuide
4344
BoundsSafetyImplPlans
4445
ControlFlowIntegrity
4546
LTOVisibility

clang/include/clang/AST/UnresolvedSet.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,8 @@ class UnresolvedSetImpl {
7171
UnresolvedSetImpl(const UnresolvedSetImpl &) = default;
7272
UnresolvedSetImpl &operator=(const UnresolvedSetImpl &) = default;
7373

74-
// FIXME: Switch these to "= default" once MSVC supports generating move ops
75-
UnresolvedSetImpl(UnresolvedSetImpl &&) {}
76-
UnresolvedSetImpl &operator=(UnresolvedSetImpl &&) { return *this; }
74+
UnresolvedSetImpl(UnresolvedSetImpl &&) = default;
75+
UnresolvedSetImpl &operator=(UnresolvedSetImpl &&) = default;
7776

7877
public:
7978
// We don't currently support assignment through this iterator, so we might

clang/include/clang/ASTMatchers/ASTMatchersInternal.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,7 +1804,7 @@ class LocMatcher : public MatcherInterface<TLoc> {
18041804
///
18051805
/// Used to implement the \c loc() matcher.
18061806
class TypeLocTypeMatcher : public MatcherInterface<TypeLoc> {
1807-
DynTypedMatcher InnerMatcher;
1807+
Matcher<QualType> InnerMatcher;
18081808

18091809
public:
18101810
explicit TypeLocTypeMatcher(const Matcher<QualType> &InnerMatcher)
@@ -1814,8 +1814,7 @@ class TypeLocTypeMatcher : public MatcherInterface<TypeLoc> {
18141814
BoundNodesTreeBuilder *Builder) const override {
18151815
if (!Node)
18161816
return false;
1817-
return this->InnerMatcher.matches(DynTypedNode::create(Node.getType()),
1818-
Finder, Builder);
1817+
return this->InnerMatcher.matches(Node.getType(), Finder, Builder);
18191818
}
18201819
};
18211820

clang/include/clang/Basic/BuiltinsSPIRV.td

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,3 @@ def SPIRVLength : Builtin {
1919
let Attributes = [NoThrow, Const];
2020
let Prototype = "void(...)";
2121
}
22-
23-
def SPIRVReflect : Builtin {
24-
let Spellings = ["__builtin_spirv_reflect"];
25-
let Attributes = [NoThrow, Const];
26-
let Prototype = "void(...)";
27-
}

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,9 @@ def err_drv_loongarch_invalid_simd_option_combination : Error<
887887
def err_drv_loongarch_invalid_msimd_EQ : Error<
888888
"invalid argument '%0' to -msimd=; must be one of: none, lsx, lasx">;
889889

890+
def err_drv_loongarch_unsupported_with_linker_relaxation : Error<
891+
"%0 is unsupported with LoongArch linker relaxation (-mrelax)">;
892+
890893
def err_drv_expand_response_file : Error<
891894
"failed to expand response file: %0">;
892895

0 commit comments

Comments
 (0)