Skip to content

Commit ba7925f

Browse files
authored
Merge branch 'main' into users/kparzysz/has_device_addr
2 parents f45aec7 + d21b2e6 commit ba7925f

File tree

315 files changed

+15885
-6415
lines changed

Some content is hidden

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

315 files changed

+15885
-6415
lines changed

bolt/test/binary-analysis/AArch64/gs-pacret-autiasp.s

Lines changed: 3 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ f1:
1818
// CHECK-NEXT: The 1 instructions that write to the return register after any authentication are:
1919
// CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
2020
// CHECK-NEXT: This happens in the following basic block:
21-
// CHECK-NEXT: {{[0-9a-f]+}}: paciasp
22-
// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]!
23-
// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp
24-
// CHECK-NEXT: {{[0-9a-f]+}}: bl g@PLT
2521
// CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3
2622
// CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
2723
// CHECK-NEXT: {{[0-9a-f]+}}: ret
@@ -39,15 +35,11 @@ f_intermediate_overwrite1:
3935
add x0, x0, #3
4036
autiasp
4137
ldp x29, x30, [sp], #16
42-
// CHECK-LABEL: GS-PACRET: non-protected ret found in function f_intermediate_overwrite1, basic block .LBB
38+
// CHECK-LABEL: GS-PACRET: non-protected ret found in function f_intermediate_overwrite1, basic block {{[0-9a-zA-Z.]+}}
4339
// CHECK-NEXT: The return instruction is {{[0-9a-f]+}}: ret
4440
// CHECK-NEXT: The 1 instructions that write to the return register after any authentication are:
4541
// CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
4642
// CHECK-NEXT: This happens in the following basic block:
47-
// CHECK-NEXT: {{[0-9a-f]+}}: paciasp
48-
// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]!
49-
// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp
50-
// CHECK-NEXT: {{[0-9a-f]+}}: bl g@PLT
5143
// CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3
5244
// CHECK-NEXT: {{[0-9a-f]+}}: autiasp
5345
// CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
@@ -71,10 +63,6 @@ f_intermediate_overwrite2:
7163
// CHECK-NEXT: The 1 instructions that write to the return register after any authentication are:
7264
// CHECK-NEXT: 1. {{[0-9a-f]+}}: mov x30, x0
7365
// CHECK-NEXT: This happens in the following basic block:
74-
// CHECK-NEXT: {{[0-9a-f]+}}: paciasp
75-
// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]!
76-
// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp
77-
// CHECK-NEXT: {{[0-9a-f]+}}: bl g@PLT
7866
// CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3
7967
// CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
8068
// CHECK-NEXT: {{[0-9a-f]+}}: autiasp
@@ -114,10 +102,6 @@ f_intermediate_overwrite3:
114102
// CHECK-NEXT: The 1 instructions that write to the return register after any authentication are:
115103
// CHECK-NEXT: 1. {{[0-9a-f]+}}: mov w30, w0
116104
// CHECK-NEXT: This happens in the following basic block:
117-
// CHECK-NEXT: {{[0-9a-f]+}}: paciasp
118-
// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]!
119-
// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp
120-
// CHECK-NEXT: {{[0-9a-f]+}}: bl g@PLT
121105
// CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3
122106
// CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
123107
// CHECK-NEXT: {{[0-9a-f]+}}: autiasp
@@ -142,10 +126,6 @@ f_nonx30_ret:
142126
// CHECK-NEXT: The 1 instructions that write to the return register after any authentication are:
143127
// CHECK-NEXT: 1. {{[0-9a-f]+}}: mov x16, x30
144128
// CHECK-NEXT: This happens in the following basic block:
145-
// CHECK-NEXT: {{[0-9a-f]+}}: paciasp
146-
// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]!
147-
// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp
148-
// CHECK-NEXT: {{[0-9a-f]+}}: bl g@PLT
149129
// CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3
150130
// CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
151131
// CHECK-NEXT: {{[0-9a-f]+}}: mov x16, x30
@@ -225,10 +205,7 @@ f_callclobbered_x30:
225205
// CHECK-LABEL: GS-PACRET: non-protected ret found in function f_callclobbered_x30, basic block {{[0-9a-zA-Z.]+}}, at address
226206
// CHECK-NEXT: The return instruction is {{[0-9a-f]+}}: ret
227207
// CHECK-NEXT: The 1 instructions that write to the return register after any authentication are:
228-
// CHECK-NEXT: 1. {{[0-9a-f]+}}: bl g@PLT
229-
// CHECK-NEXT: This happens in the following basic block:
230-
// CHECK-NEXT: {{[0-9a-f]+}}: bl g@PLT
231-
// CHECK-NEXT: {{[0-9a-f]+}}: ret
208+
// CHECK-NEXT: 1. {{[0-9a-f]+}}: bl
232209
ret
233210
.size f_callclobbered_x30, .-f_callclobbered_x30
234211

