Skip to content

Commit 69246a0

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#3526)
2 parents bc5364f + 7395f2a commit 69246a0

File tree

131 files changed

+3836
-1662
lines changed

Some content is hidden

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

131 files changed

+3836
-1662
lines changed

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/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ Sanitizers
552552

553553
Python Binding Changes
554554
----------------------
555+
- Exposed `clang_getCursorLanguage` via `Cursor.language`.
555556

556557
OpenMP Support
557558
--------------

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/lib/Driver/ToolChains/Cuda.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,9 +619,12 @@ void NVPTX::Linker::ConstructJob(Compilation &C, const JobAction &JA,
619619
CmdArgs.push_back(Args.MakeArgString(
620620
"--pxtas-path=" + Args.getLastArgValue(options::OPT_ptxas_path_EQ)));
621621

622-
if (Args.hasArg(options::OPT_cuda_path_EQ))
623-
CmdArgs.push_back(Args.MakeArgString(
624-
"--cuda-path=" + Args.getLastArgValue(options::OPT_cuda_path_EQ)));
622+
if (Args.hasArg(options::OPT_cuda_path_EQ) || TC.CudaInstallation.isValid()) {
623+
StringRef CudaPath = Args.getLastArgValue(
624+
options::OPT_cuda_path_EQ,
625+
llvm::sys::path::parent_path(TC.CudaInstallation.getBinPath()));
626+
CmdArgs.push_back(Args.MakeArgString("--cuda-path=" + CudaPath));
627+
}
625628

626629
// Add paths specified in LIBRARY_PATH environment variable as -L options.
627630
addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");

clang/lib/Headers/avx2intrin.h

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,9 +1371,8 @@ _mm256_movemask_epi8(__m256i __a)
13711371
/// A 128-bit integer vector containing the source bytes.
13721372
/// \returns A 256-bit vector of [16 x i16] containing the sign-extended
13731373
/// values.
1374-
static __inline__ __m256i __DEFAULT_FN_ATTRS256
1375-
_mm256_cvtepi8_epi16(__m128i __V)
1376-
{
1374+
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1375+
_mm256_cvtepi8_epi16(__m128i __V) {
13771376
/* This function always performs a signed extension, but __v16qi is a char
13781377
which may be signed or unsigned, so use __v16qs. */
13791378
return (__m256i)__builtin_convertvector((__v16qs)__V, __v16hi);
@@ -1399,9 +1398,8 @@ _mm256_cvtepi8_epi16(__m128i __V)
13991398
/// A 128-bit integer vector containing the source bytes.
14001399
/// \returns A 256-bit vector of [8 x i32] containing the sign-extended
14011400
/// values.
1402-
static __inline__ __m256i __DEFAULT_FN_ATTRS256
1403-
_mm256_cvtepi8_epi32(__m128i __V)
1404-
{
1401+
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1402+
_mm256_cvtepi8_epi32(__m128i __V) {
14051403
/* This function always performs a signed extension, but __v16qi is a char
14061404
which may be signed or unsigned, so use __v16qs. */
14071405
return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1, 2, 3, 4, 5, 6, 7), __v8si);
@@ -1426,9 +1424,8 @@ _mm256_cvtepi8_epi32(__m128i __V)
14261424
/// A 128-bit integer vector containing the source bytes.
14271425
/// \returns A 256-bit vector of [4 x i64] containing the sign-extended
14281426
/// values.
1429-
static __inline__ __m256i __DEFAULT_FN_ATTRS256
1430-
_mm256_cvtepi8_epi64(__m128i __V)
1431-
{
1427+
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1428+
_mm256_cvtepi8_epi64(__m128i __V) {
14321429
/* This function always performs a signed extension, but __v16qi is a char
14331430
which may be signed or unsigned, so use __v16qs. */
14341431
return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1, 2, 3), __v4di);
@@ -1454,9 +1451,8 @@ _mm256_cvtepi8_epi64(__m128i __V)
14541451
/// A 128-bit vector of [8 x i16] containing the source values.
14551452
/// \returns A 256-bit vector of [8 x i32] containing the sign-extended
14561453
/// values.
1457-
static __inline__ __m256i __DEFAULT_FN_ATTRS256
1458-
_mm256_cvtepi16_epi32(__m128i __V)
1459-
{
1454+
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1455+
_mm256_cvtepi16_epi32(__m128i __V) {
14601456
return (__m256i)__builtin_convertvector((__v8hi)__V, __v8si);
14611457
}
14621458

@@ -1479,9 +1475,8 @@ _mm256_cvtepi16_epi32(__m128i __V)
14791475
/// A 128-bit vector of [8 x i16] containing the source values.
14801476
/// \returns A 256-bit vector of [4 x i64] containing the sign-extended
14811477
/// values.
1482-
static __inline__ __m256i __DEFAULT_FN_ATTRS256
1483-
_mm256_cvtepi16_epi64(__m128i __V)
1484-
{
1478+
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1479+
_mm256_cvtepi16_epi64(__m128i __V) {
14851480
return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v8hi)__V, (__v8hi)__V, 0, 1, 2, 3), __v4di);
14861481
}
14871482

@@ -1504,9 +1499,8 @@ _mm256_cvtepi16_epi64(__m128i __V)
15041499
/// A 128-bit vector of [4 x i32] containing the source values.
15051500
/// \returns A 256-bit vector of [4 x i64] containing the sign-extended
15061501
/// values.
1507-
static __inline__ __m256i __DEFAULT_FN_ATTRS256
1508-
_mm256_cvtepi32_epi64(__m128i __V)
1509-
{
1502+
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1503+
_mm256_cvtepi32_epi64(__m128i __V) {
15101504
return (__m256i)__builtin_convertvector((__v4si)__V, __v4di);
15111505
}
15121506

@@ -1530,9 +1524,8 @@ _mm256_cvtepi32_epi64(__m128i __V)
15301524
/// A 128-bit integer vector containing the source bytes.
15311525
/// \returns A 256-bit vector of [16 x i16] containing the zero-extended
15321526
/// values.
1533-
static __inline__ __m256i __DEFAULT_FN_ATTRS256
1534-
_mm256_cvtepu8_epi16(__m128i __V)
1535-
{
1527+
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1528+
_mm256_cvtepu8_epi16(__m128i __V) {
15361529
return (__m256i)__builtin_convertvector((__v16qu)__V, __v16hi);
15371530
}
15381531

@@ -1556,9 +1549,8 @@ _mm256_cvtepu8_epi16(__m128i __V)
15561549
/// A 128-bit integer vector containing the source bytes.
15571550
/// \returns A 256-bit vector of [8 x i32] containing the zero-extended
15581551
/// values.
1559-
static __inline__ __m256i __DEFAULT_FN_ATTRS256
1560-
_mm256_cvtepu8_epi32(__m128i __V)
1561-
{
1552+
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1553+
_mm256_cvtepu8_epi32(__m128i __V) {
15621554
return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1, 2, 3, 4, 5, 6, 7), __v8si);
15631555
}
15641556

@@ -1581,9 +1573,8 @@ _mm256_cvtepu8_epi32(__m128i __V)
15811573
/// A 128-bit integer vector containing the source bytes.
15821574
/// \returns A 256-bit vector of [4 x i64] containing the zero-extended
15831575
/// values.
1584-
static __inline__ __m256i __DEFAULT_FN_ATTRS256
1585-
_mm256_cvtepu8_epi64(__m128i __V)
1586-
{
1576+
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1577+
_mm256_cvtepu8_epi64(__m128i __V) {
15871578
return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1, 2, 3), __v4di);
15881579
}
15891580

@@ -1607,9 +1598,8 @@ _mm256_cvtepu8_epi64(__m128i __V)
16071598
/// A 128-bit vector of [8 x i16] containing the source values.
16081599
/// \returns A 256-bit vector of [8 x i32] containing the zero-extended
16091600
/// values.
1610-
static __inline__ __m256i __DEFAULT_FN_ATTRS256
1611-
_mm256_cvtepu16_epi32(__m128i __V)
1612-
{
1601+
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1602+
_mm256_cvtepu16_epi32(__m128i __V) {
16131603
return (__m256i)__builtin_convertvector((__v8hu)__V, __v8si);
16141604
}
16151605

@@ -1632,9 +1622,8 @@ _mm256_cvtepu16_epi32(__m128i __V)
16321622
/// A 128-bit vector of [8 x i16] containing the source values.
16331623
/// \returns A 256-bit vector of [4 x i64] containing the zero-extended
16341624
/// values.
1635-
static __inline__ __m256i __DEFAULT_FN_ATTRS256
1636-
_mm256_cvtepu16_epi64(__m128i __V)
1637-
{
1625+
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1626+
_mm256_cvtepu16_epi64(__m128i __V) {
16381627
return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v8hu)__V, (__v8hu)__V, 0, 1, 2, 3), __v4di);
16391628
}
16401629

@@ -1657,9 +1646,8 @@ _mm256_cvtepu16_epi64(__m128i __V)
16571646
/// A 128-bit vector of [4 x i32] containing the source values.
16581647
/// \returns A 256-bit vector of [4 x i64] containing the zero-extended
16591648
/// values.
1660-
static __inline__ __m256i __DEFAULT_FN_ATTRS256
1661-
_mm256_cvtepu32_epi64(__m128i __V)
1662-
{
1649+
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1650+
_mm256_cvtepu32_epi64(__m128i __V) {
16631651
return (__m256i)__builtin_convertvector((__v4su)__V, __v4di);
16641652
}
16651653

clang/lib/Headers/avx512bwintrin.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,9 +1379,8 @@ _mm512_maskz_unpacklo_epi16(__mmask32 __U, __m512i __A, __m512i __B) {
13791379
(__v32hi)_mm512_setzero_si512());
13801380
}
13811381

1382-
static __inline__ __m512i __DEFAULT_FN_ATTRS512
1383-
_mm512_cvtepi8_epi16(__m256i __A)
1384-
{
1382+
static __inline__ __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR
1383+
_mm512_cvtepi8_epi16(__m256i __A) {
13851384
/* This function always performs a signed extension, but __v32qi is a char
13861385
which may be signed or unsigned, so use __v32qs. */
13871386
return (__m512i)__builtin_convertvector((__v32qs)__A, __v32hi);
@@ -1403,9 +1402,8 @@ _mm512_maskz_cvtepi8_epi16(__mmask32 __U, __m256i __A)
14031402
(__v32hi)_mm512_setzero_si512());
14041403
}
14051404

1406-
static __inline__ __m512i __DEFAULT_FN_ATTRS512
1407-
_mm512_cvtepu8_epi16(__m256i __A)
1408-
{
1405+
static __inline__ __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR
1406+
_mm512_cvtepu8_epi16(__m256i __A) {
14091407
return (__m512i)__builtin_convertvector((__v32qu)__A, __v32hi);
14101408
}
14111409

0 commit comments

Comments
 (0)