Commit Graph

285 Commits

Author SHA1 Message Date
Nick Desaulniers 05d74dbc3b python bindings: fix DeprecationWarning
Fixes observed warning running `ninja check-all`:
llvm-project/clang/bindings/python/tests/cindex/test_diagnostics.py💯
DeprecationWarning: Please use assertRegex instead.
  self.assertRegexpMatches(children[0].spelling

Looks like unittest.assertRegexpMatches has been deprecated in favor of
unittest.assertRegex since Python 3.2, according to:
https://docs.python.org/3/library/unittest.html#deprecated-aliases

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D85692
2020-08-10 15:25:23 -07:00
Saleem Abdulrasool 216833b32b Revert "Temporarily revert "build: use `find_package(Python3)` if available""
This reverts commit 35edd704e0.

Revert the revert and extend the patch further to account for the use of
the `PYTHONINTERP_FOUND`.
2020-04-29 01:38:08 +00:00
Eric Christopher 35edd704e0 Temporarily revert "build: use `find_package(Python3)` if available"
as it seems to be causing multiple people problems with running tests
and building.

This reverts commit c4c3883b00.
2020-04-28 16:41:22 -07:00
Saleem Abdulrasool c4c3883b00 build: use `find_package(Python3)` if available
This is primarily motivated by the desire to move from Python2 to
Python3.  `PYTHON_EXECUTABLE` is ambiguous.  This explicitly identifies
the python interpreter in use.  Since the LLVM build seems to be able to
completed successfully with python3, use that across the build.  The old
path aliases `PYTHON_EXECUTABLE` to be treated as Python3.
2020-04-28 09:24:27 -07:00
Saleem Abdulrasool be884b7935 Revert "build: use `find_package(Python3)` if available"
This reverts commit cd84bfb814.  Although
this passed the CI in phabricator, some of the bots are missing python3
packages, revert it temporarily.
2020-04-27 20:03:32 -07:00
Saleem Abdulrasool cd84bfb814 build: use `find_package(Python3)` if available
This is primarily motivated by the desire to move from Python2 to
Python3.  `PYTHON_EXECUTABLE` is ambiguous.  This explicitly identifies
the python interpreter in use.  Since the LLVM build seems to be able to
completed successfully with python3, use that across the build.  The old
path aliases `PYTHON_EXECUTABLE` to be treated as Python3.
2020-04-28 01:33:10 +00:00
Benjamin Kramer ccc43e337c Expose ATOMIC in the clang python bindings
Following 38ca7b11db
2020-04-16 23:35:55 +02:00
Aaron Ballman 66c0162771 Hopefully fixing a failing build bot.
Should fix the changes from 260b91f379.
2020-02-18 11:39:23 -05:00
Mark de Wever be1a9b3863 [Wdocumentation] Implement \anchor
Differential revision: https://reviews.llvm.org/D69223
2019-12-21 14:52:21 +01:00
David Tenty a38fc61648 [AIX] Disable clang python binding tests
Summary:
The Python ctypes FFI interface is broken on AIX, it cannot properly pass
structures containing  arrays ( https://bugs.python.org/issue38628). So
disable the clang python binding tests on AIX till this is resolved.

Reviewers: stevewan, jasonliu, hubert.reinterpretcast, mgorny

Reviewed By: jasonliu, hubert.reinterpretcast

Subscribers: mgorny, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D70675
2019-11-26 15:30:38 -05:00
Dávid Bolvanský 5c50109bb5 Fixed more -Wreturn-type tests 2019-11-09 18:13:51 +01:00
Mark Murray 8a12e40185 [TestCommit] Trivial change to test commit access.
llvm-svn: 372307
2019-09-19 09:24:42 +00:00
Mark Murray 5e7c76aa38 [TestCommit] Trivial change to test commit access.
llvm-svn: 372306
2019-09-19 09:02:12 +00:00
Kadir Cetinkaya c3a7302397 [clang][Tooling] Infer target and mode from argv[0] when using JSONCompilationDatabase
Summary:
Wraps JSON compilation database with a target and mode adding database
wrapper. So that driver can correctly figure out which toolchain to use.

Note that clients that wants to make use of this target discovery mechanism
needs to link in TargetsInfos and initialize them at startup.

Reviewers: ilya-biryukov

Subscribers: mgorny, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D63755

llvm-svn: 364386
2019-06-26 07:39:03 +00:00
Ilya Biryukov 209b138079 [CodeComplete] Update python tests after r360042
llvm-svn: 360048
2019-05-06 14:56:24 +00:00
Sven van Haastregt c9945cca03 [libclang] Expose ext_vector_type
Differential Revision: https://reviews.llvm.org/D60775

llvm-svn: 358566
2019-04-17 09:08:50 +00:00
Rainer Orth 04ee339ada [python, tests] Disable Clang Python tests on SPARC
Running `make check-all` fails on Solaris 11/SPARC since the clang python
tests FAIL:

  ............................
  ======================================================================
  FAIL: test_extent (tests.cindex.test_location.TestLocation)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "tests/cindex/test_location.py", line 87, in test_extent
      self.assert_location(one.extent.start,line=1,column=1,offset=0)
    File "tests/cindex/test_location.py", line 22, in assert_location
      self.assertEqual(loc.column, column)
  AssertionError: 5 != 1
  
  ======================================================================
  FAIL: test_get_children (tests.cindex.test_cursor.TestCursor)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "tests/cindex/test_cursor.py", line 70, in test_get_children
      self.assertEqual(tu_nodes[0].is_definition(), True)
  AssertionError: False != True
  
  ----------------------------------------------------------------------
  Ran 126 tests in 2.123s
  
  FAILED (failures=2, skipped=6)
  
Unfortunately, this aborts the rest of `make check-all`, even with `-k`, so
this patch disables the test as is already done on a couple of other
targets.
  
This allowed the `sparc-sun-solaris2.11` test to finish.

Differential Revision: https://reviews.llvm.org/D60046

llvm-svn: 357917
2019-04-08 15:01:06 +00:00
Fangrui Song 2374bff376 [libclang][test] Suppress annoying 'LIBCLANG TOOLING ERROR' output
check-all invokes check-clang-python which prints the annoying message:

LIBCLANG TOOLING ERROR: fixed-compilation-database: Error while opening fixed database: No such file or directory
json-compilation-database: Error while opening JSON database: No such file or directory

Let's fix it now with os.dup os.dup2 trick.

llvm-svn: 357562
2019-04-03 07:25:04 +00:00
Emilio Cobos Alvarez cd74127d28 [libclang] Expose aligned() attribute.
Summary:
This is useful because otherwise there's no easy way to distinguish #pragma
packed(N) from attribute(packed, aligned(N)) that isn't looking at field
offsets (since pragma packed() also creates a packed attribute).

Reviewers: Anastasia, arphaman, serge-sans-paille

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D59299

llvm-svn: 356062
2019-03-13 16:16:54 +00:00
Emilio Cobos Alvarez 0a3fe502e6 [libclang] Expose warn_unused and warn_unused_result attributes.
This is helpful to properly detect them, and fixing issues like
https://github.com/rust-lang/rust-bindgen/issues/1518.

Differential Revision: https://reviews.llvm.org/D58570

llvm-svn: 354824
2019-02-25 21:24:52 +00:00
Emilio Cobos Alvarez 76004da1c9 [libclang] Fix a trivial error introduced in D57946.
The value for CXCursor_ConvergentAttr is not 420. I'm not really sure how easy
it is to test this, and I'm not familiar with the python bindings, just noticed
the error while looking at D57946 to write D58570.

Differential Revision: https://reviews.llvm.org/D58571

llvm-svn: 354823
2019-02-25 21:15:34 +00:00
Sven van Haastregt dc2c93017f [libclang] Add attribute support for 'convergent'.
This bumps CINDEX_VERSION_MINOR up (to 51).

Patch by Hsin-Hsiao Lin.

Differential Revision: https://reviews.llvm.org/D57946

llvm-svn: 353690
2019-02-11 11:00:56 +00:00
Serge Guelton fa2e927c44 Fix python3 compability issue in clang binding
The file contents could be of str type. Should use byte length instead
of str length, otherwise utf-8 encoded files may not get properly parsed
for completion.

Source issue: https://github.com/ncm2/ncm2-pyclang#2

Commited on behalf of `roxma'

Differential Revision: https://reviews.llvm.org/D56429

llvm-svn: 352039
2019-01-24 10:34:44 +00:00
Chandler Carruth 2946cd7010 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636
2019-01-19 08:50:56 +00:00
Michal Gorny 851aec455b [test] Disable Python binding tests w/ LLVM_ENABLE_PIC=OFF
Disable Python binding tests when LLVM_ENABLE_PIC is disabled,
as libclang.so is not being built in that case.  Reported by Nico Weber.

Differential Revision: https://reviews.llvm.org/D56732

llvm-svn: 351304
2019-01-16 08:05:13 +00:00
Serge Guelton e8775ad169 [python] Make the collections import future-proof
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

llvm-svn: 350467
2019-01-05 12:07:36 +00:00
Arnaud Bienner 57fc9582f9 Make -Wstring-plus-int warns even if when the result is not out of bounds
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

llvm-svn: 350335
2019-01-03 17:45:28 +00:00
Serge Guelton f886c03e47 Portable Python script across Python version
StringIO is obsoleted in Python3, replaced by io.BytesIO or io.StringIO depending on the use.

Differential Revision: https://reviews.llvm.org/D55196

llvm-svn: 350318
2019-01-03 14:26:56 +00:00
Serge Guelton b748c0e696 Portable Python script across Python version
Make scripts more future-proof by importing most __future__ stuff.

Differential Revision: https://reviews.llvm.org/D55208

llvm-svn: 349504
2018-12-18 16:07:37 +00:00
Serge Guelton d458974c45 Portable Python script across Python version
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

llvm-svn: 349501
2018-12-18 16:04:21 +00:00
Serge Guelton c0ebe773cd Portable Python script across Python version
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

llvm-svn: 349454
2018-12-18 08:36:33 +00:00
Serge Guelton c5d97e3e35 Portable Python script across Python version
Replace `xrange(...)` by either `range(...)` or `list(range(...))` depending on the context.

Differential Revision: https://reviews.llvm.org/D55193

llvm-svn: 349448
2018-12-18 08:24:06 +00:00
Adam Nemet 4065da29f0 Revert "Try to update the test to fix the breakage With the new warning, we 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

llvm-svn: 349118
2018-12-14 00:43:36 +00:00
Sylvestre Ledru 8b325fc706 Try to update the test to fix the breakage
With the new warning, we are showing one more output in the test.

llvm-svn: 349064
2018-12-13 17:39:02 +00:00
Serge Guelton 09616bdb4a Portable Python script across version
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

llvm-svn: 348127
2018-12-03 12:12:48 +00:00
Michal Gorny 248cf96547 [python] Support PathLike filenames and directories
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

llvm-svn: 346586
2018-11-10 11:41:36 +00:00
Aaron Ballman f2965d1101 Add check-clang-python to the Clang tests directory in IDEs; NFC.
llvm-svn: 344750
2018-10-18 17:47:18 +00:00
Michal Gorny 0e75dc4188 [python] [tests] Disable on known-broken arches
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

llvm-svn: 344666
2018-10-17 03:05:39 +00:00
Artem Dergachev 38b21d91ff [python] [tests] Disable python binding tests under LLVM_USE_SANITIZER=Address
They don't work yet.

Patch by Dan Liew!

rdar://problem/45242886

Differential Revision: https://reviews.llvm.org/D53239

llvm-svn: 344537
2018-10-15 17:43:23 +00:00
Michal Gorny 22297d935a [python] [tests] Re-add once again, this time without Windows
llvm-svn: 344411
2018-10-12 20:03:54 +00:00
Simon Pilgrim 99e4d74e4a Revert rL344365: [tests] Readd Python binding tests to check-all
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.
........

llvm-svn: 344408
2018-10-12 19:46:40 +00:00
Michal Gorny e67b68f341 [tests] Readd Python binding tests to check-all
Now that both issues found out during the last iteration have been
fixed, reenable the Python binding tests on buildbots.

llvm-svn: 344365
2018-10-12 16:55:44 +00:00
Michal Gorny 4fc27bd937 [python] [tests] Remove cdb lookup failure test
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

llvm-svn: 344364
2018-10-12 16:55:39 +00:00
Michal Gorny d50a4310dc [python] [tests] Fix calling tests on Windows
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

llvm-svn: 344288
2018-10-11 20:26:55 +00:00
Michal Gorny cc8ea49d1f [python] [tests] Retab CMakeLists.txt for consistency (NFC)
llvm-svn: 344263
2018-10-11 17:45:35 +00:00
Michal Gorny 12e1df2f19 [tests] Remove Python tests from check-all due to breakage
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.

llvm-svn: 344260
2018-10-11 17:25:05 +00:00
Michal Gorny 61adf8aeb4 [tests] Include Python binding tests in CMake rules
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

llvm-svn: 344258
2018-10-11 16:32:54 +00:00
Aaron Ballman ec5932e88e Revert r344241 as it broke multiple bots.
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

llvm-svn: 344244
2018-10-11 12:57:29 +00:00
Michal Gorny cdd23f221d [tests] Include Python binding tests in CMake rules
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

llvm-svn: 344241
2018-10-11 11:58:14 +00:00
Michal Gorny c37d16140a [python] [tests] Support overriding library path via environment
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

llvm-svn: 344240
2018-10-11 11:58:07 +00:00