@@ -239,10 +216,7 @@ f_callclobbered_calleesaved:
239216
// CHECK-LABEL: GS-PACRET: non-protected ret found in function f_callclobbered_calleesaved, basic block {{[0-9a-zA-Z.]+}}, at address
240217
// CHECK-NEXT: The return instruction is {{[0-9a-f]+}}: ret x19
241218
// CHECK-NEXT: The 1 instructions that write to the return register after any authentication are:
242-
// CHECK-NEXT: 1. {{[0-9a-f]+}}: bl g@PLT
243-
// CHECK-NEXT: This happens in the following basic block:
244-
// CHECK-NEXT: {{[0-9a-f]+}}: bl g@PLT
245-
// CHECK-NEXT: {{[0-9a-f]+}}: ret x19
219+
// CHECK-NEXT: 1. {{[0-9a-f]+}}: bl
246220
// x19, according to the Arm ABI (AAPCS) is a callee-saved register.
247221
// Therefore, if function g respects the AAPCS, it should not write
248222
// anything to x19. However, we can't know whether function g actually
@@ -330,10 +304,6 @@ f_autia1716:
330304
// CHECK-NEXT: The 1 instructions that write to the return register after any authentication are:
331305
// CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
332306
// CHECK-NEXT: This happens in the following basic block:
333-
// CHECK-NEXT: {{[0-9a-f]+}}: paciasp
334-
// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]!
335-
// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp
336-
// CHECK-NEXT: {{[0-9a-f]+}}: bl g@PLT
337307
// CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3
338308
// CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
339309
// CHECK-NEXT: {{[0-9a-f]+}}: autia1716
@@ -356,10 +326,6 @@ f_autib1716:
356326
// CHECK-NEXT: The 1 instructions that write to the return register after any authentication are:
357327
// CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
358328
// CHECK-NEXT: This happens in the following basic block:
359-
// CHECK-NEXT: {{[0-9a-f]+}}: paciasp
360-
// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]!
361-
// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp
362-
// CHECK-NEXT: {{[0-9a-f]+}}: bl g@PLT
363329
// CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3
364330
// CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
365331
// CHECK-NEXT: {{[0-9a-f]+}}: autib1716
@@ -382,10 +348,6 @@ f_autiax12:
382348
// CHECK-NEXT: The 1 instructions that write to the return register after any authentication are:
383349
// CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
384350
// CHECK-NEXT: This happens in the following basic block:
385-
// CHECK-NEXT: {{[0-9a-f]+}}: paciasp
386-
// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]!
387-
// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp
388-
// CHECK-NEXT: {{[0-9a-f]+}}: bl g@PLT
389351
// CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3
390352
// CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
391353
// CHECK-NEXT: {{[0-9a-f]+}}: autia x12, sp
@@ -408,10 +370,6 @@ f_autibx12:
408370
// CHECK-NEXT: The 1 instructions that write to the return register after any authentication are:
409371
// CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
410372
// CHECK-NEXT: This happens in the following basic block:
411-
// CHECK-NEXT: {{[0-9a-f]+}}: paciasp
412-
// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]!
413-
// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp
414-
// CHECK-NEXT: {{[0-9a-f]+}}: bl g@PLT
415373
// CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3
416374
// CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
417375
// CHECK-NEXT: {{[0-9a-f]+}}: autib x12, sp
@@ -463,10 +421,6 @@ f_autdax12:
463421
// CHECK-NEXT: The 1 instructions that write to the return register after any authentication are:
464422
// CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
465423
// CHECK-NEXT: This happens in the following basic block:
466-
// CHECK-NEXT: {{[0-9a-f]+}}: paciasp
467-
// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]!
468-
// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp
469-
// CHECK-NEXT: {{[0-9a-f]+}}: bl g@PLT
470424
// CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3
471425
// CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
472426
// CHECK-NEXT: {{[0-9a-f]+}}: autda x12, sp
@@ -489,10 +443,6 @@ f_autdbx12:
489443
// CHECK-NEXT: The 1 instructions that write to the return register after any authentication are:
490444
// CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
491445
// CHECK-NEXT: This happens in the following basic block:
492-
// CHECK-NEXT: {{[0-9a-f]+}}: paciasp
493-
// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]!
494-
// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp
495-
// CHECK-NEXT: {{[0-9a-f]+}}: bl g@PLT
496446
// CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3
497447
// CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
498448
// CHECK-NEXT: {{[0-9a-f]+}}: autdb x12, sp
@@ -544,10 +494,6 @@ f_autizax12:
544494
// CHECK-NEXT: The 1 instructions that write to the return register after any authentication are:
545495
// CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
546496
// CHECK-NEXT: This happens in the following basic block:
547-
// CHECK-NEXT: {{[0-9a-f]+}}: paciasp
548-
// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]!
549-
// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp
550-
// CHECK-NEXT: {{[0-9a-f]+}}: bl g@PLT
551497
// CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3
552498
// CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
553499
// CHECK-NEXT: {{[0-9a-f]+}}: autiza x12
@@ -570,10 +516,6 @@ f_autizbx12:
570516
// CHECK-NEXT: The 1 instructions that write to the return register after any authentication are:
571517
// CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
572518
// CHECK-NEXT: This happens in the following basic block:
573-
// CHECK-NEXT: {{[0-9a-f]+}}: paciasp
574-
// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]!
575-
// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp
576-
// CHECK-NEXT: {{[0-9a-f]+}}: bl g@PLT
577519
// CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3
578520
// CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
579521
// CHECK-NEXT: {{[0-9a-f]+}}: autizb x12
@@ -625,10 +567,6 @@ f_autdzax12:
625567
// CHECK-NEXT: The 1 instructions that write to the return register after any authentication are:
626568
// CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
627569
// CHECK-NEXT: This happens in the following basic block:
628-
// CHECK-NEXT: {{[0-9a-f]+}}: paciasp
629-
// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]!
630-
// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp
631-
// CHECK-NEXT: {{[0-9a-f]+}}: bl g@PLT
632570
// CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3
633571
// CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
634572
// CHECK-NEXT: {{[0-9a-f]+}}: autdza x12
@@ -651,10 +589,6 @@ f_autdzbx12:
651589
// CHECK-NEXT: The 1 instructions that write to the return register after any authentication are:
652590
// CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
653591
// CHECK-NEXT: This happens in the following basic block:
654-
// CHECK-NEXT: {{[0-9a-f]+}}: paciasp
655-
// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]!
656-
// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp
657-
// CHECK-NEXT: {{[0-9a-f]+}}: bl g@PLT
658592
// CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3
659593
// CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
660594
// CHECK-NEXT: {{[0-9a-f]+}}: autdzb x12
@@ -913,10 +847,6 @@ f_autia171615:
913847
// CHECK-NEXT: The 1 instructions that write to the return register after any authentication are:
914848
// CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
915849
// CHECK-NEXT: This happens in the following basic block:
916-
// CHECK-NEXT: {{[0-9a-f]+}}: paciasp
917-
// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]!
918-
// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp
919-
// CHECK-NEXT: {{[0-9a-f]+}}: bl g@PLT
920850
// CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3
921851
// CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
922852
// CHECK-NEXT: {{[0-9a-f]+}}: autia171615
@@ -939,10 +869,6 @@ f_autib171615:
939869
// CHECK-NEXT: The 1 instructions that write to the return register after any authentication are:
940870
// CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
941871
// CHECK-NEXT: This happens in the following basic block:
942-
// CHECK-NEXT: {{[0-9a-f]+}}: paciasp
943-
// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]!
944-
// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp
945-
// CHECK-NEXT: {{[0-9a-f]+}}: bl g@PLT
946872
// CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3
947873
// CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
948874
// CHECK-NEXT: {{[0-9a-f]+}}: autib171615

