Skip to content

Commit 0e8c729

Browse files
authored
merge main into amd-staging (llvm#1339)
2 parents 2cb990a + a435982 commit 0e8c729

File tree

61 files changed

+3403
-5130
lines changed

Some content is hidden

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

61 files changed

+3403
-5130
lines changed

clang/bindings/python/clang/cindex.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2802,7 +2802,7 @@ class _CXUnsavedFile(Structure):
28022802
# Functions calls through the python interface are rather slow. Fortunately,
28032803
# for most symboles, we do not need to perform a function call. Their spelling
28042804
# never changes and is consequently provided by this spelling cache.
2805-
spelling_cache = {
2805+
SPELLING_CACHE = {
28062806
# 0: CompletionChunk.Kind("Optional"),
28072807
# 1: CompletionChunk.Kind("TypedText"),
28082808
# 2: CompletionChunk.Kind("Text"),
@@ -2848,8 +2848,8 @@ def __repr__(self):
28482848

28492849
@CachedProperty
28502850
def spelling(self):
2851-
if self.__kindNumber in spelling_cache:
2852-
return spelling_cache[self.__kindNumber]
2851+
if self.__kindNumber in SPELLING_CACHE:
2852+
return SPELLING_CACHE[self.__kindNumber]
28532853
return _CXString.from_result(
28542854
conf.lib.clang_getCompletionChunkText(self.cs, self.key)
28552855
)
@@ -3846,7 +3846,7 @@ def set_property(self, property, value):
38463846
fields_visit_callback = CFUNCTYPE(c_int, Cursor, py_object)
38473847

38483848
# Functions strictly alphabetical order.
3849-
function_list: list[LibFunc] = [
3849+
FUNCTION_LIST: list[LibFunc] = [
38503850
(
38513851
"clang_annotateTokens",
38523852
[TranslationUnit, POINTER(Token), c_uint, POINTER(Cursor)],
@@ -4125,7 +4125,7 @@ def register_functions(lib: CDLL, ignore_errors: bool) -> None:
41254125
def register(item: LibFunc) -> None:
41264126
register_function(lib, item, ignore_errors)
41274127

4128-
for f in function_list:
4128+
for f in FUNCTION_LIST:
41294129
register(f)
41304130

41314131

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import sys
1111
from pathlib import Path
1212

13-
inputs_dir = os.path.join(os.path.dirname(__file__), "INPUTS")
13+
INPUTS_DIR = os.path.join(os.path.dirname(__file__), "INPUTS")
1414

1515

1616
@unittest.skipIf(sys.platform == "win32", "TODO: Fix these tests on Windows")
@@ -34,23 +34,23 @@ def test_create_fail(self):
3434

3535
def test_create(self):
3636
"""Check we can load a compilation database"""
37-
CompilationDatabase.fromDirectory(inputs_dir)
37+
CompilationDatabase.fromDirectory(INPUTS_DIR)
3838

3939
def test_lookup_succeed(self):
4040
"""Check we get some results if the file exists in the db"""
41-
cdb = CompilationDatabase.fromDirectory(inputs_dir)
41+
cdb = CompilationDatabase.fromDirectory(INPUTS_DIR)
4242
cmds = cdb.getCompileCommands("/home/john.doe/MyProject/project.cpp")
4343
self.assertNotEqual(len(cmds), 0)
4444

4545
def test_lookup_succeed_pathlike(self):
4646
"""Same as test_lookup_succeed, but with PathLikes"""
47-
cdb = CompilationDatabase.fromDirectory(Path(inputs_dir))
47+
cdb = CompilationDatabase.fromDirectory(Path(INPUTS_DIR))
4848
cmds = cdb.getCompileCommands(Path("/home/john.doe/MyProject/project.cpp"))
4949
self.assertNotEqual(len(cmds), 0)
5050

5151
def test_all_compilecommand(self):
5252
"""Check we get all results from the db"""
53-
cdb = CompilationDatabase.fromDirectory(inputs_dir)
53+
cdb = CompilationDatabase.fromDirectory(INPUTS_DIR)
5454
cmds = cdb.getAllCompileCommands()
5555
self.assertEqual(len(cmds), 3)
5656
expected = [
@@ -100,7 +100,7 @@ def test_all_compilecommand(self):
100100

101101
def test_1_compilecommand(self):
102102
"""Check file with single compile command"""
103-
cdb = CompilationDatabase.fromDirectory(inputs_dir)
103+
cdb = CompilationDatabase.fromDirectory(INPUTS_DIR)
104104
file = "/home/john.doe/MyProject/project.cpp"
105105
cmds = cdb.getCompileCommands(file)
106106
self.assertEqual(len(cmds), 1)
@@ -119,7 +119,7 @@ def test_1_compilecommand(self):
119119

120120
def test_2_compilecommand(self):
121121
"""Check file with 2 compile commands"""
122-
cdb = CompilationDatabase.fromDirectory(inputs_dir)
122+
cdb = CompilationDatabase.fromDirectory(INPUTS_DIR)
123123
cmds = cdb.getCompileCommands("/home/john.doe/MyProject/project2.cpp")
124124
self.assertEqual(len(cmds), 2)
125125
expected = [
@@ -154,23 +154,23 @@ def test_2_compilecommand(self):
154154

155155
def test_compilecommand_iterator_stops(self):
156156
"""Check that iterator stops after the correct number of elements"""
157-
cdb = CompilationDatabase.fromDirectory(inputs_dir)
157+
cdb = CompilationDatabase.fromDirectory(INPUTS_DIR)
158158
count = 0
159159
for cmd in cdb.getCompileCommands("/home/john.doe/MyProject/project2.cpp"):
160160
count += 1
161161
self.assertLessEqual(count, 2)
162162

163163
def test_compilationDB_references(self):
164164
"""Ensure CompilationsCommands are independent of the database"""
165-
cdb = CompilationDatabase.fromDirectory(inputs_dir)
165+
cdb = CompilationDatabase.fromDirectory(INPUTS_DIR)
166166
cmds = cdb.getCompileCommands("/home/john.doe/MyProject/project.cpp")
167167
del cdb
168168
gc.collect()
169169
cmds[0].directory
170170

171171
def test_compilationCommands_references(self):
172172
"""Ensure CompilationsCommand keeps a reference to CompilationCommands"""
173-
cdb = CompilationDatabase.fromDirectory(inputs_dir)
173+
cdb = CompilationDatabase.fromDirectory(INPUTS_DIR)
174174
cmds = cdb.getCompileCommands("/home/john.doe/MyProject/project.cpp")
175175
del cdb
176176
cmd0 = cmds[0]

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
from .util import get_cursor, get_cursors, get_tu
2424

25-
children_test = """\
25+
CHILDREN_TEST = """\
2626
struct s0 {
2727
int a;
2828
int b;
@@ -42,23 +42,23 @@
4242
}
4343
"""
4444

45-
parent_test = """\
45+
PARENT_TEST = """\
4646
class C {
4747
void f();
4848
}
4949
5050
void C::f() { }
5151
"""
5252

53-
template_arg_test = """\
53+
TEMPLATE_ARG_TEST = """\
5454
template <int kInt, typename T, bool kBool>
5555
void foo();
5656
5757
template<>
5858
void foo<-7, float, true>();
5959
"""
6060

61-
binops = """\
61+
BINOPS = """\
6262
struct C {
6363
int m;
6464
};
@@ -119,7 +119,7 @@ class C {
119119

120120
class TestCursor(unittest.TestCase):
121121
def test_get_children(self):
122-
tu = get_tu(children_test)
122+
tu = get_tu(CHILDREN_TEST)
123123

124124
it = tu.cursor.get_children()
125125
tu_nodes = list(it)
@@ -614,15 +614,15 @@ def test_underlying_type(self):
614614
self.assertEqual(underlying.kind, TypeKind.INT)
615615

616616
def test_semantic_parent(self):
617-
tu = get_tu(parent_test, "cpp")
617+
tu = get_tu(PARENT_TEST, "cpp")
618618
curs = get_cursors(tu, "f")
619619
decl = get_cursor(tu, "C")
620620
self.assertEqual(len(curs), 2)
621621
self.assertEqual(curs[0].semantic_parent, curs[1].semantic_parent)
622622
self.assertEqual(curs[0].semantic_parent, decl)
623623

624624
def test_lexical_parent(self):
625-
tu = get_tu(parent_test, "cpp")
625+
tu = get_tu(PARENT_TEST, "cpp")
626626
curs = get_cursors(tu, "f")
627627
decl = get_cursor(tu, "C")
628628
self.assertEqual(len(curs), 2)
@@ -866,13 +866,13 @@ def test_get_arguments(self):
866866
self.assertEqual(arguments[1].spelling, "j")
867867

868868
def test_get_num_template_arguments(self):
869-
tu = get_tu(template_arg_test, lang="cpp")
869+
tu = get_tu(TEMPLATE_ARG_TEST, lang="cpp")
870870
foos = get_cursors(tu, "foo")
871871

872872
self.assertEqual(foos[1].get_num_template_arguments(), 3)
873873

874874
def test_get_template_argument_kind(self):
875-
tu = get_tu(template_arg_test, lang="cpp")
875+
tu = get_tu(TEMPLATE_ARG_TEST, lang="cpp")
876876
foos = get_cursors(tu, "foo")
877877

878878
self.assertEqual(
@@ -886,20 +886,20 @@ def test_get_template_argument_kind(self):
886886
)
887887

888888
def test_get_template_argument_type(self):
889-
tu = get_tu(template_arg_test, lang="cpp")
889+
tu = get_tu(TEMPLATE_ARG_TEST, lang="cpp")
890890
foos = get_cursors(tu, "foo")
891891

892892
self.assertEqual(foos[1].get_template_argument_type(1).kind, TypeKind.FLOAT)
893893

894894
def test_get_template_argument_value(self):
895-
tu = get_tu(template_arg_test, lang="cpp")
895+
tu = get_tu(TEMPLATE_ARG_TEST, lang="cpp")
896896
foos = get_cursors(tu, "foo")
897897

898898
self.assertEqual(foos[1].get_template_argument_value(0), -7)
899899
self.assertEqual(foos[1].get_template_argument_value(2), True)
900900

901901
def test_get_template_argument_unsigned_value(self):
902-
tu = get_tu(template_arg_test, lang="cpp")
902+
tu = get_tu(TEMPLATE_ARG_TEST, lang="cpp")
903903
foos = get_cursors(tu, "foo")
904904

905905
self.assertEqual(foos[1].get_template_argument_unsigned_value(0), 2**32 - 7)
@@ -931,7 +931,7 @@ def test_mangled_name(self):
931931
)
932932

933933
def test_binop(self):
934-
tu = get_tu(binops, lang="cpp")
934+
tu = get_tu(BINOPS, lang="cpp")
935935

936936
operators = {
937937
# not exposed yet
@@ -1004,7 +1004,7 @@ def accumulate_cursors(cursor: Cursor, all_cursors: list):
10041004
all_cursors = accumulate_cursors(child, all_cursors)
10051005
return all_cursors
10061006

1007-
tu = get_tu(children_test)
1007+
tu = get_tu(CHILDREN_TEST)
10081008
all_cursors = accumulate_cursors(tu.cursor, [])
10091009
cursor_hashes = set()
10101010
for cursor in all_cursors:
@@ -1028,7 +1028,7 @@ def test_has_attrs(self):
10281028
self.assertFalse(B.get_definition().has_attrs())
10291029

10301030
def test_specialized_template(self):
1031-
tu = get_tu(template_arg_test, lang="cpp")
1031+
tu = get_tu(TEMPLATE_ARG_TEST, lang="cpp")
10321032
foos = get_cursors(tu, "foo")
10331033
prime_foo = foos[1].specialized_template
10341034

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import unittest
99

10-
inputs_dir = os.path.join(os.path.dirname(__file__), "INPUTS")
10+
INPUTS_DIR = os.path.join(os.path.dirname(__file__), "INPUTS")
1111

1212

1313
class TestIndex(unittest.TestCase):
@@ -19,7 +19,7 @@ def test_create(self):
1919
def test_parse(self):
2020
index = Index.create()
2121
self.assertIsInstance(index, Index)
22-
tu = index.parse(os.path.join(inputs_dir, "hello.cpp"))
22+
tu = index.parse(os.path.join(INPUTS_DIR, "hello.cpp"))
2323
self.assertIsInstance(tu, TranslationUnit)
24-
tu = index.parse(None, ["-c", os.path.join(inputs_dir, "hello.cpp")])
24+
tu = index.parse(None, ["-c", os.path.join(INPUTS_DIR, "hello.cpp")])
2525
self.assertIsInstance(tu, TranslationUnit)

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from .util import get_cursor, get_tu
1818

19-
base_input = "int one;\nint two;\n"
19+
BASE_INPUT = "int one;\nint two;\n"
2020

2121

2222
class TestLocation(unittest.TestCase):
@@ -26,7 +26,7 @@ def assert_location(self, loc, line, column, offset):
2626
self.assertEqual(loc.offset, offset)
2727

2828
def test_location(self):
29-
tu = get_tu(base_input)
29+
tu = get_tu(BASE_INPUT)
3030
one = get_cursor(tu, "one")
3131
two = get_cursor(tu, "two")
3232

@@ -37,7 +37,7 @@ def test_location(self):
3737
self.assert_location(two.location, line=2, column=5, offset=13)
3838

3939
# adding a linebreak at top should keep columns same
40-
tu = get_tu("\n" + base_input)
40+
tu = get_tu("\n" + BASE_INPUT)
4141
one = get_cursor(tu, "one")
4242
two = get_cursor(tu, "two")
4343

@@ -48,7 +48,7 @@ def test_location(self):
4848
self.assert_location(two.location, line=3, column=5, offset=14)
4949

5050
# adding a space should affect column on first line only
51-
tu = get_tu(" " + base_input)
51+
tu = get_tu(" " + BASE_INPUT)
5252
one = get_cursor(tu, "one")
5353
two = get_cursor(tu, "two")
5454

@@ -57,7 +57,7 @@ def test_location(self):
5757

5858
# define the expected location ourselves and see if it matches
5959
# the returned location
60-
tu = get_tu(base_input)
60+
tu = get_tu(BASE_INPUT)
6161

6262
file = File.from_name(tu, "t.c")
6363
location = SourceLocation.from_position(tu, file, 1, 5)
@@ -83,20 +83,20 @@ def test_location(self):
8383
self.assertTrue(verified)
8484

8585
def test_extent(self):
86-
tu = get_tu(base_input)
86+
tu = get_tu(BASE_INPUT)
8787
one = get_cursor(tu, "one")
8888
two = get_cursor(tu, "two")
8989

9090
self.assert_location(one.extent.start, line=1, column=1, offset=0)
9191
self.assert_location(one.extent.end, line=1, column=8, offset=7)
9292
self.assertEqual(
93-
base_input[one.extent.start.offset : one.extent.end.offset], "int one"
93+
BASE_INPUT[one.extent.start.offset : one.extent.end.offset], "int one"
9494
)
9595

9696
self.assert_location(two.extent.start, line=2, column=1, offset=9)
9797
self.assert_location(two.extent.end, line=2, column=8, offset=16)
9898
self.assertEqual(
99-
base_input[two.extent.start.offset : two.extent.end.offset], "int two"
99+
BASE_INPUT[two.extent.start.offset : two.extent.end.offset], "int two"
100100
)
101101

102102
file = File.from_name(tu, "t.c")

0 commit comments

Comments
 (0)