Skip to content

Commit 5f404a3

Browse files
authored
Merge branch 'main' into issue-33296
2 parents 824cf42 + b8e4232 commit 5f404a3

File tree

1,446 files changed

+60807
-12903
lines changed

Some content is hidden

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

1,446 files changed

+60807
-12903
lines changed

.ci/utils.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ function at-exit {
2626
mkdir -p artifacts
2727
sccache --show-stats >> artifacts/sccache_stats.txt
2828
cp "${BUILD_DIR}"/.ninja_log artifacts/.ninja_log
29+
cp "${MONOREPO_ROOT}"/*.log artifacts/ || :
2930
cp "${BUILD_DIR}"/test-results.*.xml artifacts/ || :
3031

3132
# If building fails there will be no results files.
3233
shopt -s nullglob
3334

3435
if [[ "$GITHUB_STEP_SUMMARY" != "" ]]; then
3536
python "${MONOREPO_ROOT}"/.ci/generate_test_report_github.py \
36-
$retcode "${BUILD_DIR}"/test-results.*.xml "${BUILD_DIR}"/ninja*.log \
37+
$retcode "${BUILD_DIR}"/test-results.*.xml "${MONOREPO_ROOT}"/ninja*.log \
3738
>> $GITHUB_STEP_SUMMARY
3839
fi
3940
}

clang/bindings/python/clang/cindex.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,6 +1907,15 @@ def linkage(self) -> LinkageKind:
19071907

19081908
return LinkageKind.from_id(self._linkage)
19091909

1910+
@property
1911+
@cursor_null_guard
1912+
def language(self) -> LanguageKind:
1913+
"""Determine the "language" of the entity referred to by a given cursor."""
1914+
if not hasattr(self, "_language"):
1915+
self._language = conf.lib.clang_getCursorLanguage(self)
1916+
1917+
return LanguageKind.from_id(self._language)
1918+
19101919
@property
19111920
@cursor_null_guard
19121921
def tls_kind(self) -> TLSKind:
@@ -2584,6 +2593,17 @@ class LinkageKind(BaseEnumeration):
25842593
EXTERNAL = 4
25852594

25862595

2596+
class LanguageKind(BaseEnumeration):
2597+
"""
2598+
Describe the "language" of the entity referred to by a cursor.
2599+
"""
2600+
2601+
INVALID = 0
2602+
C = 1
2603+
OBJ_C = 2
2604+
C_PLUS_PLUS = 3
2605+
2606+
25872607
class TLSKind(BaseEnumeration):
25882608
"""Describes the kind of thread-local storage (TLS) of a cursor."""
25892609

@@ -4084,6 +4104,7 @@ def set_property(self, property, value):
40844104
("clang_getCursorDisplayName", [Cursor], _CXString),
40854105
("clang_getCursorExceptionSpecificationType", [Cursor], c_int),
40864106
("clang_getCursorExtent", [Cursor], SourceRange),
4107+
("clang_getCursorLanguage", [Cursor], c_int),
40874108
("clang_getCursorLexicalParent", [Cursor], Cursor),
40884109
("clang_getCursorLinkage", [Cursor], c_int),
40894110
("clang_getCursorLocation", [Cursor], SourceLocation),
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import os
2+
3+
from clang.cindex import Config, LanguageKind
4+
5+
if "CLANG_LIBRARY_PATH" in os.environ:
6+
Config.set_library_path(os.environ["CLANG_LIBRARY_PATH"])
7+
8+
import unittest
9+
10+
from .util import get_cursor, get_tu
11+
12+
13+
class TestCursorLanguage(unittest.TestCase):
14+
def test_c(self):
15+
tu = get_tu("int a;", lang="c")
16+
main_func = get_cursor(tu.cursor, "a")
17+
self.assertEqual(main_func.language, LanguageKind.C)
18+
19+
def test_c(self):
20+
tu = get_tu("class Cls {};", lang="cpp")
21+
main_func = get_cursor(tu.cursor, "Cls")
22+
self.assertEqual(main_func.language, LanguageKind.C_PLUS_PLUS)
23+
24+
def test_obj_c(self):
25+
tu = get_tu("@interface If : NSObject", lang="objc")
26+
main_func = get_cursor(tu.cursor, "If")
27+
self.assertEqual(main_func.language, LanguageKind.OBJ_C)

clang/bindings/python/tests/cindex/test_enums.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
BinaryOperator,
77
CursorKind,
88
ExceptionSpecificationKind,
9+
LanguageKind,
910
LinkageKind,
1011
RefQualifierKind,
1112
StorageClass,
@@ -26,6 +27,7 @@ class TestEnums(unittest.TestCase):
2627
AccessSpecifier,
2728
TypeKind,
2829
RefQualifierKind,
30+
LanguageKind,
2931
LinkageKind,
3032
TLSKind,
3133
StorageClass,

clang/docs/LanguageExtensions.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,8 @@ Unless specified otherwise operation(±0) = ±0 and operation(±infinity) = ±in
759759

760760
The integer elementwise intrinsics, including ``__builtin_elementwise_popcount``,
761761
``__builtin_elementwise_bitreverse``, ``__builtin_elementwise_add_sat``,
762-
``__builtin_elementwise_sub_sat`` can be called in a ``constexpr`` context.
762+
``__builtin_elementwise_sub_sat``, ``__builtin_elementwise_max``,
763+
``__builtin_elementwise_min`` can be called in a ``constexpr`` context.
763764

764765
No implicit promotion of integer types takes place. The mixing of integer types
765766
of different sizes and signs is forbidden in binary and ternary builtins.
@@ -859,6 +860,15 @@ of different sizes and signs is forbidden in binary and ternary builtins.
859860
semantics, see `LangRef
860861
<http://llvm.org/docs/LangRef.html#llvm-min-intrinsics-comparation>`_
861862
for the comparison.
863+
T __builtin_elementwise_fshl(T x, T y, T z) perform a funnel shift left. Concatenate x and y (x is the most integer types
864+
significant bits of the wide value), the combined value is shifted
865+
left by z, and the most significant bits are extracted to produce
866+
a result that is the same size as the original arguments.
867+
868+
T __builtin_elementwise_fshr(T x, T y, T z) perform a funnel shift right. Concatenate x and y (x is the most integer types
869+
significant bits of the wide value), the combined value is shifted
870+
right by z, and the least significant bits are extracted to produce
871+
a result that is the same size as the original arguments.
862872
============================================== ====================================================================== =========================================
863873

864874

clang/docs/OpenMPSupport.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ implementation.
191191
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
192192
| device | teams construct on the host device | :good:`done` | r371553 |
193193
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
194-
| device | support non-contiguous array sections for target update | :good:`done` | |
194+
| device | support non-contiguous array sections for target update | :good:`done` | https://github.com/llvm/llvm-project/pull/144635 |
195195
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
196196
| device | pointer attachment | :good:`done` | |
197197
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+

clang/docs/ReleaseNotes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ C23 Feature Support
113113

114114
Non-comprehensive list of changes in this release
115115
-------------------------------------------------
116+
- Added ``__builtin_elementwise_fshl`` and ``__builtin_elementwise_fshr``.
117+
116118
- Added ``__builtin_elementwise_minnumnum`` and ``__builtin_elementwise_maxnumnum``.
117119

118120
- Trapping UBSan (e.g. ``-fsanitize-trap=undefined``) now emits a string describing the reason for
@@ -124,6 +126,9 @@ Non-comprehensive list of changes in this release
124126
This feature is enabled by default but can be disabled by compiling with
125127
``-fno-sanitize-annotate-debug-info-traps``.
126128

129+
- ``__builtin_elementwise_max`` and ``__builtin_elementwise_min`` functions for integer types can
130+
now be used in constant expressions.
131+
127132
New Compiler Flags
128133
------------------
129134
- New option ``-fno-sanitize-annotate-debug-info-traps`` added to disable emitting trap reasons into the debug info when compiling with trapping UBSan (e.g. ``-fsanitize-trap=undefined``).
@@ -295,6 +300,7 @@ Crash and bug fixes
295300
^^^^^^^^^^^^^^^^^^^
296301
- Fixed a crash in the static analyzer that when the expression in an
297302
``[[assume(expr)]]`` attribute was enclosed in parentheses. (#GH151529)
303+
- Fixed a crash when parsing ``#embed`` parameters with unmatched closing brackets. (#GH152829)
298304

299305
Improvements
300306
^^^^^^^^^^^^
@@ -309,12 +315,14 @@ Sanitizers
309315

310316
Python Binding Changes
311317
----------------------
318+
- Exposed `clang_getCursorLanguage` via `Cursor.language`.
312319

313320
OpenMP Support
314321
--------------
315322
- Added parsing and semantic analysis support for the ``need_device_addr``
316323
modifier in the ``adjust_args`` clause.
317324
- Allow array length to be omitted in array section subscript expression.
325+
- Fixed non-contiguous strided update in the ``omp target update`` directive with the ``from`` clause.
318326

319327
Improvements
320328
^^^^^^^^^^^^

clang/include/clang/APINotes/Types.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ class CommonTypeInfo : public CommonEntityInfo {
141141
/// The NS error domain for this type.
142142
std::optional<std::string> NSErrorDomain;
143143

144+
/// The Swift protocol that this type should be automatically conformed to.
145+
std::optional<std::string> SwiftConformance;
146+
144147
public:
145148
CommonTypeInfo() {}
146149

@@ -165,6 +168,14 @@ class CommonTypeInfo : public CommonEntityInfo {
165168
: std::nullopt;
166169
}
167170

171+
std::optional<std::string> getSwiftConformance() const {
172+
return SwiftConformance;
173+
}
174+
175+
void setSwiftConformance(std::optional<std::string> conformance) {
176+
SwiftConformance = conformance;
177+
}
178+
168179
friend bool operator==(const CommonTypeInfo &, const CommonTypeInfo &);
169180

170181
CommonTypeInfo &operator|=(const CommonTypeInfo &RHS) {
@@ -175,6 +186,8 @@ class CommonTypeInfo : public CommonEntityInfo {
175186
setSwiftBridge(RHS.getSwiftBridge());
176187
if (!NSErrorDomain)
177188
setNSErrorDomain(RHS.getNSErrorDomain());
189+
if (SwiftConformance)
190+
setSwiftConformance(RHS.getSwiftConformance());
178191

179192
return *this;
180193
}
@@ -185,7 +198,8 @@ class CommonTypeInfo : public CommonEntityInfo {
185198
inline bool operator==(const CommonTypeInfo &LHS, const CommonTypeInfo &RHS) {
186199
return static_cast<const CommonEntityInfo &>(LHS) == RHS &&
187200
LHS.SwiftBridge == RHS.SwiftBridge &&
188-
LHS.NSErrorDomain == RHS.NSErrorDomain;
201+
LHS.NSErrorDomain == RHS.NSErrorDomain &&
202+
LHS.SwiftConformance == RHS.SwiftConformance;
189203
}
190204

191205
inline bool operator!=(const CommonTypeInfo &LHS, const CommonTypeInfo &RHS) {
@@ -739,9 +753,6 @@ class TagInfo : public CommonTypeInfo {
739753
std::optional<std::string> SwiftReleaseOp;
740754
std::optional<std::string> SwiftDefaultOwnership;
741755

742-
/// The Swift protocol that this type should be automatically conformed to.
743-
std::optional<std::string> SwiftConformance;
744-
745756
std::optional<EnumExtensibilityKind> EnumExtensibility;
746757

747758
TagInfo()
@@ -790,9 +801,6 @@ class TagInfo : public CommonTypeInfo {
790801
if (!SwiftDefaultOwnership)
791802
SwiftDefaultOwnership = RHS.SwiftDefaultOwnership;
792803

793-
if (!SwiftConformance)
794-
SwiftConformance = RHS.SwiftConformance;
795-
796804
if (!HasFlagEnum)
797805
setFlagEnum(RHS.isFlagEnum());
798806

@@ -819,7 +827,6 @@ inline bool operator==(const TagInfo &LHS, const TagInfo &RHS) {
819827
LHS.SwiftRetainOp == RHS.SwiftRetainOp &&
820828
LHS.SwiftReleaseOp == RHS.SwiftReleaseOp &&
821829
LHS.SwiftDefaultOwnership == RHS.SwiftDefaultOwnership &&
822-
LHS.SwiftConformance == RHS.SwiftConformance &&
823830
LHS.isFlagEnum() == RHS.isFlagEnum() &&
824831
LHS.isSwiftCopyable() == RHS.isSwiftCopyable() &&
825832
LHS.isSwiftEscapable() == RHS.isSwiftEscapable() &&

clang/include/clang/AST/ExprCXX.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,19 @@ class CXXConstructExpr : public Expr {
17121712
CXXConstructExprBits.IsImmediateEscalating = Set;
17131713
}
17141714

1715+
/// Returns the WarnUnusedResultAttr that is declared on the callee
1716+
/// or its return type declaration, together with a NamedDecl that
1717+
/// refers to the declaration the attribute is attached to.
1718+
std::pair<const NamedDecl *, const WarnUnusedResultAttr *>
1719+
getUnusedResultAttr(const ASTContext &Ctx) const {
1720+
return getUnusedResultAttrImpl(getConstructor(), getType());
1721+
}
1722+
1723+
/// Returns true if this call expression should warn on unused results.
1724+
bool hasUnusedResultAttr(const ASTContext &Ctx) const {
1725+
return getUnusedResultAttr(Ctx).second != nullptr;
1726+
}
1727+
17151728
SourceLocation getBeginLoc() const LLVM_READONLY;
17161729
SourceLocation getEndLoc() const LLVM_READONLY;
17171730
SourceRange getParenOrBraceRange() const { return ParenOrBraceRange; }

clang/include/clang/Basic/Attr.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4932,6 +4932,7 @@ def HLSLResourceBinding: InheritableAttr {
49324932
return SpaceNumber;
49334933
}
49344934
void setImplicitBindingOrderID(uint32_t Value) {
4935+
assert(!hasImplicitBindingOrderID() && "attribute already has implicit binding order id");
49354936
ImplicitBindingOrderID = Value;
49364937
}
49374938
bool hasImplicitBindingOrderID() const {

0 commit comments

Comments
 (0)