Skip to content

Commit 4ddc87a

Browse files
committed
Merge remote-tracking branch 'origin/main' into vplan-runtime-checks-tmp
2 parents b87cf14 + 1fef4ad commit 4ddc87a

File tree

219 files changed

+4343
-1375
lines changed

Some content is hidden

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

219 files changed

+4343
-1375
lines changed

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,6 @@ jobs:
159159
'generic-no-rtti',
160160
'generic-optimized-speed',
161161
'generic-static',
162-
# TODO Find a better place for the benchmark and bootstrapping builds to live. They're either very expensive
163-
# or don't provide much value since the benchmark run results are too noise on the bots.
164-
'benchmarks',
165162
'bootstrapping-build'
166163
]
167164
machine: [ 'libcxx-runners-set' ]

clang/docs/ReleaseNotes.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,30 @@ C Language Changes
274274
C2y Feature Support
275275
^^^^^^^^^^^^^^^^^^^
276276

277+
- Updated conformance for `N3298 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3298.htm>`_
278+
which adds the ``i`` and ``j`` suffixes for the creation of a ``_Complex``
279+
constant value. Clang has always supported these suffixes as a GNU extension,
280+
so ``-Wgnu-imaginary-constant`` no longer has effect in C modes, as this is
281+
not a C2y extension in C. ``-Wgnu-imaginary-constant`` still applies in C++
282+
modes.
283+
277284
- Clang updated conformance for `N3370 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3370.htm>`_
278285
case range expressions. This feature was previously supported by Clang as a
279286
GNU extension, so ``-Wgnu-case-range`` no longer has effect in C modes, as
280287
this is now a C2y extension in C. ``-Wgnu-case-range`` still applies in C++
281288
modes.
282289

290+
- Clang implemented support for `N3344 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3344.pdf>`_
291+
which disallows a ``void`` parameter from having a qualifier or storage class
292+
specifier. Note that ``register void`` was previously accepted in all C
293+
language modes but is now rejected (all of the other qualifiers and storage
294+
class specifiers were previously rejected).
295+
296+
- Updated conformance for `N3364 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3364.pdf>`_
297+
on floating-point translation-time initialization with signaling NaN. This
298+
paper adopts Clang's existing practice, so there were no changes to compiler
299+
behavior.
300+
283301
C23 Feature Support
284302
^^^^^^^^^^^^^^^^^^^
285303