clang/Maintainers.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ Clang static analyzer
136136
137137
| Balázs Benics
138138
| benicsbalazs\@gmail.com (email), steakhal (Phabricator), steakhal (GitHub)
139+
| balazs.benics\@sonarsource.com (email), balazs-benics-sonarsource (GitHub)
139140
140141
Compiler options
141142
~~~~~~~~~~~~~~~~

clang/docs/ReleaseNotes.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,50 @@ Attribute Changes in Clang
132132
This forces the global to be considered small or large in regards to the
133133
x86-64 code model, regardless of the code model specified for the compilation.
134134

135+
- There is a new ``format_matches`` attribute to complement the existing
136+
``format`` attribute. ``format_matches`` allows the compiler to verify that
137+
a format string argument is equivalent to a reference format string: it is
138+
useful when a function accepts a format string without its accompanying
139+
arguments to format. For instance:
140+
141+
.. code-block:: c
142+
143+
static int status_code;
144+
static const char *status_string;
145+
146+
void print_status(const char *fmt) {
147+
fprintf(stderr, fmt, status_code, status_string);
148+
// ^ warning: format string is not a string literal [-Wformat-nonliteral]
149+
}
150+
151+
void stuff(void) {
152+
print_status("%s (%#08x)\n");
153+
// order of %s and %x is swapped but there is no diagnostic
154+
}
155+
156+
Before the introducion of ``format_matches``, this code cannot be verified
157+
at compile-time. ``format_matches`` plugs that hole:
158+
159+
.. code-block:: c
160+
161+
__attribute__((format_matches(printf, 1, "%x %s")))
162+
void print_status(const char *fmt) {
163+
fprintf(stderr, fmt, status_code, status_string);
164+
// ^ `fmt` verified as if it was "%x %s" here; no longer triggers
165+
// -Wformat-nonliteral, would warn if arguments did not match "%x %s"
166+
}
167+
168+
void stuff(void) {
169+
print_status("%s (%#08x)\n");
170+
// warning: format specifier 's' is incompatible with 'x'
171+
// warning: format specifier 'x' is incompatible with 's'
172+
}
173+
174+
Like with ``format``, the first argument is the format string flavor and the
175+
second argument is the index of the format string parameter.
176+
``format_matches`` accepts an example valid format string as its third
177+
argument. For more information, see the Clang attributes documentation.
178+
135179
Improvements to Clang's diagnostics
136180
-----------------------------------
137181

