Skip to content

Commit 626ecee

Browse files
authored
Merge branch 'llvm:main' into main
2 parents 4d3c68d + 5d4a0d5 commit 626ecee

File tree

540 files changed

+23048
-2965
lines changed

Some content is hidden

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

540 files changed

+23048
-2965
lines changed

clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "../utils/FixItHintUtils.h"
1111
#include "clang/AST/ASTContext.h"
1212
#include "clang/ASTMatchers/ASTMatchFinder.h"
13+
#include "clang/ASTMatchers/ASTMatchers.h"
1314
#include "clang/Lex/Lexer.h"
1415
#include "clang/Tooling/FixIt.h"
1516
#include <queue>
@@ -26,6 +27,8 @@ AST_MATCHER(Stmt, isMacroExpansion) {
2627
return SM.isMacroBodyExpansion(Loc) || SM.isMacroArgExpansion(Loc);
2728
}
2829

30+
AST_MATCHER(Stmt, isC23) { return Finder->getASTContext().getLangOpts().C23; }
31+
2932
bool isNULLMacroExpansion(const Stmt *Statement, ASTContext &Context) {
3033
SourceManager &SM = Context.getSourceManager();
3134
const LangOptions &LO = Context.getLangOpts();
@@ -298,6 +301,11 @@ void ImplicitBoolConversionCheck::registerMatchers(MatchFinder *Finder) {
298301
hasCastKind(CK_FloatingToBoolean),
299302
hasCastKind(CK_PointerToBoolean),
300303
hasCastKind(CK_MemberPointerToBoolean)),
304+
// Exclude cases of C23 comparison result.
305+
unless(allOf(isC23(),
306+
hasSourceExpression(ignoringParens(
307+
binaryOperator(hasAnyOperatorName(
308+
">", ">=", "==", "!=", "<", "<=")))))),
301309
// Exclude case of using if or while statements with variable
302310
// declaration, e.g.:
303311
// if (int var = functionCall()) {}

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ Changes in existing checks
249249
- Improved :doc:`readability-implicit-bool-conversion
250250
<clang-tidy/checks/readability/implicit-bool-conversion>` check
251251
by adding the option `UseUpperCaseLiteralSuffix` to select the
252-
case of the literal suffix in fixes.
252+
case of the literal suffix in fixes and fixing false positive for implicit
253+
conversion of comparison result in C23.
253254

254255
- Improved :doc:`readability-redundant-smartptr-get
255256
<clang-tidy/checks/readability/redundant-smartptr-get>` check to

clang-tools-extra/modularize/CoverageChecker.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,9 @@ bool CoverageChecker::collectModuleHeaders(const Module &Mod) {
223223
return false;
224224
}
225225

226-
for (auto &HeaderKind : Mod.Headers)
227-
for (auto &Header : HeaderKind)
228-
ModuleMapHeadersSet.insert(
229-
ModularizeUtilities::getCanonicalPath(Header.Entry.getName()));
226+
for (const auto &Header : Mod.getAllHeaders())
227+
ModuleMapHeadersSet.insert(
228+
ModularizeUtilities::getCanonicalPath(Header.Entry.getName()));
230229

231230
for (auto *Submodule : Mod.submodules())
232231
collectModuleHeaders(*Submodule);

clang-tools-extra/modularize/ModularizeUtilities.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ bool ModularizeUtilities::collectModuleHeaders(const clang::Module &Mod) {
358358
} else if (std::optional<clang::Module::DirectoryName> UmbrellaDir =
359359
Mod.getUmbrellaDirAsWritten()) {
360360
// If there normal headers, assume these are umbrellas and skip collection.
361-
if (Mod.Headers->size() == 0) {
361+
if (Mod.getHeaders(Module::HK_Normal).empty()) {
362362
// Collect headers in umbrella directory.
363363
if (!collectUmbrellaHeaders(UmbrellaDir->Entry.getName(),
364364
UmbrellaDependents))
@@ -371,16 +371,8 @@ bool ModularizeUtilities::collectModuleHeaders(const clang::Module &Mod) {
371371
// modules or because they are meant to be included by another header,
372372
// and thus should be ignored by modularize.
373373

374-
int NormalHeaderCount = Mod.Headers[clang::Module::HK_Normal].size();
375-
376-
for (int Index = 0; Index < NormalHeaderCount; ++Index) {
377-
DependentsVector NormalDependents;
378-
// Collect normal header.
379-
const clang::Module::Header &Header(
380-
Mod.Headers[clang::Module::HK_Normal][Index]);
381-
std::string HeaderPath = getCanonicalPath(Header.Entry.getName());
382-
HeaderFileNames.push_back(HeaderPath);
383-
}
374+
for (const auto &Header : Mod.getHeaders(clang::Module::HK_Normal))
375+
HeaderFileNames.push_back(getCanonicalPath(Header.Entry.getName()));
384376

385377
int MissingCountThisModule = Mod.MissingHeaders.size();
386378

clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,15 @@ void implicitConversionToBoolFromUnaryMinusAndZeroLiterals() {
304304
// CHECK-FIXES: functionTakingBool((-0.0) != 0.0);
305305
}
306306

307+
void ignoreImplicitCastToBoolForComparisonResult() {
308+
bool boolFromComparison0 = 1 != 0;
309+
bool boolFromComparison1 = 1 == 0;
310+
bool boolFromComparison2 = 1 > 0;
311+
bool boolFromComparison3 = 1 >= 0;
312+
bool boolFromComparison4 = 1 < 0;
313+
bool boolFromComparison5 = 1 <= 0;
314+
}
315+
307316
void ignoreExplicitCastsToBool() {
308317
int integer = 10;
309318
bool boolComingFromInt = (bool)integer;

clang/docs/RealtimeSanitizer.rst

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ A **partial** list of flags RealtimeSanitizer respects:
183183
- ``true``
184184
- boolean
185185
- If set, use the symbolizer to turn virtual addresses to file/line locations. If false, can greatly speed up the error reporting.
186+
* - ``suppressions``
187+
- ""
188+
- path
189+
- If set to a valid suppressions file, will suppress issue reporting. See details in "Disabling", below.
186190

187191

188192
Some issues with flags can be debugged using the ``verbosity=$NUM`` flag:
@@ -194,12 +198,43 @@ Some issues with flags can be debugged using the ``verbosity=$NUM`` flag:
194198
misspelled_flag
195199
...
196200
197-
Disabling
198-
---------
201+
Disabling and suppressing
202+
-------------------------
199203

200-
In some circumstances, you may want to suppress error reporting in a specific scope.
204+
There are multiple ways to disable error reporting when using RealtimeSanitizer.
201205

202-
In C++, this is achieved via ``__rtsan::ScopedDisabler``. Within the scope where the ``ScopedDisabler`` object is instantiated, all sanitizer error reports are suppressed. This suppression applies to the current scope as well as all invoked functions, including any functions called transitively.
206+
In general, ``ScopedDisabler`` should be preferred, as it is the most performant.
207+
208+
.. list-table:: Suppression methods
209+
:widths: 30 15 15 10 70
210+
:header-rows: 1
211+
212+
* - Method
213+
- Specified at?
214+
- Scope
215+
- Run-time cost
216+
- Description
217+
* - ``ScopedDisabler``
218+
- Compile-time
219+
- Stack
220+
- Very low
221+
- Violations are ignored for the lifetime of the ``ScopedDisabler`` object.
222+
* - ``function-name-matches`` suppression
223+
- Run-time
224+
- Single function
225+
- Medium
226+
- Suppresses intercepted and ``[[clang::blocking]]`` function calls by name.
227+
* - ``call-stack-contains`` suppression
228+
- Run-time
229+
- Stack
230+
- High
231+
- Suppresses any stack trace contaning the specified pattern.
232+
233+
234+
``ScopedDisabler``
235+
##################
236+
237+
At compile time, RealtimeSanitizer may be disabled using ``__rtsan::ScopedDisabler``. RTSan ignores any errors originating within the ``ScopedDisabler`` instance variable scope.
203238

204239
.. code-block:: c++
205240

@@ -233,6 +268,31 @@ In C, you can use the ``__rtsan_disable()`` and ``rtsan_enable()`` functions to
233268

234269
Each call to ``__rtsan_disable()`` must be paired with a subsequent call to ``__rtsan_enable()`` to restore normal sanitizer functionality. If a corresponding ``rtsan_enable()`` call is not made, the behavior is undefined.
235270

271+
Suppression file
272+
################
273+
274+
At run-time, suppressions may be specified using a suppressions file passed in ``RTSAN_OPTIONS``. Run-time suppression may be useful if the source cannot be changed.
275+
276+
.. code-block:: console
277+
278+
> cat suppressions.supp
279+
call-stack-contains:MallocViolation
280+
call-stack-contains:std::*vector
281+
function-name-matches:free
282+
function-name-matches:CustomMarkedBlocking*
283+
> RTSAN_OPTIONS="suppressions=suppressions.supp" ./a.out
284+
...
285+
286+
Suppressions specified in this file are one of two flavors.
287+
288+
``function-name-matches`` suppresses reporting of any intercepted library call, or function marked ``[[clang::blocking]]`` by name. If, for instance, you know that ``malloc`` is real-time safe on your system, you can disable the check for it via ``function-name-matches:malloc``.
289+
290+
``call-stack-contains`` suppresses reporting of errors in any stack that contains a string matching the pattern specified. For example, suppressing error reporting of any non-real-time-safe behavior in ``std::vector`` may be specified ``call-stack-contains:std::*vector``. You must include symbols in your build for this method to be effective, unsymbolicated stack traces cannot be matched. ``call-stack-contains`` has the highest run-time cost of any method of suppression.
291+
292+
Patterns may be exact matches or are "regex-light" patterns, containing special characters such as ``^$*``.
293+
294+
The number of potential errors suppressed via this method may be seen on exit when using the ``print_stats_on_exit`` flag.
295+
236296
Compile-time sanitizer detection
237297
--------------------------------
238298

clang/docs/ReleaseNotes.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,15 @@ C++ Specific Potentially Breaking Changes
133133
// Fixed version:
134134
unsigned operator""_udl_name(unsigned long long);
135135

136+
- Clang will now produce an error diagnostic when [[clang::lifetimebound]] is
137+
applied on a parameter of a function that returns void. This was previously
138+
ignored and had no effect. (#GH107556)
139+
140+
.. code-block:: c++
141+
142+
// Now diagnoses with an error.
143+
void f(int& i [[clang::lifetimebound]]);
144+
136145
ABI Changes in This Version
137146
---------------------------
138147

@@ -302,6 +311,11 @@ Modified Compiler Flags
302311
the ``promoted`` algorithm for complex division when possible rather than the
303312
less basic (limited range) algorithm.
304313

314+
- The ``-fveclib`` option has been updated to enable ``-fno-math-errno`` for
315+
``-fveclib=ArmPL`` and ``-fveclib=SLEEF``. This gives Clang more opportunities
316+
to utilize these vector libraries. The behavior for all other vector function
317+
libraries remains unchanged.
318+
305319
Removed Compiler Flags
306320
-------------------------
307321

@@ -614,6 +628,10 @@ X86 Support
614628
* Supported MINMAX intrinsics of ``*_(mask(z)))_minmax(ne)_p[s|d|h|bh]`` and
615629
``*_(mask(z)))_minmax_s[s|d|h]``.
616630

631+
- Supported intrinsics for ``SM4 and AVX10.2``.
632+
* Supported SM4 intrinsics of ``_mm512_sm4key4_epi32`` and
633+
``_mm512_sm4rnds4_epi32``.
634+
617635
- All intrinsics in adcintrin.h can now be used in constant expressions.
618636

619637
- All intrinsics in adxintrin.h can now be used in constant expressions.
@@ -676,6 +694,15 @@ NetBSD Support
676694
WebAssembly Support
677695
^^^^^^^^^^^^^^^^^^^
678696

697+
The default target CPU, "generic", now enables the `-mnontrapping-fptoint`
698+
and `-mbulk-memory` flags, which correspond to the [Bulk Memory Operations]
699+
and [Non-trapping float-to-int Conversions] language features, which are
700+
[widely implemented in engines].
701+
702+
[Bulk Memory Operations]: https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md
703+
[Non-trapping float-to-int Conversions]: https://github.com/WebAssembly/spec/blob/master/proposals/nontrapping-float-to-int-conversion/Overview.md
704+
[widely implemented in engines]: https://webassembly.org/features/
705+
679706
AVR Support
680707
^^^^^^^^^^^
681708

clang/include/clang/Analysis/FlowSensitive/NoopLattice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_NOOP_LATTICE_H
1515

1616
#include "clang/Analysis/FlowSensitive/DataflowLattice.h"
17+
#include "clang/Support/Compiler.h"
1718
#include "llvm/ADT/Any.h"
1819
#include <ostream>
1920

clang/include/clang/Basic/AArch64SVEACLETypes.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@
107107
AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId)
108108
#endif
109109

110-
111110
//===- Vector point types -----------------------------------------------===//
112111

113112
SVE_VECTOR_TYPE_INT("__SVInt8_t", "__SVInt8_t", SveInt8, SveInt8Ty, 16, 8, 1, true)
@@ -201,6 +200,7 @@ SVE_PREDICATE_TYPE_ALL("__clang_svboolx4_t", "svboolx4_t", SveBoolx4, SveBoolx4T
201200

202201
SVE_OPAQUE_TYPE("__SVCount_t", "__SVCount_t", SveCount, SveCountTy)
203202

203+
AARCH64_VECTOR_TYPE_MFLOAT("__MFloat8_t", "__MFloat8_t", MFloat8, MFloat8Ty, 1, 8, 1)
204204
AARCH64_VECTOR_TYPE_MFLOAT("__MFloat8x8_t", "__MFloat8x8_t", MFloat8x8, MFloat8x8Ty, 8, 8, 1)
205205
AARCH64_VECTOR_TYPE_MFLOAT("__MFloat8x16_t", "__MFloat8x16_t", MFloat8x16, MFloat8x16Ty, 16, 8, 1)
206206

clang/include/clang/Basic/AMDGPUTypes.def

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@
1515
AMDGPU_TYPE(Name, Id, SingletonId, Width, Align)
1616
#endif
1717

18+
#ifndef AMDGPU_NAMED_BARRIER_TYPE
19+
#define AMDGPU_NAMED_BARRIER_TYPE(Name, Id, SingletonId, Width, Align, Scope) \
20+
AMDGPU_TYPE(Name, Id, SingletonId, Width, Align)
21+
#endif
22+
1823
AMDGPU_OPAQUE_PTR_TYPE("__amdgpu_buffer_rsrc_t", AMDGPUBufferRsrc, AMDGPUBufferRsrcTy, 128, 128, 8)
1924

25+
AMDGPU_NAMED_BARRIER_TYPE("__amdgpu_named_workgroup_barrier_t", AMDGPUNamedWorkgroupBarrier, AMDGPUNamedWorkgroupBarrierTy, 128, 32, 0)
26+
2027
#undef AMDGPU_TYPE
2128
#undef AMDGPU_OPAQUE_PTR_TYPE
29+
#undef AMDGPU_NAMED_BARRIER_TYPE

0 commit comments

Comments
 (0)