@@ -595,6 +613,8 @@ Bug Fixes to C++ Support
595613
an implicitly instantiated class template specialization. (#GH51051)
596614
- Fixed an assertion failure caused by invalid enum forward declarations. (#GH112208)
597615
- Name independent data members were not correctly initialized from default member initializers. (#GH114069)
616+
- Fixed an assertion failure caused by invalid default argument substitutions in non-defining
617+
friend declarations. (#GH113324).
598618

599619
Bug Fixes to AST Handling
600620
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/docs/analyzer/checkers.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3560,6 +3560,12 @@ We also define a set of safe transformations which if passed a safe value as an
35603560
- casts
35613561
- unary operators like ``&`` or ``*``
35623562
3563+
alpha.webkit.UncheckedCallArgsChecker
3564+
"""""""""""""""""""""""""""""""""""""
3565+
The goal of this rule is to make sure that lifetime of any dynamically allocated CheckedPtr capable object passed as a call argument keeps its memory region past the end of the call. This applies to call to any function, method, lambda, function pointer or functor. CheckedPtr capable objects aren't supposed to be allocated on stack so we check arguments for parameters of raw pointers and references to unchecked types.
3566+
3567+
The rules of when to use and not to use CheckedPtr / CheckedRef are same as alpha.webkit.UncountedCallArgsChecker for ref-counted objects.
3568+
35633569
alpha.webkit.UncountedLocalVarsChecker
35643570
""""""""""""""""""""""""""""""""""""""
35653571
The goal of this rule is to make sure that any uncounted local variable is backed by a ref-counted object with lifetime that is strictly larger than the scope of the uncounted local variable. To be on the safe side we require the scope of an uncounted variable to be embedded in the scope of ref-counted object that backs it.

clang/include/clang/APINotes/Types.h

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -445,19 +445,16 @@ class ParamInfo : public VariableInfo {
445445
RawRetainCountConvention() {}
446446

447447
std::optional<bool> isNoEscape() const {
448-
if (!NoEscapeSpecified)
449-
return std::nullopt;
450-
return NoEscape;
448+
return NoEscapeSpecified ? std::optional<bool>(NoEscape) : std::nullopt;
451449
}
452450
void setNoEscape(std::optional<bool> Value) {
453451
NoEscapeSpecified = Value.has_value();
454452
NoEscape = Value.value_or(false);
455453
}
456454

457455
std::optional<bool> isLifetimebound() const {
458-
if (!LifetimeboundSpecified)
459-
return std::nullopt;
460-
return Lifetimebound;
456+
return LifetimeboundSpecified ? std::optional<bool>(Lifetimebound)
457+
: std::nullopt;
461458
}
462459
void setLifetimebound(std::optional<bool> Value) {
463460
LifetimeboundSpecified = Value.has_value();
@@ -643,6 +640,8 @@ class ObjCMethodInfo : public FunctionInfo {
643640
LLVM_PREFERRED_TYPE(bool)
644641
unsigned RequiredInit : 1;
645642

643+
std::optional<ParamInfo> Self;
644+
646645
ObjCMethodInfo() : DesignatedInit(false), RequiredInit(false) {}
647646

648647
friend bool operator==(const ObjCMethodInfo &, const ObjCMethodInfo &);
@@ -664,7 +663,7 @@ class ObjCMethodInfo : public FunctionInfo {
664663
inline bool operator==(const ObjCMethodInfo &LHS, const ObjCMethodInfo &RHS) {
665664
return static_cast<const FunctionInfo &>(LHS) == RHS &&
666665
LHS.DesignatedInit == RHS.DesignatedInit &&
667-
LHS.RequiredInit == RHS.RequiredInit;
666+
LHS.RequiredInit == RHS.RequiredInit && LHS.Self == RHS.Self;
668667
}
669668

670669
inline bool operator!=(const ObjCMethodInfo &LHS, const ObjCMethodInfo &RHS) {
@@ -693,8 +692,20 @@ class FieldInfo : public VariableInfo {
693692
class CXXMethodInfo : public FunctionInfo {
694693
public:
695694
CXXMethodInfo() {}
695+
696+
std::optional<ParamInfo> This;
697+
698+
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS);
696699
};
697700

701+
inline bool operator==(const CXXMethodInfo &LHS, const CXXMethodInfo &RHS) {
702+
return static_cast<const FunctionInfo &>(LHS) == RHS && LHS.This == RHS.This;
703+
}
704+
705+
inline bool operator!=(const CXXMethodInfo &LHS, const CXXMethodInfo &RHS) {
706+
return !(LHS == RHS);
707+
}
708+
698709
/// Describes API notes data for an enumerator.
699710
class EnumConstantInfo : public CommonEntityInfo {
700711
public:

clang/include/clang/Basic/Builtins.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4798,6 +4798,12 @@ def HLSLDot4AddI8Packed : LangBuiltin<"HLSL_LANG"> {
47984798
let Prototype = "int(unsigned int, unsigned int, int)";
47994799
}
48004800

4801+
def HLSLDot4AddU8Packed : LangBuiltin<"HLSL_LANG"> {
4802+
let Spellings = ["__builtin_hlsl_dot4add_u8packed"];
4803+
let Attributes = [NoThrow, Const];
4804+
let Prototype = "unsigned int(unsigned int, unsigned int, unsigned int)";
4805+
}
4806+
48014807
def HLSLFirstBitHigh : LangBuiltin<"HLSL_LANG"> {
48024808
let Spellings = ["__builtin_hlsl_elementwise_firstbithigh"];
48034809
let Attributes = [NoThrow, Const];

clang/include/clang/StaticAnalyzer/Checkers/Checkers.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,6 +1760,10 @@ def UncountedCallArgsChecker : Checker<"UncountedCallArgsChecker">,
17601760
HelpText<"Check uncounted call arguments.">,
17611761
Documentation<HasDocumentation>;
17621762

1763+
def UncheckedCallArgsChecker : Checker<"UncheckedCallArgsChecker">,
1764+
HelpText<"Check unchecked call arguments.">,
1765+
Documentation<HasDocumentation>;
1766+
17631767
def UncountedLocalVarsChecker : Checker<"UncountedLocalVarsChecker">,
17641768
HelpText<"Check uncounted local variables.">,
17651769
Documentation<HasDocumentation>;

clang/lib/APINotes/APINotesFormat.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ const uint16_t VERSION_MAJOR = 0;
2424
/// API notes file minor version number.
2525
///
2626
/// When the format changes IN ANY WAY, this number should be incremented.
27-
const uint16_t VERSION_MINOR = 31; // lifetimebound
27+
const uint16_t VERSION_MINOR =
28+
32; // implicit parameter support (at position -1)
2829

2930
const uint8_t kSwiftCopyable = 1;
3031
const uint8_t kSwiftNonCopyable = 2;

clang/lib/APINotes/APINotesReader.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
//===----------------------------------------------------------------------===//
1515
#include "clang/APINotes/APINotesReader.h"
1616
#include "APINotesFormat.h"
17+
#include "clang/APINotes/Types.h"
1718
#include "llvm/ADT/Hashing.h"
1819
#include "llvm/ADT/StringExtras.h"
1920
#include "llvm/Bitstream/BitstreamReader.h"
@@ -396,12 +397,19 @@ class ObjCMethodTableInfo
396397
const uint8_t *&Data) {
397398
ObjCMethodInfo Info;
398399
uint8_t Payload = *Data++;
400+
bool HasSelf = Payload & 0x01;
401+
Payload >>= 1;
399402
Info.RequiredInit = Payload & 0x01;
400403
Payload >>= 1;
401404
Info.DesignatedInit = Payload & 0x01;
402405
Payload >>= 1;
406+
assert(Payload == 0 && "Unable to fully decode 'Payload'.");
403407

404408
ReadFunctionInfo(Data, Info);
409+
if (HasSelf) {
410+
Info.Self = ParamInfo{};
411+
ReadParamInfo(Data, *Info.Self);
412+
}
405413
return Info;
406414
}
407415
};
@@ -516,7 +524,17 @@ class CXXMethodTableInfo
516524
static CXXMethodInfo readUnversioned(internal_key_type Key,
517525
const uint8_t *&Data) {
518526
CXXMethodInfo Info;
527+
528+
uint8_t Payload = *Data++;
529+
bool HasThis = Payload & 0x01;
530+
Payload >>= 1;
531+
assert(Payload == 0 && "Unable to fully decode 'Payload'.");
532+
519533
ReadFunctionInfo(Data, Info);
534+
if (HasThis) {
535+
Info.This = ParamInfo{};
536+
ReadParamInfo(Data, *Info.This);
537+
}
520538
return Info;
521539
}
522540
};

clang/lib/APINotes/APINotesTypes.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,18 @@ LLVM_DUMP_METHOD void FunctionInfo::dump(llvm::raw_ostream &OS) const {
8585

8686
LLVM_DUMP_METHOD void ObjCMethodInfo::dump(llvm::raw_ostream &OS) {
8787
static_cast<FunctionInfo &>(*this).dump(OS);
88+
if (Self)
89+
Self->dump(OS);
8890
OS << (DesignatedInit ? "[DesignatedInit] " : "")
8991
<< (RequiredInit ? "[RequiredInit] " : "") << '\n';
9092
}
9193

94+
LLVM_DUMP_METHOD void CXXMethodInfo::dump(llvm::raw_ostream &OS) {
95+
static_cast<FunctionInfo &>(*this).dump(OS);
96+
if (This)
97+
This->dump(OS);
98+
}
99+
92100
LLVM_DUMP_METHOD void TagInfo::dump(llvm::raw_ostream &OS) {
93101
static_cast<CommonTypeInfo &>(*this).dump(OS);
94102
if (HasFlagEnum)

clang/lib/APINotes/APINotesWriter.cpp

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ namespace {
649649
unsigned getVariableInfoSize(const VariableInfo &VI) {
650650
return 2 + getCommonEntityInfoSize(VI) + 2 + VI.getType().size();
651651
}
652+
unsigned getParamInfoSize(const ParamInfo &PI);
652653

653654
/// Emit a serialized representation of the variable information.
654655
void emitVariableInfo(raw_ostream &OS, const VariableInfo &VI) {
@@ -737,6 +738,7 @@ void APINotesWriter::Implementation::writeObjCPropertyBlock(
737738
namespace {
738739
unsigned getFunctionInfoSize(const FunctionInfo &);
739740
void emitFunctionInfo(llvm::raw_ostream &, const FunctionInfo &);
741+
void emitParamInfo(raw_ostream &OS, const ParamInfo &PI);
740742

741743
/// Used to serialize the on-disk Objective-C method table.
742744
class ObjCMethodTableInfo
@@ -760,17 +762,24 @@ class ObjCMethodTableInfo
760762
}
761763

762764
unsigned getUnversionedInfoSize(const ObjCMethodInfo &OMI) {
763-
return getFunctionInfoSize(OMI) + 1;
765+
auto size = getFunctionInfoSize(OMI) + 1;
766+
if (OMI.Self)
767+
size += getParamInfoSize(*OMI.Self);
768+
return size;
764769
}
765770

766771
void emitUnversionedInfo(raw_ostream &OS, const ObjCMethodInfo &OMI) {
767772
uint8_t flags = 0;
768773
llvm::support::endian::Writer writer(OS, llvm::endianness::little);
769774
flags = (flags << 1) | OMI.DesignatedInit;
770775
flags = (flags << 1) | OMI.RequiredInit;
776+
flags = (flags << 1) | static_cast<bool>(OMI.Self);
771777
writer.write<uint8_t>(flags);
772778

773779
emitFunctionInfo(OS, OMI);
780+
781+
if (OMI.Self)
782+
emitParamInfo(OS, *OMI.Self);
774783
}
775784
};
776785

@@ -793,12 +802,22 @@ class CXXMethodTableInfo
793802
return static_cast<size_t>(key.hashValue());
794803
}
795804

796-
unsigned getUnversionedInfoSize(const CXXMethodInfo &OMI) {
797-
return getFunctionInfoSize(OMI);
805+
unsigned getUnversionedInfoSize(const CXXMethodInfo &MI) {
806+
auto size = getFunctionInfoSize(MI) + 1;
807+
if (MI.This)
808+
size += getParamInfoSize(*MI.This);
809+
return size;
798810
}
799811

800-
void emitUnversionedInfo(raw_ostream &OS, const CXXMethodInfo &OMI) {
801-
emitFunctionInfo(OS, OMI);
812+
void emitUnversionedInfo(raw_ostream &OS, const CXXMethodInfo &MI) {
813+
uint8_t flags = 0;
814+
llvm::support::endian::Writer writer(OS, llvm::endianness::little);
815+
flags = (flags << 1) | static_cast<bool>(MI.This);
816+
writer.write<uint8_t>(flags);
817+
818+
emitFunctionInfo(OS, MI);
819+
if (MI.This)
820+
emitParamInfo(OS, *MI.This);
802821
}
803822
};
804823
} // namespace

0 commit comments

Comments
 (0)