clang/include/clang/AST/FormatString.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ class ArgType {
292292
};
293293

294294
private:
295-
const Kind K;
295+
Kind K;
296296
QualType T;
297297
const char *Name = nullptr;
298298
bool Ptr = false;
@@ -338,6 +338,7 @@ class ArgType {
338338
}
339339

340340
MatchKind matchesType(ASTContext &C, QualType argTy) const;
341+
MatchKind matchesArgType(ASTContext &C, const ArgType &other) const;
341342

342343
QualType getRepresentativeType(ASTContext &C) const;
343344

clang/include/clang/Basic/Attr.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,6 +1834,16 @@ def Format : InheritableAttr {
18341834
let Documentation = [FormatDocs];
18351835
}
18361836

1837+
def FormatMatches : InheritableAttr {
1838+
let Spellings = [GCC<"format_matches">];
1839+
let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">, ExprArgument<"ExpectedFormat">];
1840+
let AdditionalMembers = [{
1841+
StringLiteral *getFormatString() const;
1842+
}];
1843+
let Subjects = SubjectList<[ObjCMethod, Block, HasFunctionProto]>;
1844+
let Documentation = [FormatMatchesDocs];
1845+
}
1846+
18371847
def FormatArg : InheritableAttr {
18381848
let Spellings = [GCC<"format_arg">];
18391849
let Args = [ParamIdxArgument<"FormatIdx">];

0 commit comments

Comments
 (0)