Skip to content

Commit c055df0

Browse files
committed
Merge branch 'main' of github.com:llvm/llvm-project into loop-vectorize/single-header-mask
2 parents ff6d700 + 8140779 commit c055df0

File tree

612 files changed

+31155
-8609
lines changed

Some content is hidden

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

612 files changed

+31155
-8609
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: 2 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.

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ Non-comprehensive list of changes in this release
124124
This feature is enabled by default but can be disabled by compiling with
125125
``-fno-sanitize-annotate-debug-info-traps``.
126126

127+
- ``__builtin_elementwise_max`` and ``__builtin_elementwise_min`` functions for integer types can
128+
now be used in constant expressions.
129+
127130
New Compiler Flags
128131
------------------
129132
- 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 +298,7 @@ Crash and bug fixes
295298
^^^^^^^^^^^^^^^^^^^
296299
- Fixed a crash in the static analyzer that when the expression in an
297300
``[[assume(expr)]]`` attribute was enclosed in parentheses. (#GH151529)
301+
- Fixed a crash when parsing ``#embed`` parameters with unmatched closing brackets. (#GH152829)
298302

299303
Improvements
300304
^^^^^^^^^^^^
@@ -309,6 +313,7 @@ Sanitizers
309313

310314
Python Binding Changes
311315
----------------------
316+
- Exposed `clang_getCursorLanguage` via `Cursor.language`.
312317

313318
OpenMP Support
314319
--------------

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 {

clang/include/clang/Basic/Builtins.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,13 +1300,13 @@ def ElementwiseBitreverse : Builtin {
13001300

13011301
def ElementwiseMax : Builtin {
13021302
let Spellings = ["__builtin_elementwise_max"];
1303-
let Attributes = [NoThrow, Const, CustomTypeChecking];
1303+
let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
13041304
let Prototype = "void(...)";
13051305
}
13061306

13071307
def ElementwiseMin : Builtin {
13081308
let Spellings = ["__builtin_elementwise_min"];
1309-
let Attributes = [NoThrow, Const, CustomTypeChecking];
1309+
let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
13101310
let Prototype = "void(...)";
13111311
}
13121312

clang/include/clang/Driver/CommonArgs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ const char *RelocationModelName(llvm::Reloc::Model Model);
8585
std::tuple<llvm::Reloc::Model, unsigned, bool>
8686
ParsePICArgs(const ToolChain &ToolChain, const llvm::opt::ArgList &Args);
8787

88+
bool getStaticPIE(const llvm::opt::ArgList &Args, const ToolChain &TC);
89+
8890
unsigned ParseFunctionAlignment(const ToolChain &TC,
8991
const llvm::opt::ArgList &Args);
9092

0 commit comments

Comments
 (0)