Skip to content

Commit b31f352

Browse files
committed
Merge branch 'main' into flang-aa-ptr-component
2 parents b14ff32 + 41f2f1f commit b31f352

File tree

285 files changed

+13852
-2750
lines changed

Some content is hidden

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

285 files changed

+13852
-2750
lines changed

.mailmap

Lines changed: 1 addition & 1 deletion

clang-tools-extra/include-cleaner/lib/WalkAST.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,11 @@ class ASTWalker : public RecursiveASTVisitor<ASTWalker> {
351351
}
352352

353353
bool VisitCXXNewExpr(CXXNewExpr *E) {
354-
report(E->getExprLoc(), E->getOperatorNew());
354+
report(E->getExprLoc(), E->getOperatorNew(), RefType::Ambiguous);
355355
return true;
356356
}
357357
bool VisitCXXDeleteExpr(CXXDeleteExpr *E) {
358-
report(E->getExprLoc(), E->getOperatorDelete());
358+
report(E->getExprLoc(), E->getOperatorDelete(), RefType::Ambiguous);
359359
return true;
360360
}
361361
};

clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,9 @@ TEST(WalkAST, FriendDecl) {
557557
}
558558

559559
TEST(WalkAST, OperatorNewDelete) {
560-
testWalk("void* $explicit^operator new(decltype(sizeof(int)), void*);",
560+
testWalk("void* $ambiguous^operator new(decltype(sizeof(int)), void*);",
561561
"struct Bar { void foo() { Bar b; ^new (&b) Bar; } };");
562-
testWalk("struct A { static void $explicit^operator delete(void*); };",
562+
testWalk("struct A { static void $ambiguous^operator delete(void*); };",
563563
"void foo() { A a; ^delete &a; }");
564564
}
565565
} // namespace

clang/docs/ReleaseNotes.rst

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ C++ Specific Potentially Breaking Changes
7777
ABI Changes in This Version
7878
---------------------------
7979

80+
- Fixed Microsoft name mangling of placeholder, auto and decltype(auto), return types for MSVC 1920+. This change resolves incompatibilities with code compiled by MSVC 1920+ but will introduce incompatibilities with code compiled by earlier versions of Clang unless such code is built with the compiler option -fms-compatibility-version=19.14 to imitate the MSVC 1914 mangling behavior.
81+
8082
AST Dumping Potentially Breaking Changes
8183
----------------------------------------
8284

@@ -247,6 +249,11 @@ Improvements to Clang's diagnostics
247249
a warning which defaults to being an error, is enabled by default, and is
248250
also controlled by the now-deprecated ``-fheinous-gnu-extensions`` flag.
249251

252+
- Added the ``-Wdecls-in-multiple-modules`` option to assist users to identify
253+
multiple declarations in different modules, which is the major reason of the slow
254+
compilation speed with modules. This warning is disabled by default and it needs
255+
to be explicitly enabled or by ``-Weverything``.
256+
250257
Improvements to Clang's time-trace
251258
----------------------------------
252259

@@ -466,28 +473,34 @@ Sanitizers
466473

467474
- Added the ``-fsanitize-undefined-ignore-overflow-pattern`` flag which can be
468475
used to disable specific overflow-dependent code patterns. The supported
469-
patterns are: ``add-overflow-test``, ``negated-unsigned-const``, and
470-
``post-decr-while``. The sanitizer instrumentation can be toggled off for all
471-
available patterns by specifying ``all``. Conversely, you can disable all
472-
exclusions with ``none``.
476+
patterns are: ``add-signed-overflow-test``, ``add-unsigned-overflow-test``,
477+
``negated-unsigned-const``, and ``unsigned-post-decr-while``. The sanitizer
478+
instrumentation can be toggled off for all available patterns by specifying
479+
``all``. Conversely, you may disable all exclusions with ``none`` which is
480+
the default.
473481

474482
.. code-block:: c++
475483

476-
/// specified with ``-fsanitize-undefined-ignore-overflow-pattern=add-overflow-test``
484+
/// specified with ``-fsanitize-undefined-ignore-overflow-pattern=add-unsigned-overflow-test``
477485
int common_overflow_check_pattern(unsigned base, unsigned offset) {
478486
if (base + offset < base) { /* ... */ } // The pattern of `a + b < a`, and other re-orderings, won't be instrumented
479487
}
480488
489+
/// specified with ``-fsanitize-undefined-ignore-overflow-pattern=add-signed-overflow-test``
490+
int common_overflow_check_pattern_signed(signed int base, signed int offset) {
491+
if (base + offset < base) { /* ... */ } // The pattern of `a + b < a`, and other re-orderings, won't be instrumented
492+
}
493+
481494
/// specified with ``-fsanitize-undefined-ignore-overflow-pattern=negated-unsigned-const``
482495
void negation_overflow() {
483496
unsigned long foo = -1UL; // No longer causes a negation overflow warning
484497
unsigned long bar = -2UL; // and so on...
485498
}
486499

487-
/// specified with ``-fsanitize-undefined-ignore-overflow-pattern=post-decr-while``
500+
/// specified with ``-fsanitize-undefined-ignore-overflow-pattern=unsigned-post-decr-while``
488501
void while_post_decrement() {
489502
unsigned char count = 16;
490-
while (count--) { /* ... */} // No longer causes unsigned-integer-overflow sanitizer to trip
503+
while (count--) { /* ... */ } // No longer causes unsigned-integer-overflow sanitizer to trip
491504
}
492505
493506
Many existing projects have a large amount of these code patterns present.

clang/docs/StandardCPlusPlusModules.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,9 @@ approach:
894894
Reducing the duplication from textual includes is what improves compile-time
895895
performance.
896896

897+
To help users to identify such issues, we add a warning ``-Wdecls-in-multiple-modules``.
898+
This warning is disabled by default and it needs to be explicitly enabled or by ``-Weverything``.
899+
897900
Transitioning to modules
898901
------------------------
899902

clang/docs/UndefinedBehaviorSanitizer.rst

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -314,26 +314,49 @@ Currently, this option supports three overflow-dependent code idioms:
314314
unsigned long foo = -1UL; // No longer causes a negation overflow warning
315315
unsigned long bar = -2UL; // and so on...
316316

317-
``post-decr-while``
317+
``unsigned-post-decr-while``
318318

319319
.. code-block:: c++
320320

321-
/// -fsanitize-undefined-ignore-overflow-pattern=post-decr-while
321+
/// -fsanitize-undefined-ignore-overflow-pattern=unsigned-post-decr-while
322322
unsigned char count = 16;
323323
while (count--) { /* ... */ } // No longer causes unsigned-integer-overflow sanitizer to trip
324324
325-
``add-overflow-test``
325+
``add-signed-overflow-test,add-unsigned-overflow-test``
326326

327327
.. code-block:: c++
328328

329-
/// -fsanitize-undefined-ignore-overflow-pattern=add-overflow-test
329+
/// -fsanitize-undefined-ignore-overflow-pattern=add-(signed|unsigned)-overflow-test
330330
if (base + offset < base) { /* ... */ } // The pattern of `a + b < a`, and other re-orderings,
331-
// won't be instrumented (same for signed types)
331+
// won't be instrumented (signed or unsigned types)
332+
333+
.. list-table:: Overflow Pattern Types
334+
:widths: 30 50
335+
:header-rows: 1
336+
337+
* - Pattern
338+
- Sanitizer
339+
* - negated-unsigned-const
340+
- unsigned-integer-overflow
341+
* - unsigned-post-decr-while
342+
- unsigned-integer-overflow
343+
* - add-unsigned-overflow-test
344+
- unsigned-integer-overflow
345+
* - add-signed-overflow-test
346+
- signed-integer-overflow
347+
348+
349+
350+
Note: ``add-signed-overflow-test`` suppresses only the check for Undefined
351+
Behavior. Eager Undefined Behavior optimizations are still possible. One may
352+
remedy this with ``-fwrapv`` or ``-fno-strict-overflow``.
332353

333354
You can enable all exclusions with
334355
``-fsanitize-undefined-ignore-overflow-pattern=all`` or disable all exclusions
335-
with ``-fsanitize-undefined-ignore-overflow-pattern=none``. Specifying ``none``
336-
has precedence over other values.
356+
with ``-fsanitize-undefined-ignore-overflow-pattern=none``. If
357+
``-fsanitize-undefined-ignore-overflow-pattern`` is not specified ``none`` is
358+
implied. Specifying ``none`` alongside other values also implies ``none`` as
359+
``none`` has precedence over other values -- including ``all``.
337360

338361
Issue Suppression
339362
=================

clang/include/clang/Basic/LangOptions.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,13 @@ class LangOptionsBase {
375375
/// Exclude all overflow patterns (below)
376376
All = 1 << 1,
377377
/// if (a + b < a)
378-
AddOverflowTest = 1 << 2,
378+
AddSignedOverflowTest = 1 << 2,
379+
/// if (a + b < a)
380+
AddUnsignedOverflowTest = 1 << 3,
379381
/// -1UL
380-
NegUnsignedConst = 1 << 3,
382+
NegUnsignedConst = 1 << 4,
381383
/// while (count--)
382-
PostDecrInWhile = 1 << 4,
384+
PostDecrInWhile = 1 << 5,
383385
};
384386

385387
enum class DefaultVisiblityExportMapping {

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2570,7 +2570,7 @@ defm sanitize_stats : BoolOption<"f", "sanitize-stats",
25702570
def fsanitize_undefined_ignore_overflow_pattern_EQ : CommaJoined<["-"], "fsanitize-undefined-ignore-overflow-pattern=">,
25712571
HelpText<"Specify the overflow patterns to exclude from artihmetic sanitizer instrumentation">,
25722572
Visibility<[ClangOption, CC1Option]>,
2573-
Values<"none,all,add-overflow-test,negated-unsigned-const,post-decr-while">,
2573+
Values<"none,all,add-unsigned-overflow-test,add-signed-overflow-test,negated-unsigned-const,unsigned-post-decr-while">,
25742574
MarshallingInfoStringVector<LangOpts<"OverflowPatternExclusionValues">>;
25752575
def fsanitize_thread_memory_access : Flag<["-"], "fsanitize-thread-memory-access">,
25762576
Group<f_clang_Group>,

clang/lib/AST/ByteCode/EvalEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ bool EvalEmitter::emitRetValue(const SourceInfo &Info) {
219219
return false;
220220

221221
if (std::optional<APValue> APV =
222-
Ptr.toRValue(S.getCtx(), EvalResult.getSourceType())) {
222+
Ptr.toRValue(S.getASTContext(), EvalResult.getSourceType())) {
223223
EvalResult.setValue(*APV);
224224
return true;
225225
}

clang/lib/AST/ByteCode/IntegralAP.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,24 @@ template <bool Signed> class IntegralAP final {
136136
APValue toAPValue(const ASTContext &) const { return APValue(toAPSInt()); }
137137

138138
bool isZero() const { return V.isZero(); }
139-
bool isPositive() const { return V.isNonNegative(); }
140-
bool isNegative() const { return !V.isNonNegative(); }
139+
bool isPositive() const {
140+
if constexpr (Signed)
141+
return V.isNonNegative();
142+
return true;
143+
}
144+
bool isNegative() const {
145+
if constexpr (Signed)
146+
return !V.isNonNegative();
147+
return false;
148+
}
141149
bool isMin() const { return V.isMinValue(); }
142150
bool isMax() const { return V.isMaxValue(); }
143151
static constexpr bool isSigned() { return Signed; }
144152
bool isMinusOne() const { return Signed && V == -1; }
145153

146154
unsigned countLeadingZeros() const { return V.countl_zero(); }
147155

148-
void print(llvm::raw_ostream &OS) const { OS << V; }
156+
void print(llvm::raw_ostream &OS) const { V.print(OS, Signed);}
149157
std::string toDiagnosticString(const ASTContext &Ctx) const {
150158
std::string NameStr;
151159
llvm::raw_string_ostream OS(NameStr);

0 commit comments

Comments
 (0)