Skip to content

Commit dbfe1d7

Browse files
authored
Merge branch 'llvm:main' into llvm-jitlink
2 parents 9d41ed4 + eb614cd commit dbfe1d7

File tree

306 files changed

+6215
-3310
lines changed

Some content is hidden

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

306 files changed

+6215
-3310
lines changed

.github/workflows/containers/github-action-ci-tooling/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ RUN apt-get update && \
108108
abi-compliance-checker \
109109
abi-dumper \
110110
autoconf \
111+
parallel \
111112
pkg-config && \
112113
apt-get clean && \
113114
rm -rf /var/lib/apt/lists/*

.github/workflows/llvm-abi-tests.yml

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ jobs:
7272
if: github.repository_owner == 'llvm'
7373
needs: abi-dump-setup
7474
runs-on: ubuntu-24.04
75+
container:
76+
image: "ghcr.io/llvm/ci-ubuntu-24.04-abi-tests@sha256:01e66b0847c1e9c88f0bd0492ed7c3374550a0730b48040f63888393f1ff6c13" #ghcr.io/llvm/ci-ubuntu-24.04-abi-tests:bb0bd382ab2b"
7577
strategy:
7678
matrix:
7779
name:
@@ -87,19 +89,6 @@ jobs:
8789
ref: ${{ github.sha }}
8890
repo: ${{ github.repository }}
8991
steps:
90-
- name: Install Ninja
91-
uses: llvm/actions/install-ninja@42d80571b13f4599bbefbc7189728b64723c7f78 # main
92-
- name: Install abi-compliance-checker
93-
run: |
94-
sudo apt-get update
95-
sudo apt-get -y install abi-dumper autoconf pkg-config
96-
- name: Install universal-ctags
97-
run: |
98-
git clone https://github.com/universal-ctags/ctags.git
99-
cd ctags
100-
./autogen.sh
101-
./configure
102-
sudo make install
10392
- name: Download source code
10493
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
10594
with:
@@ -143,6 +132,8 @@ jobs:
143132
abi-compare:
144133
if: github.repository_owner == 'llvm'
145134
runs-on: ubuntu-24.04
135+
container:
136+
image: "ghcr.io/llvm/ci-ubuntu-24.04-abi-tests@sha256:01e66b0847c1e9c88f0bd0492ed7c3374550a0730b48040f63888393f1ff6c13" #ghcr.io/llvm/ci-ubuntu-24.04-abi-tests:bb0bd382ab2b
146137
needs:
147138
- abi-dump-setup
148139
- abi-dump
@@ -163,10 +154,6 @@ jobs:
163154
name: symbol-list
164155
path: symbol-list
165156

166-
- name: Install abi-compliance-checker
167-
run: |
168-
sudo apt-get update
169-
sudo apt-get -y install abi-compliance-checker
170157
- name: Compare ABI
171158
run: |
172159
if [ -s symbol-list/llvm.symbols ]; then

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class UncheckedOptionalAccessCheck : public ClangTidyCheck {
2525
public:
2626
UncheckedOptionalAccessCheck(StringRef Name, ClangTidyContext *Context)
2727
: ClangTidyCheck(Name, Context),
28-
ModelOptions{Options.get("IgnoreSmartPointerDereference", false)} {}
28+
ModelOptions{Options.get("IgnoreSmartPointerDereference", false),
29+
Options.get("IgnoreValueCalls", false)} {}
2930
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
3031
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
3132
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
@@ -34,6 +35,7 @@ class UncheckedOptionalAccessCheck : public ClangTidyCheck {
3435
void storeOptions(ClangTidyOptions::OptionMap &Opts) override {
3536
Options.store(Opts, "IgnoreSmartPointerDereference",
3637
ModelOptions.IgnoreSmartPointerDereference);
38+
Options.store(Opts, "IgnoreValueCalls", ModelOptions.IgnoreValueCalls);
3739
}
3840

3941
private:

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,11 @@ Changes in existing checks
367367
- Improved :doc:`bugprone-unchecked-optional-access
368368
<clang-tidy/checks/bugprone/unchecked-optional-access>` check by supporting
369369
``NullableValue::makeValue`` and ``NullableValue::makeValueInplace`` to
370-
prevent false-positives for ``BloombergLP::bdlb::NullableValue`` type.
370+
prevent false-positives for ``BloombergLP::bdlb::NullableValue`` type, and by
371+
adding the `IgnoreValueCalls` option to suppress diagnostics for
372+
``optional::value()`` and the `IgnoreSmartPointerDereference` option to
373+
ignore optionals reached via smart-pointer-like dereference, while still
374+
diagnosing UB-prone dereferences via ``operator*`` and ``operator->``.
371375

372376
- Improved :doc:`bugprone-unhandled-self-assignment
373377
<clang-tidy/checks/bugprone/unhandled-self-assignment>` check by adding

clang-tools-extra/docs/clang-tidy/checks/bugprone/unchecked-optional-access.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,22 @@ advantages:
308308
* Performance. A single check can cover many or even all accesses within
309309
scope. This gives the user the best of both worlds -- the safety of a
310310
dynamic check, but without incurring redundant costs.
311+
312+
Options
313+
-------
314+
315+
.. option:: IgnoreSmartPointerDereference
316+
317+
If set to `true`, the check ignores optionals that
318+
are reached through overloaded smart-pointer-like dereference (``operator*``,
319+
``operator->``) on classes other than the optional type itself. This helps
320+
avoid false positives where the analysis cannot equate results across such
321+
calls. This does not cover access through ``operator[]``. Default is `false`.
322+
323+
.. option:: IgnoreValueCalls
324+
325+
If set to `true`, the check does not diagnose calls
326+
to ``optional::value()``. Diagnostics for ``operator*()`` and
327+
``operator->()`` remain enabled. This is useful for codebases that
328+
intentionally rely on ``value()`` for defined, guarded access while still
329+
flagging UB-prone operator dereferences. Default is `false`.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %check_clang_tidy %s bugprone-unchecked-optional-access %t -- \
2+
// RUN: -config="{CheckOptions: \
3+
// RUN: {bugprone-unchecked-optional-access.IgnoreValueCalls: true}}" -- \
4+
// RUN: -I %S/Inputs/unchecked-optional-access
5+
6+
#include "absl/types/optional.h"
7+
8+
struct Foo {
9+
void foo() const {}
10+
};
11+
12+
void unchecked_value_access(const absl::optional<int> &opt) {
13+
opt.value(); // no-warning
14+
}
15+
16+
void unchecked_deref_operator_access(const absl::optional<int> &opt) {
17+
*opt;
18+
// CHECK-MESSAGES: :[[@LINE-1]]:4: warning: unchecked access to optional value
19+
}
20+
21+
void unchecked_arrow_operator_access(const absl::optional<Foo> &opt) {
22+
opt->foo();
23+
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: unchecked access to optional value
24+
}
25+

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,9 @@ RISC-V Support
598598
- Add `-march=unset` to clear any previous `-march=` value. This ISA string will
599599
be computed from `-mcpu` or the platform default.
600600

601+
- `__GCC_CONSTRUCTIVE_SIZE` and `__GCC_DESTRUCTIVE_SIZE` are changed to 64. These values are
602+
unstable according to `Clang's documentation <https://clang.llvm.org/docs/LanguageExtensions.html#gcc-destructive-size-and-gcc-constructive-size>`_.
603+
601604
CUDA/HIP Language Changes
602605
^^^^^^^^^^^^^^^^^^^^^^^^^
603606

clang/include/clang/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ struct UncheckedOptionalAccessModelOptions {
4646
/// are confident in this const accessor caching, we shouldn't need the
4747
/// IgnoreSmartPointerDereference option anymore.
4848
bool IgnoreSmartPointerDereference = false;
49+
50+
/// In generating diagnostics, ignore calls to `optional::value()`.
51+
bool IgnoreValueCalls = false;
4952
};
5053

5154
using UncheckedOptionalAccessLattice = CachedConstAccessorsLattice<NoopLattice>;

clang/include/clang/Basic/BuiltinsX86.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ let Features = "sse3", Attributes = [NoThrow, RequiredVectorWidth<128>] in {
311311
def lddqu : X86Builtin<"_Vector<16, char>(char const *)">;
312312
}
313313

314-
let Features = "ssse3", Attributes = [NoThrow, Const, RequiredVectorWidth<128>] in {
314+
let Features = "ssse3", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
315315
def palignr128 : X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Vector<16, char>, _Constant int)">;
316316
}
317317

@@ -605,8 +605,7 @@ let Features = "avx", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWid
605605

606606
let Features = "avx2", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] in {
607607
def mpsadbw256 : X86Builtin<"_Vector<32, char>(_Vector<32, char>, _Vector<32, char>, _Constant char)">;
608-
def palignr256 : X86Builtin<"_Vector<32, char>(_Vector<32, char>, "
609-
"_Vector<32, char>, _Constant int)">;
608+
610609
def psadbw256
611610
: X86Builtin<
612611
"_Vector<4, long long int>(_Vector<32, char>, _Vector<32, char>)">;
@@ -630,6 +629,7 @@ let Features = "avx2", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWi
630629
def pmovmskb256 : X86Builtin<"int(_Vector<32, char>)">;
631630
def pavgb256 : X86Builtin<"_Vector<32, unsigned char>(_Vector<32, unsigned char>, _Vector<32, unsigned char>)">;
632631
def pavgw256 : X86Builtin<"_Vector<16, unsigned short>(_Vector<16, unsigned short>, _Vector<16, unsigned short>)">;
632+
def palignr256 : X86Builtin<"_Vector<32, char>(_Vector<32, char>, _Vector<32, char>, _Constant int)">;
633633

634634
def pblendd128 : X86Builtin<"_Vector<4, int>(_Vector<4, int>, _Vector<4, int>, _Constant int)">;
635635
def pblendd256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Vector<8, int>, _Constant int)">;
@@ -3263,7 +3263,7 @@ let Features = "avx512bw", Attributes = [NoThrow, Const] in {
32633263
def kmovq : X86Builtin<"unsigned long long int(unsigned long long int)">;
32643264
}
32653265

3266-
let Features = "avx512bw", Attributes = [NoThrow, Const, RequiredVectorWidth<512>] in {
3266+
let Features = "avx512bw", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<512>] in {
32673267
def palignr512 : X86Builtin<"_Vector<64, char>(_Vector<64, char>, _Vector<64, char>, _Constant int)">;
32683268
}
32693269

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5432,8 +5432,7 @@ bool Compiler<Emitter>::VisitCXXThisExpr(const CXXThisExpr *E) {
54325432
unsigned EndIndex = 0;
54335433
// Find the init list.
54345434
for (StartIndex = InitStack.size() - 1; StartIndex > 0; --StartIndex) {
5435-
if (InitStack[StartIndex].Kind == InitLink::K_InitList ||
5436-
InitStack[StartIndex].Kind == InitLink::K_This) {
5435+
if (InitStack[StartIndex].Kind == InitLink::K_DIE) {
54375436
EndIndex = StartIndex;
54385437
--StartIndex;
54395438
break;
@@ -5446,7 +5445,8 @@ bool Compiler<Emitter>::VisitCXXThisExpr(const CXXThisExpr *E) {
54465445
continue;
54475446

54485447
if (InitStack[StartIndex].Kind != InitLink::K_Field &&
5449-
InitStack[StartIndex].Kind != InitLink::K_Elem)
5448+
InitStack[StartIndex].Kind != InitLink::K_Elem &&
5449+
InitStack[StartIndex].Kind != InitLink::K_DIE)
54505450
break;
54515451
}
54525452

@@ -5457,7 +5457,8 @@ bool Compiler<Emitter>::VisitCXXThisExpr(const CXXThisExpr *E) {
54575457

54585458
// Emit the instructions.
54595459
for (unsigned I = StartIndex; I != (EndIndex + 1); ++I) {
5460-
if (InitStack[I].Kind == InitLink::K_InitList)
5460+
if (InitStack[I].Kind == InitLink::K_InitList ||
5461+
InitStack[I].Kind == InitLink::K_DIE)
54615462
continue;
54625463
if (!InitStack[I].template emit<Emitter>(this, E))
54635464
return false;
@@ -6328,8 +6329,8 @@ bool Compiler<Emitter>::compileConstructor(const CXXConstructorDecl *Ctor) {
63286329

63296330
unsigned FirstLinkOffset =
63306331
R->getField(cast<FieldDecl>(IFD->chain()[0]))->Offset;
6331-
InitStackScope<Emitter> ISS(this, isa<CXXDefaultInitExpr>(InitExpr));
63326332
InitLinkScope<Emitter> ILS(this, InitLink::Field(FirstLinkOffset));
6333+
InitStackScope<Emitter> ISS(this, isa<CXXDefaultInitExpr>(InitExpr));
63336334
if (!emitFieldInitializer(NestedField, NestedFieldOffset, InitExpr,
63346335
IsUnion))
63356336
return false;

0 commit comments

Comments
 (0)