summaryrefslogtreecommitdiff
path: root/clang/bindings
AgeCommit message (Collapse)Author
2019-01-05[python] Make the collections import future-proofSerge Guelton
On Python 3.7 the old code raises a warning: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working class ArgumentsIterator(collections.Sequence): On Python 3.8 it wouldn't work anymore. Commited on behalf of Jakub Stasiak. Differential Revision: https://reviews.llvm.org/D56341
2019-01-03Make -Wstring-plus-int warns even if when the result is not out of boundsArnaud Bienner
Summary: Patch by Arnaud Bienner Reviewers: sylvestre.ledru, thakis, serge-sans-paille Reviewed By: thakis Subscribers: arphaman, dyung, anemet, llvm-commits, cfe-commits Differential Revision: https://reviews.llvm.org/D55382
2019-01-03Portable Python script across Python versionSerge Guelton
StringIO is obsoleted in Python3, replaced by io.BytesIO or io.StringIO depending on the use. Differential Revision: https://reviews.llvm.org/D55196
2018-12-18Portable Python script across Python versionSerge Guelton
Make scripts more future-proof by importing most __future__ stuff. Differential Revision: https://reviews.llvm.org/D55208
2018-12-18Portable Python script across Python versionSerge Guelton
In Python3, dict.items, dict.keys, dict.values, zip, map and filter no longer return lists, they create generator instead. The portability patch consists in forcing an extra `list` call if the result is actually used as a list. `map` are replaced by list comprehension and `filter` by filtered list comprehension. Differential Revision: https://reviews.llvm.org/D55197
2018-12-18Portable Python script across Python versionSerge Guelton
Using from __future__ import print_function it is possible to have a compatible behavior of `print(...)` across Python version. Differential Revision: https://reviews.llvm.org/D55213
2018-12-18Portable Python script across Python versionSerge Guelton
Replace `xrange(...)` by either `range(...)` or `list(range(...))` depending on the context. Differential Revision: https://reviews.llvm.org/D55193
2018-12-14Revert "Try to update the test to fix the breakage With the new warning, we ↵Adam Nemet
are showing one more output in the test." This reverts commit r349064. This wasn't updating the right test. Causing (not the different line number from the previous revert): ====================================================================== FAIL: test_diagnostic_warning (tests.cindex.test_diagnostics.TestDiagnostics) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/buildslave/jenkins/workspace/clang-stage1-configure-RA/llvm/tools/clang/bindings/python/tests/cindex/test_diagnostics.py", line 18, in test_diagnostic_warning self.assertEqual(len(tu.diagnostics), 2) AssertionError: 1 != 2
2018-12-13Try to update the test to fix the breakageSylvestre Ledru
With the new warning, we are showing one more output in the test.
2018-12-03Portable Python script across versionSerge Guelton
Have all classes derive from object: that's implicitly the default in Python3, it needs to be done explicilty in Python2. Differential Revision: https://reviews.llvm.org/D55121
2018-11-10[python] Support PathLike filenames and directoriesMichal Gorny
Python 3.6 introduced a file system path protocol (PEP 519[1]). The standard library APIs accepting file system paths now accept path objects too. It could be useful to add this here as well for convenience. [1] https://www.python.org/dev/peps/pep-0519 Authored by: jstasiak (Jakub Stasiak) Differential Revision: https://reviews.llvm.org/D54120
2018-10-18Add check-clang-python to the Clang tests directory in IDEs; NFC.Aaron Ballman
2018-10-17[python] [tests] Disable on known-broken archesMichal Gorny
Disable the Python binding tests on AArch64, Hexagon and SystemZ following reports on test failures. The first two yield different results, possibly indicating test case problems. The last one seems to have broken FFI in Python. While at it, refactor the code to make adding future test restrictions easier. Differential Revision: https://reviews.llvm.org/D53326
2018-10-15[python] [tests] Disable python binding tests under LLVM_USE_SANITIZER=AddressArtem Dergachev
They don't work yet. Patch by Dan Liew! rdar://problem/45242886 Differential Revision: https://reviews.llvm.org/D53239
2018-10-12[python] [tests] Re-add once again, this time without WindowsMichal Gorny
2018-10-12Revert rL344365: [tests] Readd Python binding tests to check-allSimon Pilgrim
Windows buildbots are still not happy Now that both issues found out during the last iteration have been fixed, reenable the Python binding tests on buildbots. ........
2018-10-12[tests] Readd Python binding tests to check-allMichal Gorny
Now that both issues found out during the last iteration have been fixed, reenable the Python binding tests on buildbots.
2018-10-12[python] [tests] Remove cdb lookup failure testMichal Gorny
Remove the test checking for compilation db lookup failure. Since r342228, JSONCompilationDatabasePlugin infers compile commands for missing files, therefore making the lookup always succeed. Differential Revision: https://reviews.llvm.org/D53202
2018-10-11[python] [tests] Fix calling tests on WindowsMichal Gorny
Fix passing arguments to the Python test command to use 'env' builtin CMake command, in order to fix compatibility with Windows. Differential Revision: https://reviews.llvm.org/D53151
2018-10-11[python] [tests] Retab CMakeLists.txt for consistency (NFC)Michal Gorny
2018-10-11[tests] Remove Python tests from check-all due to breakageMichal Gorny
Remove the Python tests from default target in order to fix two kinds of breakage uncovered by enabling them: one failing test on Linux, and problem with the test command on Windows. Both to be addressed in followup revisions.
2018-10-11[tests] Include Python binding tests in CMake rulesMichal Gorny
Add a new CMake rule check-clang-python to run the Python bindings' test suite, and include it in check-all. Differential Revision: https://reviews.llvm.org/D52840
2018-10-11Revert r344241 as it broke multiple bots.Aaron Ballman
http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/10814 http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/20613
2018-10-11[tests] Include Python binding tests in CMake rulesMichal Gorny
Add a new CMake rule check-clang-python to run the Python bindings' test suite, and include it in check-all. Differential Revision: https://reviews.llvm.org/D52840
2018-10-11[python] [tests] Support overriding library path via environmentMichal Gorny
Support a new CLANG_LIBRARY_PATH environment variable for the Python binding tests. This variable can be used to force the bindings to load libclang.* from a specific directory. I plan to use this when integrating Python binding tests with the CMake build system. Currently, those tests load libclang.so from default search paths, so I would have to rely on platform-specific mechanics such as LD_LIBRARY_PATH. Instead of copying the whole logic necessary to handle platform differences into yet another place, it's easier to just add a dedicated variable for this purpose. Differential Revision: https://reviews.llvm.org/D52806
2018-09-24[python] [tests] Update test_code_completionMichal Gorny
Update expected completions to match output generated by clang-7.0. Differential Revision: https://reviews.llvm.org/D50171
2018-09-11[python bindings] Expose getNumTemplateArgumentsJonathan Coe
Expose the C bindings for clang_Type_getNumTemplateArguments() and clang_Type_getTemplateArgumentAsType() in the python API. Patch by kjteske (Kyle Teske). Reviewed By: jbcoe Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51299
2018-06-21[bindings] Fix most Python binding unittests on WindowsJonathan Coe
Summary: This fixes all but one of the test cases for Windows. TestCDB will take more work to debug, as CompilationDatabase seems not to work correctly. Reviewers: bkramer, wanders, jbcoe Reviewed By: bkramer, jbcoe Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D47864 Patch written by ethanhs (Ethan)
2018-05-10implementing Cursor.get_included_file in python bindingsJonathan Coe
Summary: adding function: `Cursor.get_included_file` , so the C API's `clang_getIncludedFile` function is available on the python binding interface also adding test to unittests related ticket: https://bugs.llvm.org/show_bug.cgi?id=15223 Reviewers: mgorny, arphaman, jbcoe Reviewed By: jbcoe Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D46383 Patch by jlaz (József Láz)
2018-04-22[python bindings] Fix Cursor.result_type for ObjC method declarations - Bug ↵Jonathan Coe
36677 Summary: In cindex.py, Cursor.result_type called into the wrong libclang function, causing cursors for ObjC method declarations to return invalid result types. Fixes Bug 36677. Reviewers: jbcoe, rsmith Reviewed By: jbcoe Subscribers: cfe-commits, llvm-commits Differential Revision: https://reviews.llvm.org/D45671 Patch by kjteske (Kyle Teske).
2018-04-06Fix typos in clangAlexander Kornienko
Found via codespell -q 3 -I ../clang-whitelist.txt Where whitelist consists of: archtype cas classs checkk compres definit frome iff inteval ith lod methode nd optin ot pres statics te thru Patch by luzpaz! (This is a subset of D44188 that applies cleanly with a few files that have dubious fixes reverted.) Differential revision: https://reviews.llvm.org/D44188
2017-12-14Remove duplicate python libclang changes from r320748Alex Lorenz
2017-12-14[libclang] Add support for checking abstractness of recordsAlex Lorenz
This patch allows checking whether a C++ record declaration is abstract through libclang and clang.cindex (Python). Patch by Johann Klähn! Differential Revision: https://reviews.llvm.org/D36952
2017-11-11[python] [tests] Fix test_linkage for unique external linkageMichal Gorny
Starting with r314037, anonymous namespaces no longer give unique-external linkage to variables. However, this linkage can still be achieved by using a type which is not exterally visible, e.g. through being declared in an anonymous namespace but used outside it. Fix the test to take advantage of that. Differential Revision: https://reviews.llvm.org/D39810
2017-11-10[python] [tests] Rewrite to use standard unittest moduleMichal Gorny
Rewrite the tests from using plain 'assert' mixed with some nosetests methods to the standard unittest module layout. Improve the code to use the most canonical assertion methods whenever possible. This has a few major advantages: - the code uses standard methods now, resulting in a reduced number of WTFs whenever someone with basic Python knowledge gets to read it, - completely unnecessary dependency on nosetests is removed since the standard library supplies all that is necessary for the tests to run, - the tests can be run via any test runner, including the one built-in in Python, - the failure output for most of the tests is improved from 'assertion x == y failed' to actually telling the values. Differential Revision: https://reviews.llvm.org/D39763
2017-11-09[python] [tests] Update priority values in code completion testMichal Gorny
The priority for destructors and operators was reduced in r314019. Adjust the values used in the test appropriately to fix the test failure. Differential Revision: https://reviews.llvm.org/D39838
2017-11-08[bindings] fix TLS test failureMasud Rahman
Since cfe commit r237337, '__declspec(thread)' and 'thread_local' have been the same since MSVC 2015. i.e. they are both considered to supply a dynamic TLS kind, not a static TLS kind. This test originally did not specify which version of MS compatibility to assume. As a result, the test was brittle, since changing the default compatibility version could break the test. This commit adds a specific version when building up the flags used to parse the translation unit, and tests both versions.
2017-10-21Reverting r316278 due to failing build bots.Aaron Ballman
http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/11896 http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/12380
2017-10-21[libclang, bindings]: add spelling locationMasud Rahman
o) Add a 'Location' class that represents the four properties of a physical location o) Enhance 'SourceLocation' to provide 'expansion' and 'spelling' locations, maintaining backwards compatibility with existing code by forwarding the four properties to 'expansion'. o) Update the implementation to use 'clang_getExpansionLocation' instead of the deprecated 'clang_getInstantiationLocation', which has been present since 2011. o) Update the implementation of 'clang_getSpellingLocation' to actually obtain spelling location instead of file location.
2017-10-21[bindings] allow null strings in Python 3Masud Rahman
Some API calls accept 'NULL' instead of a char array (e.g. the second argument to 'clang_ParseTranslationUnit'). For Python 3 compatibility, all strings are passed through 'c_interop_string' which expects to receive only 'bytes' or 'str' objects. This change extends this behavior to additionally allow 'None' to be supplied. A test case was added which breaks in Python 3, and is fixed by this change. All the test cases pass in both, Python 2 and Python 3.
2017-10-16[libclang] Add support for querying cursor availabilityJonathan Coe
Summary: This patch allows checking the availability of cursors through libclang and clang.cindex (Python). This e.g. allows to check whether a C++ member function has been marked as deleted. Reviewers: arphaman, jbcoe Reviewed By: jbcoe Subscribers: cfe-commits Tags: #clang Patch by jklaehn (Johann Klähn) Differential Revision: https://reviews.llvm.org/D36973
2017-10-16[libclang] Visit attributes for function and class templatesJonathan Coe
Summary: Previously, `VisitAttributes` was not called for function and class templates and thus their attributes were not accessible using libclang. Reviewers: bkramer, arphaman, rsmith, jbcoe Reviewed By: jbcoe Subscribers: cfe-commits Tags: #clang Patch by jklaehn (Johann Klähn) Differential Revision: https://reviews.llvm.org/D36955
2017-09-22bindings: expose Linkage to the python bindingsSaleem Abdulrasool
Add Python bindings for the 'clang_getCursorLinkage', and tests to validate the functionality. Patch by Masud Rahman!
2017-09-21[libclang] Keep track of TranslationUnit instance when annotating tokensJonathan Coe
Summary: Previously the `_tu` was not propagated to the returned cursor, leading to errors when calling any method on that cursor (e.g. `cursor.referenced`). Reviewers: jbcoe, rsmith Reviewed By: jbcoe Subscribers: cfe-commits Tags: #clang Patch by jklaehn (Johann Klähn) Differential Revision: https://reviews.llvm.org/D36953
2017-09-13libclang: expose `clang_getCursorTLSKind`Saleem Abdulrasool
Introduce the 'TLS Kind' property of variable declarations through libclang. Additionally, provide a Python accessor for it, and test that functionality. Patch by Masud Rahman!
2017-09-06Fix __repr__ for Diagnostic in clang.cindexJonathan Coe
Summary: Also move misplaced tests for exception specification to fix failing Python tests. Reviewers: hans, compnerd Reviewed By: compnerd Subscribers: cfe-commits Tags: #clang-c Differential Revision: https://reviews.llvm.org/D37490
2017-07-12[libclang] Support for querying whether an enum is scopedAlex Lorenz
This commit allows checking whether an enum declaration is scoped through libclang and clang.cindex (Python). Patch by Johann Klähn! Differential Revision: https://reviews.llvm.org/D35187
2017-07-12Revert r307769 (Forgot to mention the name of the contributor).Alex Lorenz
2017-07-12[libclang] Support for querying whether an enum is scopedAlex Lorenz
This commit allows checking whether an enum declaration is scoped through libclang and clang.cindex (Python). Differential Revision: https://reviews.llvm.org/D35187
2017-07-03fix trivial typos in comments; NFCHiroshi Inoue