Skip to content

Commit a2c6ef8

Browse files
authored
Merge branch 'main' into dag-match-bitlogic
2 parents b67f976 + 15c2f79 commit a2c6ef8

File tree

123 files changed

+5101
-2336
lines changed

Some content is hidden

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

123 files changed

+5101
-2336
lines changed

clang/bindings/python/clang/cindex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,7 +1887,7 @@ def binary_operator(self):
18871887
"""
18881888

18891889
if not hasattr(self, "_binopcode"):
1890-
self._binopcode = conf.lib.clang_Cursor_getBinaryOpcode(self)
1890+
self._binopcode = conf.lib.clang_getCursorBinaryOperatorKind(self)
18911891

18921892
return BinaryOperator.from_id(self._binopcode)
18931893

@@ -4097,7 +4097,7 @@ def set_property(self, property, value):
40974097
("clang_Cursor_getTemplateArgumentType", [Cursor, c_uint], Type),
40984098
("clang_Cursor_getTemplateArgumentValue", [Cursor, c_uint], c_longlong),
40994099
("clang_Cursor_getTemplateArgumentUnsignedValue", [Cursor, c_uint], c_ulonglong),
4100-
("clang_Cursor_getBinaryOpcode", [Cursor], c_int),
4100+
("clang_getCursorBinaryOperatorKind", [Cursor], c_int),
41014101
("clang_Cursor_getBriefCommentText", [Cursor], _CXString),
41024102
("clang_Cursor_getRawCommentText", [Cursor], _CXString),
41034103
("clang_Cursor_getOffsetOfField", [Cursor], c_longlong),

clang/docs/CommandGuide/clang.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,15 @@ Language Selection and Mode Options
146146
147147
ISO C 2017 with GNU extensions
148148

149+
| ``c23``
150+
| ``iso9899:2024``
151+
152+
ISO C 2023
153+
154+
| ``gnu23``
155+
156+
ISO C 2023 with GNU extensions
157+
149158
The default C language standard is ``gnu17``, except on PS4, where it is
150159
``gnu99``.
151160

clang/docs/ReleaseNotes.rst

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ C Language Changes
205205
``-Wunterminated-string-initialization``. However, this diagnostic is not
206206
silenced by the ``nonstring`` attribute as these initializations are always
207207
incompatible with C++.
208-
- Added ``-Wjump-bypasses-init``, which is off by default and grouped under
208+
- Added ``-Wjump-misses-init``, which is off by default and grouped under
209209
``-Wc++-compat``. It diagnoses when a jump (``goto`` to its label, ``switch``
210210
to its ``case``) will bypass the initialization of a local variable, which is
211211
invalid in C++.
@@ -241,6 +241,7 @@ C2y Feature Support
241241

242242
C23 Feature Support
243243
^^^^^^^^^^^^^^^^^^^
244+
- Clang now accepts ``-std=iso9899:2024`` as an alias for C23.
244245
- Added ``__builtin_c23_va_start()`` for compatibility with GCC and to enable
245246
better diagnostic behavior for the ``va_start()`` macro in C23 and later.
246247
This also updates the definition of ``va_start()`` in ``<stdarg.h>`` to use
@@ -254,7 +255,10 @@ C23 Feature Support
254255
- Implemented `WG14 N3037 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3037.pdf>`_
255256
which allows tag types to be redefined within the same translation unit so
256257
long as both definitions are structurally equivalent (same tag types, same
257-
tag names, same tag members, etc).
258+
tag names, same tag members, etc). As a result of this paper, ``-Wvisibility``
259+
is no longer diagnosed in C23 if the parameter is a complete tag type (it
260+
does still fire when the parameter is an incomplete tag type as that cannot
261+
be completed).
258262
- Fixed a failed assertion with an invalid parameter to the ``#embed``
259263
directive. Fixes #GH126940.
260264

@@ -550,7 +554,9 @@ Bug Fixes in This Version
550554
- Fixed visibility calculation for template functions. (#GH103477)
551555
- Fixed a bug where an attribute before a ``pragma clang attribute`` or
552556
``pragma clang __debug`` would cause an assertion. Instead, this now diagnoses
553-
the invalid attribute location appropriately. (#GH137861)
557+
the invalid attribute location appropriately. (#GH137861)
558+
- Fixed a crash when a malformed ``_Pragma`` directive appears as part of an
559+
``#include`` directive. (#GH138094)
554560

555561
Bug Fixes to Compiler Builtins
556562
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -799,6 +805,10 @@ libclang
799805
- Fixed a buffer overflow in ``CXString`` implementation. The fix may result in
800806
increased memory allocation.
801807

808+
- Deprecate ``clang_Cursor_GetBinaryOpcode`` and ``clang_Cursor_getBinaryOpcodeStr``
809+
implementations, which are duplicates of ``clang_getCursorBinaryOperatorKind``
810+
and ``clang_getBinaryOperatorKindSpelling`` respectively.
811+
802812
Code Completion
803813
---------------
804814

clang/include/clang-c/Index.h

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3882,12 +3882,16 @@ enum CX_BinaryOperatorKind {
38823882

38833883
/**
38843884
* \brief Returns the operator code for the binary operator.
3885+
*
3886+
* @deprecated: use clang_getCursorBinaryOperatorKind instead.
38853887
*/
38863888
CINDEX_LINKAGE enum CX_BinaryOperatorKind
38873889
clang_Cursor_getBinaryOpcode(CXCursor C);
38883890

38893891
/**
38903892
* \brief Returns a string containing the spelling of the binary operator.
3893+
*
3894+
* @deprecated: use clang_getBinaryOperatorKindSpelling instead
38913895
*/
38923896
CINDEX_LINKAGE CXString
38933897
clang_Cursor_getBinaryOpcodeStr(enum CX_BinaryOperatorKind Op);
@@ -6683,73 +6687,74 @@ CINDEX_LINKAGE unsigned clang_visitCXXMethods(CXType T, CXFieldVisitor visitor,
66836687
*/
66846688
enum CXBinaryOperatorKind {
66856689
/** This value describes cursors which are not binary operators. */
6686-
CXBinaryOperator_Invalid,
6690+
CXBinaryOperator_Invalid = 0,
66876691
/** C++ Pointer - to - member operator. */
6688-
CXBinaryOperator_PtrMemD,
6692+
CXBinaryOperator_PtrMemD = 1,
66896693
/** C++ Pointer - to - member operator. */
6690-
CXBinaryOperator_PtrMemI,
6694+
CXBinaryOperator_PtrMemI = 2,
66916695
/** Multiplication operator. */
6692-
CXBinaryOperator_Mul,
6696+
CXBinaryOperator_Mul = 3,
66936697
/** Division operator. */
6694-
CXBinaryOperator_Div,
6698+
CXBinaryOperator_Div = 4,
66956699
/** Remainder operator. */
6696-
CXBinaryOperator_Rem,
6700+
CXBinaryOperator_Rem = 5,
66976701
/** Addition operator. */
6698-
CXBinaryOperator_Add,
6702+
CXBinaryOperator_Add = 6,
66996703
/** Subtraction operator. */
6700-
CXBinaryOperator_Sub,
6704+
CXBinaryOperator_Sub = 7,
67016705
/** Bitwise shift left operator. */
6702-
CXBinaryOperator_Shl,
6706+
CXBinaryOperator_Shl = 8,
67036707
/** Bitwise shift right operator. */
6704-
CXBinaryOperator_Shr,
6708+
CXBinaryOperator_Shr = 9,
67056709
/** C++ three-way comparison (spaceship) operator. */
6706-
CXBinaryOperator_Cmp,
6710+
CXBinaryOperator_Cmp = 10,
67076711
/** Less than operator. */
6708-
CXBinaryOperator_LT,
6712+
CXBinaryOperator_LT = 11,
67096713
/** Greater than operator. */
6710-
CXBinaryOperator_GT,
6714+
CXBinaryOperator_GT = 12,
67116715
/** Less or equal operator. */
6712-
CXBinaryOperator_LE,
6716+
CXBinaryOperator_LE = 13,
67136717
/** Greater or equal operator. */
6714-
CXBinaryOperator_GE,
6718+
CXBinaryOperator_GE = 14,
67156719
/** Equal operator. */
6716-
CXBinaryOperator_EQ,
6720+
CXBinaryOperator_EQ = 15,
67176721
/** Not equal operator. */
6718-
CXBinaryOperator_NE,
6722+
CXBinaryOperator_NE = 16,
67196723
/** Bitwise AND operator. */
6720-
CXBinaryOperator_And,
6724+
CXBinaryOperator_And = 17,
67216725
/** Bitwise XOR operator. */
6722-
CXBinaryOperator_Xor,
6726+
CXBinaryOperator_Xor = 18,
67236727
/** Bitwise OR operator. */
6724-
CXBinaryOperator_Or,
6728+
CXBinaryOperator_Or = 19,
67256729
/** Logical AND operator. */
6726-
CXBinaryOperator_LAnd,
6730+
CXBinaryOperator_LAnd = 20,
67276731
/** Logical OR operator. */
6728-
CXBinaryOperator_LOr,
6732+
CXBinaryOperator_LOr = 21,
67296733
/** Assignment operator. */
6730-
CXBinaryOperator_Assign,
6734+
CXBinaryOperator_Assign = 22,
67316735
/** Multiplication assignment operator. */
6732-
CXBinaryOperator_MulAssign,
6736+
CXBinaryOperator_MulAssign = 23,
67336737
/** Division assignment operator. */
6734-
CXBinaryOperator_DivAssign,
6738+
CXBinaryOperator_DivAssign = 24,
67356739
/** Remainder assignment operator. */
6736-
CXBinaryOperator_RemAssign,
6740+
CXBinaryOperator_RemAssign = 25,
67376741
/** Addition assignment operator. */
6738-
CXBinaryOperator_AddAssign,
6742+
CXBinaryOperator_AddAssign = 26,
67396743
/** Subtraction assignment operator. */
6740-
CXBinaryOperator_SubAssign,
6744+
CXBinaryOperator_SubAssign = 27,
67416745
/** Bitwise shift left assignment operator. */
6742-
CXBinaryOperator_ShlAssign,
6746+
CXBinaryOperator_ShlAssign = 28,
67436747
/** Bitwise shift right assignment operator. */
6744-
CXBinaryOperator_ShrAssign,
6748+
CXBinaryOperator_ShrAssign = 29,
67456749
/** Bitwise AND assignment operator. */
6746-
CXBinaryOperator_AndAssign,
6750+
CXBinaryOperator_AndAssign = 30,
67476751
/** Bitwise XOR assignment operator. */
6748-
CXBinaryOperator_XorAssign,
6752+
CXBinaryOperator_XorAssign = 31,
67496753
/** Bitwise OR assignment operator. */
6750-
CXBinaryOperator_OrAssign,
6754+
CXBinaryOperator_OrAssign = 32,
67516755
/** Comma operator. */
6752-
CXBinaryOperator_Comma
6756+
CXBinaryOperator_Comma = 33,
6757+
CXBinaryOperator_Last = CXBinaryOperator_Comma
67536758
};
67546759

67556760
/**

clang/include/clang/AST/Type.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3602,6 +3602,9 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode {
36023602
}
36033603

36043604
NestedNameSpecifier *getQualifier() const { return Qualifier; }
3605+
/// Note: this can trigger extra deserialization when external AST sources are
3606+
/// used. Prefer `getCXXRecordDecl()` unless you really need the most recent
3607+
/// decl.
36053608
CXXRecordDecl *getMostRecentCXXRecordDecl() const;
36063609

36073610
bool isSugared() const;
@@ -3610,7 +3613,10 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode {
36103613
}
36113614

36123615
void Profile(llvm::FoldingSetNodeID &ID) {
3613-
Profile(ID, getPointeeType(), getQualifier(), getMostRecentCXXRecordDecl());
3616+
// FIXME: `getMostRecentCXXRecordDecl()` should be possible to use here,
3617+
// however when external AST sources are used it causes nondeterminism
3618+
// issues (see https://github.com/llvm/llvm-project/pull/137910).
3619+
Profile(ID, getPointeeType(), getQualifier(), getCXXRecordDecl());
36143620
}
36153621

36163622
static void Profile(llvm::FoldingSetNodeID &ID, QualType Pointee,
@@ -3620,6 +3626,9 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode {
36203626
static bool classof(const Type *T) {
36213627
return T->getTypeClass() == MemberPointer;
36223628
}
3629+
3630+
private:
3631+
CXXRecordDecl *getCXXRecordDecl() const;
36233632
};
36243633

36253634
/// Capture whether this is a normal array (e.g. int X[4])

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def DefaultConstInit : DiagGroup<"default-const-init",
177177
def ImplicitVoidPtrCast : DiagGroup<"implicit-void-ptr-cast">;
178178
def ImplicitIntToEnumCast : DiagGroup<"implicit-int-enum-cast",
179179
[ImplicitEnumEnumCast]>;
180-
def JumpBypassesInit : DiagGroup<"jump-bypasses-init">;
180+
def JumpBypassesInit : DiagGroup<"jump-misses-init">;
181181
def TentativeDefnCompat : DiagGroup<"tentative-definition-compat">;
182182
def CXXCompat: DiagGroup<"c++-compat", [ImplicitVoidPtrCast, DefaultConstInit,
183183
ImplicitIntToEnumCast, HiddenCppDecl,

clang/include/clang/Basic/LangStandards.def

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,14 @@ LANGSTANDARD_ALIAS(gnu17, "gnu18")
8989

9090
// C23 modes
9191
LANGSTANDARD(c23, "c23",
92-
C, "Working Draft for ISO C23",
92+
C, "ISO C 2023",
9393
LineComment | C99 | C11 | C17 | C23 | Digraphs | HexFloat)
94+
LANGSTANDARD_ALIAS(c23, "iso9899:2024")
9495
LANGSTANDARD_ALIAS_DEPR(c23, "c2x")
9596
LANGSTANDARD(gnu23, "gnu23",
96-
C, "Working Draft for ISO C23 with GNU extensions",
97+
C, "ISO C 2023 with GNU extensions",
9798
LineComment | C99 | C11 | C17 | C23 | Digraphs | GNUMode | HexFloat)
9899
LANGSTANDARD_ALIAS_DEPR(gnu23, "gnu2x")
99-
// FIXME: Add the alias for iso9899:202* once we know the year ISO publishes
100-
// the document (expected to be 2024).
101100

102101
// C2y modes
103102
LANGSTANDARD(c2y, "c2y",

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,12 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
834834
return false;
835835
}
836836

837+
// Bail out if the function declaration itself is invalid. We will
838+
// have produced a relevant diagnostic while parsing it, so just
839+
// note the problematic sub-expression.
840+
if (F->getDecl()->isInvalidDecl())
841+
return Invalid(S, OpPC);
842+
837843
if (S.checkingPotentialConstantExpression() && S.Current->getDepth() != 0)
838844
return false;
839845

clang/lib/AST/ExternalASTSource.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ uint32_t ExternalASTSource::incrementGeneration(ASTContext &C) {
129129
// FIXME: Only bump the generation counter if the current generation number
130130
// has been observed?
131131
if (!++CurrentGeneration)
132-
llvm::report_fatal_error("generation counter overflowed", false);
132+
llvm::reportFatalUsageError("generation counter overflowed");
133133
}
134134

135135
return OldGeneration;

clang/lib/AST/Type.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5305,10 +5305,14 @@ void MemberPointerType::Profile(llvm::FoldingSetNodeID &ID, QualType Pointee,
53055305
ID.AddPointer(Cls->getCanonicalDecl());
53065306
}
53075307

5308+
CXXRecordDecl *MemberPointerType::getCXXRecordDecl() const {
5309+
return dyn_cast<MemberPointerType>(getCanonicalTypeInternal())
5310+
->getQualifier()
5311+
->getAsRecordDecl();
5312+
}
5313+
53085314
CXXRecordDecl *MemberPointerType::getMostRecentCXXRecordDecl() const {
5309-
auto *RD = dyn_cast<MemberPointerType>(getCanonicalTypeInternal())
5310-
->getQualifier()
5311-
->getAsRecordDecl();
5315+
auto *RD = getCXXRecordDecl();
53125316
if (!RD)
53135317
return nullptr;
53145318
return RD->getMostRecentNonInjectedDecl();

0 commit comments

Comments
 (0)