summaryrefslogtreecommitdiffstats
path: root/bindings/python
diff options
context:
space:
mode:
Diffstat (limited to 'bindings/python')
-rw-r--r--bindings/python/clang/__init__.py7
-rw-r--r--bindings/python/clang/cindex.py51
-rw-r--r--bindings/python/clang/enumerations.py7
-rw-r--r--bindings/python/examples/cindex/cindex-dump.py7
-rw-r--r--bindings/python/examples/cindex/cindex-includes.py7
-rw-r--r--bindings/python/tests/CMakeLists.txt4
-rw-r--r--bindings/python/tests/cindex/test_cdb.py9
-rw-r--r--bindings/python/tests/cindex/test_code_completion.py4
8 files changed, 49 insertions, 47 deletions
diff --git a/bindings/python/clang/__init__.py b/bindings/python/clang/__init__.py
index 88f3081238..14944b63e6 100644
--- a/bindings/python/clang/__init__.py
+++ b/bindings/python/clang/__init__.py
@@ -1,9 +1,8 @@
#===- __init__.py - Clang Python Bindings --------------------*- python -*--===#
#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#===------------------------------------------------------------------------===#
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py
index 8b23ae90b9..8e5a9fe006 100644
--- a/bindings/python/clang/cindex.py
+++ b/bindings/python/clang/cindex.py
@@ -1,9 +1,8 @@
#===- cindex.py - Python Indexing Library Bindings -----------*- python -*--===#
#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#===------------------------------------------------------------------------===#
@@ -1343,6 +1342,10 @@ CursorKind.VISIBILITY_ATTR = CursorKind(417)
CursorKind.DLLEXPORT_ATTR = CursorKind(418)
CursorKind.DLLIMPORT_ATTR = CursorKind(419)
+CursorKind.CONVERGENT_ATTR = CursorKind(438)
+CursorKind.WARN_UNUSED_ATTR = CursorKind(439)
+CursorKind.WARN_UNUSED_RESULT_ATTR = CursorKind(440)
+CursorKind.ALIGNED_ATTR = CursorKind(441)
###
# Preprocessing
@@ -2118,6 +2121,8 @@ TypeKind.OCLEVENT = TypeKind(158)
TypeKind.OCLQUEUE = TypeKind(159)
TypeKind.OCLRESERVEID = TypeKind(160)
+TypeKind.EXTVECTOR = TypeKind(176)
+
class RefQualifierKind(BaseEnumeration):
"""Describes a specific ref-qualifier of a type."""
@@ -2815,9 +2820,9 @@ class TranslationUnit(ClangObject):
for i, (name, contents) in enumerate(unsaved_files):
if hasattr(contents, "read"):
contents = contents.read()
-
+ contents = b(contents)
unsaved_array[i].name = b(fspath(name))
- unsaved_array[i].contents = b(contents)
+ unsaved_array[i].contents = contents
unsaved_array[i].length = len(contents)
ptr = conf.lib.clang_parseTranslationUnit(index,
@@ -2994,17 +2999,13 @@ class TranslationUnit(ClangObject):
unsaved_files_array = 0
if len(unsaved_files):
unsaved_files_array = (_CXUnsavedFile * len(unsaved_files))()
- for i,(name,value) in enumerate(unsaved_files):
- if not isinstance(value, str):
- # FIXME: It would be great to support an efficient version
- # of this, one day.
- value = value.read()
- print(value)
- if not isinstance(value, str):
- raise TypeError('Unexpected unsaved file contents.')
- unsaved_files_array[i].name = fspath(name)
- unsaved_files_array[i].contents = value
- unsaved_files_array[i].length = len(value)
+ for i,(name,contents) in enumerate(unsaved_files):
+ if hasattr(contents, "read"):
+ contents = contents.read()
+ contents = b(contents)
+ unsaved_files_array[i].name = b(fspath(name))
+ unsaved_files_array[i].contents = contents
+ unsaved_files_array[i].length = len(contents)
ptr = conf.lib.clang_reparseTranslationUnit(self, len(unsaved_files),
unsaved_files_array, options)
@@ -3058,17 +3059,13 @@ class TranslationUnit(ClangObject):
unsaved_files_array = 0
if len(unsaved_files):
unsaved_files_array = (_CXUnsavedFile * len(unsaved_files))()
- for i,(name,value) in enumerate(unsaved_files):
- if not isinstance(value, str):
- # FIXME: It would be great to support an efficient version
- # of this, one day.
- value = value.read()
- print(value)
- if not isinstance(value, str):
- raise TypeError('Unexpected unsaved file contents.')
+ for i,(name,contents) in enumerate(unsaved_files):
+ if hasattr(contents, "read"):
+ contents = contents.read()
+ contents = b(contents)
unsaved_files_array[i].name = b(fspath(name))
- unsaved_files_array[i].contents = b(value)
- unsaved_files_array[i].length = len(value)
+ unsaved_files_array[i].contents = contents
+ unsaved_files_array[i].length = len(contents)
ptr = conf.lib.clang_codeCompleteAt(self, fspath(path), line, column,
unsaved_files_array, len(unsaved_files), options)
if ptr:
diff --git a/bindings/python/clang/enumerations.py b/bindings/python/clang/enumerations.py
index a86a48ade3..520e1346d3 100644
--- a/bindings/python/clang/enumerations.py
+++ b/bindings/python/clang/enumerations.py
@@ -1,9 +1,8 @@
#===- enumerations.py - Python Enumerations ------------------*- python -*--===#
#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#===------------------------------------------------------------------------===#
diff --git a/bindings/python/examples/cindex/cindex-dump.py b/bindings/python/examples/cindex/cindex-dump.py
index acec7e0e00..46073b285c 100644
--- a/bindings/python/examples/cindex/cindex-dump.py
+++ b/bindings/python/examples/cindex/cindex-dump.py
@@ -2,10 +2,9 @@
#===- cindex-dump.py - cindex/Python Source Dump -------------*- python -*--===#
#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#===------------------------------------------------------------------------===#
diff --git a/bindings/python/examples/cindex/cindex-includes.py b/bindings/python/examples/cindex/cindex-includes.py
index 17500227a3..ec1fbc0c3e 100644
--- a/bindings/python/examples/cindex/cindex-includes.py
+++ b/bindings/python/examples/cindex/cindex-includes.py
@@ -2,10 +2,9 @@
#===- cindex-includes.py - cindex/Python Inclusion Graph -----*- python -*--===#
#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#===------------------------------------------------------------------------===#
diff --git a/bindings/python/tests/CMakeLists.txt b/bindings/python/tests/CMakeLists.txt
index 7af6503f15..3f5ac957f8 100644
--- a/bindings/python/tests/CMakeLists.txt
+++ b/bindings/python/tests/CMakeLists.txt
@@ -32,11 +32,11 @@ if(WIN32)
set(RUN_PYTHON_TESTS FALSE)
endif()
-# AArch64 and Hexagon have known test failures that need to be
+# AArch64, Hexagon, and Sparc have known test failures that need to be
# addressed.
# SystemZ has broken Python/FFI interface:
# https://reviews.llvm.org/D52840#1265716
-if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|SystemZ)$")
+if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|Sparc|SystemZ)$")
set(RUN_PYTHON_TESTS FALSE)
endif()
diff --git a/bindings/python/tests/cindex/test_cdb.py b/bindings/python/tests/cindex/test_cdb.py
index 589fc72856..e2a48f14cd 100644
--- a/bindings/python/tests/cindex/test_cdb.py
+++ b/bindings/python/tests/cindex/test_cdb.py
@@ -23,8 +23,17 @@ class TestCDB(unittest.TestCase):
def test_create_fail(self):
"""Check we fail loading a database with an assertion"""
path = os.path.dirname(__file__)
+
+ # clang_CompilationDatabase_fromDirectory calls fprintf(stderr, ...)
+ # Suppress its output.
+ stderr = os.dup(2)
+ with open(os.devnull, 'wb') as null:
+ os.dup2(null.fileno(), 2)
with self.assertRaises(CompilationDatabaseError) as cm:
cdb = CompilationDatabase.fromDirectory(path)
+ os.dup2(stderr, 2)
+ os.close(stderr)
+
e = cm.exception
self.assertEqual(e.cdb_error,
CompilationDatabaseError.ERROR_CANNOTLOADDATABASE)
diff --git a/bindings/python/tests/cindex/test_code_completion.py b/bindings/python/tests/cindex/test_code_completion.py
index e0b41577ae..1603d3dfc1 100644
--- a/bindings/python/tests/cindex/test_code_completion.py
+++ b/bindings/python/tests/cindex/test_code_completion.py
@@ -41,7 +41,7 @@ void f() {
expected = [
"{'int', ResultType} | {'test1', TypedText} || Priority: 50 || Availability: Available || Brief comment: Aaa.",
"{'void', ResultType} | {'test2', TypedText} | {'(', LeftParen} | {')', RightParen} || Priority: 50 || Availability: Available || Brief comment: Bbb.",
- "{'return', TypedText} || Priority: 40 || Availability: Available || Brief comment: None"
+ "{'return', TypedText} | {';', SemiColon} || Priority: 40 || Availability: Available || Brief comment: None"
]
self.check_completion_results(cr, expected)
@@ -67,7 +67,7 @@ void f() {
expected = [
"{'int', ResultType} | {'test1', TypedText} || Priority: 50 || Availability: Available || Brief comment: Aaa.",
"{'void', ResultType} | {'test2', TypedText} | {'(', LeftParen} | {')', RightParen} || Priority: 50 || Availability: Available || Brief comment: Bbb.",
- "{'return', TypedText} || Priority: 40 || Availability: Available || Brief comment: None"
+ "{'return', TypedText} | {';', SemiColon} || Priority: 40 || Availability: Available || Brief comment: None"
]
self.check_completion_results(cr, expected)