Commit Graph

218 Commits

Author SHA1 Message Date
Saleem Abdulrasool 25eb54f789 bindings: expose Linkage to the python bindings
Add Python bindings for the 'clang_getCursorLinkage', and tests to
validate the functionality.

Patch by Masud Rahman!

llvm-svn: 314009
2017-09-22 18:35:09 +00:00
Jonathan Coe 1a28f2a002 [libclang] Keep track of TranslationUnit instance when annotating tokens
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

llvm-svn: 313913
2017-09-21 20:48:43 +00:00
Saleem Abdulrasool 50bc565f3f libclang: expose `clang_getCursorTLSKind`
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!

llvm-svn: 313111
2017-09-13 02:15:09 +00:00
Jonathan Coe f3ecda6057 Fix __repr__ for Diagnostic in clang.cindex
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

llvm-svn: 312622
2017-09-06 07:33:32 +00:00
Alex Lorenz ff7f42e61a [libclang] Support for querying whether an enum is scoped
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

llvm-svn: 307771
2017-07-12 11:35:11 +00:00
Alex Lorenz 4fabc97c43 Revert r307769 (Forgot to mention the name of the contributor).
llvm-svn: 307770
2017-07-12 11:34:14 +00:00
Alex Lorenz 571b8cfac9 [libclang] Support for querying whether an enum is scoped
This commit allows checking whether an enum declaration is scoped
through libclang and clang.cindex (Python).

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

llvm-svn: 307769
2017-07-12 11:31:37 +00:00
Hiroshi Inoue c5e54ddab3 fix trivial typos in comments; NFC
llvm-svn: 307007
2017-07-03 08:49:44 +00:00
Jonathan Coe 0a5b03b659 [libclang] Support for querying the exception specification type through libclang
Summary: This patch exposes the exception specification type (noexcept,
etc.) of a C++ function through libclang and Python clang.cindex.

Reviewers: rsmith, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: jbcoe, cfe-commits

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

Patch by Andrew Bennieston

llvm-svn: 306483
2017-06-27 22:54:56 +00:00
Sven van Haastregt e891042105 [libclang] Expose typedef and address space functions
Expose the following functions:
 - clang_getTypedefName
 - clang_getAddressSpace

Patch by Simon Perretta.

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

llvm-svn: 304978
2017-06-08 14:22:04 +00:00
Sven van Haastregt cc4f1e49af [libclang] [OpenCL] Expose more OpenCL CIndex types
Expose pipe, sampler_t, clk_event_t, queue_t, reserve_id_t, and all
image types.

Update the opencl-types.cl test RUN line such that we can test the
OpenCL 2.0 types.

Patch by Simon Perretta.

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

llvm-svn: 303626
2017-05-23 10:36:43 +00:00
Jonathan Coe e93970c55d Add Python 3 support to clang.cindex
Summary:
Introduce an interop string to convert from unicode to c-strings where needed.
Add missing conversions from _CXString to strings in function registrations.
Explicitly evaluate lists where Python 3's lazy iterators would not otherwise do so.

This is an improvement upon the reverted change proposed in https://reviews.llvm.org/D26082

Reviewers: compnerd, skalinichev, modocache, MathieuDuponchelle

Reviewed By: compnerd

Subscribers: cfe-commits

Tags: #clang-c

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

llvm-svn: 300829
2017-04-20 10:11:01 +00:00
Joey Gouly 6ea21852af [libclang] [OpenCL] Expose half type.
Expose the half type (fp16) through libclang and the python bindings.

It seems CXType_LastBuiltin was not updated in b2ea6d9 ("Enable
support for __float128 in Clang", 2016-04-13), so update it now.

Add an Index test for OpenCL types; in the future we will add other
OpenCL types such as images to this test.

Patch by Sven van Haastregt.

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

llvm-svn: 294754
2017-02-10 15:51:11 +00:00
Jonathan Coe e02a3908cf Fix Python 3 language issues and add an explicit check for Python version == 2.
Summary:
Python bindings cannot support Python 3 without work being done to fix Unicode c-string conversion.

This was attempted in https://reviews.llvm.org/D26082. That patch was reverted due to memory access issues on Linux.

This revision fixes enough language compatibility issues for the clang module to be loaded and raise an error if the Python version is not 2.

Reviewers: mgorny, MathieuDuponchelle, rengolin, compnerd

Reviewed By: compnerd

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

llvm-svn: 292247
2017-01-17 20:03:54 +00:00
Jonathan Coe 435aaeefe9 Revert "Support for Python 3 in libclang python bindings"
This reverts commit 4464581bb63e9789e9ee231a8c8800be5f614743.

Memory access issues on Linux were reported by Mathieu Duponchelle and
discussed here: https://reviews.llvm.org/D26082.

llvm-svn: 291907
2017-01-13 16:06:59 +00:00
Sergey Kalinichev bbcf74f585 [libclang] Fix python tests
It was broken in r286421

llvm-svn: 288582
2016-12-03 12:53:06 +00:00
Olivier Goffart 7cbfe23ad4 [python bindings] Expose CXCursor_FriendDecl as CursorKind.FRIEND_DECL
CXCursor_FriendDecl was added in r285984

llvm-svn: 285986
2016-11-04 06:50:59 +00:00
Jonathan Coe dad22c7cf0 Support for Python 3 in libclang python bindings
Summary:
Python bindings tests now pass in Python 3.

`map` in Python 3 is lazily evaluated so the method by which functions are registered needed updating.

Strings are unicode in Python 3 not UTF-8, I've tried to create an new c_types-like class (c_string_p) to automate the conversion.

String conversions made explicit where required.

Reviewers: eliben, nemanjai, skalinichev, compnerd

Subscribers: mgorny, cfe-commits

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

llvm-svn: 285909
2016-11-03 13:55:34 +00:00
Igor Kudrin 692f4e95cf [libclang] Add missing cursor kinds to python bindings.
Differential Revision: https://reviews.llvm.org/D25673

llvm-svn: 284464
2016-10-18 09:42:03 +00:00
Igor Kudrin a6ea95ad64 [libclang] Fix a failure in a test for python bindings on CursorKind.OVERLOAD_CANDIDATE.
The test fails because the value does not lay in any existing group.

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

llvm-svn: 284463
2016-10-18 09:30:33 +00:00
Saleem Abdulrasool ae0e635f60 bindings: expose diagnostic formatting to Python
This makes it easier for tools using the Python libclang bindings to display
diagnostics in a manner consistent with clang.

Patch by Omar Sandoval!

llvm-svn: 278315
2016-08-11 05:31:07 +00:00
Nemanja Ivanovic bb1ea2d613 Enable support for __float128 in Clang and enable it on pertinent platforms
This patch corresponds to reviews:
http://reviews.llvm.org/D15120
http://reviews.llvm.org/D19125

It adds support for the __float128 keyword, literals and target feature to
enable it. Based on the latter of the two aforementioned reviews, this feature
is enabled on Linux on i386/X86 as well as SystemZ.
This is also the second attempt in commiting this feature. The first attempt
did not enable it on required platforms which caused failures when compiling
type_traits with -std=gnu++11.

If you see failures with compiling this header on your platform after this
commit, it is likely that your platform needs to have this feature enabled.

llvm-svn: 268898
2016-05-09 08:52:33 +00:00
Sergey Kalinichev 69770aee36 [libclang] Expose the ElaboratedType
Differential Revision: http://reviews.llvm.org/D11797

llvm-svn: 268366
2016-05-03 06:58:29 +00:00
Saleem Abdulrasool acc98ca43c python: add bindings for children of diagnostics
This exposes the Clang API bindings clang_getChildDiagnostics (which returns a
CXDiagnosticSet) and clang_getNumDiagnosticsInSet / clang_getDiagnosticInSet (to
traverse the CXDiagnosticSet), and adds a helper children property in the Python
Diagnostic wrapper.

Also, this adds the missing OVERLOAD_CANDIDATE (700) cursor type.

Patch by Hanson Wang!

llvm-svn: 268167
2016-04-30 21:14:01 +00:00
Jonathan Coe 2956535b7c Expose cxx constructor and method properties through libclang and python bindings.
Summary:
I have exposed the following function through libclang and the clang.cindex python bindings:

clang_CXXConstructor_isConvertingConstructor,
clang_CXXConstructor_isCopyConstructor,
clang_CXXConstructor_isDefaultConstructor,
clang_CXXConstructor_isMoveConstructor,
clang_CXXMethod_isDefaulted

I need (some of) these methods for a C++ code model I am building in Python to drive a code generator.

Reviewers: compnerd, skalinichev

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D15469

llvm-svn: 267706
2016-04-27 12:48:25 +00:00
Nemanja Ivanovic d7d45bf8ce Revert 266186 as it breaks anything that includes type_traits on some platforms
Since this patch provided support for the __float128 type but disabled it
on all platforms by default, some platforms can't compile type_traits with
-std=gnu++11 since there is a specialization with __float128.
This reverts the patch until D19125 is approved (i.e. we know which platforms
need this support enabled).

llvm-svn: 266460
2016-04-15 18:04:13 +00:00
Nemanja Ivanovic 50f29e06a1 Enable support for __float128 in Clang
This patch corresponds to review:
http://reviews.llvm.org/D15120

It adds support for the __float128 keyword, literals and a target feature to
enable it. This support is disabled by default on all targets and any target
that has support for this type is free to add it.

Based on feedback that I've received from target maintainers, this appears to
be the right thing for most targets. I have not heard from the maintainers of
X86 which I believe supports this type. I will subsequently investigate the
impact of enabling this on X86.

llvm-svn: 266186
2016-04-13 09:49:45 +00:00
Jonathan Coe 02281b8419 libclang python bindings: Fix for bug 26394
Summary:
https://llvm.org/bugs/show_bug.cgi?id=26394 reports that clang's python bindings tests are failing.

I can confirm that the bug exists and that the proposed fix is good.

Differential Revision: http://reviews.llvm.org/D17226

llvm-svn: 263170
2016-03-10 23:29:45 +00:00
Guillaume Papin 06eff5f2c8 python binding: expose compile command filename
Reviewers: compnerd, skalinichev

Differential Revision: http://reviews.llvm.org/D17278

llvm-svn: 262845
2016-03-07 18:44:42 +00:00
Saleem Abdulrasool 8aa0b80ec7 libclang: expose dllexport, dllimport attributes
These attributes were previously unexposed.  Expose them through the libclang
interfaces.  Add tests that cover both the MSVC spelling and the GNU spelling.

llvm-svn: 255273
2015-12-10 18:45:18 +00:00
Sergey Kalinichev 8f3b187e21 [libclang] Visit TypeAliasTemplateDecl
This makes TypeAliasTemplateDecl accessible via LibClang and python bindings

Differential Revision: http://reviews.llvm.org/D13844

llvm-svn: 253166
2015-11-15 13:48:32 +00:00
Sergey Kalinichev c015120b53 [libclang] Expose AutoType
Expose the AutoType via LibClang and python bindings

Differential Revision: http://reviews.llvm.org/D13000

llvm-svn: 253165
2015-11-15 13:10:10 +00:00
Saleem Abdulrasool 6ea75dbeb0 Index: expose is_mutable_field
Expose isMutable via libClang and python bindings.

Patch by Jonathan B Coe!

llvm-svn: 251410
2015-10-27 15:50:22 +00:00
Saleem Abdulrasool d79eec97fc bindings: add new C++ function attribute accessors
Add methods to index Cursor to see if a cxx method is pure_virtual,
virtual or const methods.

Patch by Jonathan B Coe!

llvm-svn: 250008
2015-10-12 03:10:20 +00:00
Saleem Abdulrasool 79c6971cdf Index: expose visibility attribute
Expose the previously unexposed visibility attribute via the python and C
bindings.

llvm-svn: 246931
2015-09-05 18:53:43 +00:00
Manuel Klimek e0495d987c [libclang] Return deduced type for auto type, not the one written in the source.
It used to work, but was accidentally broken by r179769.
The issue with decayed types was fixed by r190796.
So this patch partially reverts r179769, and adds more tests.

This also fixes PR 18669.

Patch by Sergey Kalinichev.

llvm-svn: 246778
2015-09-03 16:11:10 +00:00
Argyrios Kyrtzidis 2bff5161c4 [libclang] Add functions to get information about fields.
Patch by Loïc Jaquemet!

llvm-svn: 234762
2015-04-13 16:55:04 +00:00
Rafael Espindola 3c5f2354b8 This reverts commit r227432, r227438 and r227448.
It should bring the bots back.

Original messagses:

r227448:
   Remove unnecessary default.

r227438:
   Fix Index/print-type.cpp test following r227432.

r227432:
    libclang: Add three functions useful for dealing with anonymous fields:
       clang_Cursor_getOffsetOfField
       clang_Cursor_isAnonymous
       clang_Type_visitFields
    Python: Add corresponding methods for dealing with anonymous fields.

    Patch by Loïc Jaquemet

llvm-svn: 227472
2015-01-29 17:22:53 +00:00
Francois Pichet f3be1cc5a9 libclang: Add three functions useful for dealing with anonymous fields:
clang_Cursor_getOffsetOfField
   clang_Cursor_isAnonymous
   clang_Type_visitFields
Python: Add corresponding methods for dealing with anonymous fields.

Patch by Loïc Jaquemet

llvm-svn: 227432
2015-01-29 12:45:29 +00:00
Argyrios Kyrtzidis 4e0854f23c [libclang] Add function to retrieve storage class in libclang.
Patch by guibufolo!

llvm-svn: 219809
2014-10-15 17:05:31 +00:00
Eli Bendersky c27a0c490c Add libclang capabilities to retriete template arguments from specializations.
Includes Python bindings.

Reviewed in http://reviews.llvm.org/D5621
Patch by Rob Springer

llvm-svn: 219529
2014-10-10 20:01:05 +00:00
Eli Bendersky 9b07147fc9 Expose the CUDA shared attribute to the C API.
Similar to r209767, which exposed other CUDA-related attributes.

Patch by Rob Springer.

llvm-svn: 215208
2014-08-08 14:59:00 +00:00
Eli Bendersky d28bc5e2f2 Expose the name mangling C API to Python bindings.
llvm-svn: 214930
2014-08-05 22:27:50 +00:00
Eli Bendersky e4f02eceea Reformat docstring to 80-col
llvm-svn: 214412
2014-07-31 18:12:17 +00:00
Alp Toker 1a923b42cb cindex.py: remove obsolete workaround and FIXME
clang_getCursorSpelling() doesn't assert on non-declarations any more and the
behaviour is covered by c-index tests.

Passes nosetests.

llvm-svn: 211482
2014-06-22 23:28:54 +00:00
Eli Bendersky 086e5816b0 Implement a convenience recursive walk method over a cursor and its descendants.
Before r160106 there was a way to recursively visit all descendants of a cursor
via Cursor_visit, but it was removed. Since then, every user needs to
reimplement the recursive descent into get_children.

Adding a walk_preorder() method to Cursor that conveniently implements recursive
walking in a Pythonic way. This also greatly simplifies get_cursor and
get_cursors in tests/cindex/util.py (walk_preorder is now tested through these
utility functions, since they are used in many tests).

llvm-svn: 209793
2014-05-29 02:35:27 +00:00
Eli Bendersky 2581e66e7a Expose CUDA function attributes to the C interface.
Until now all CUDA-specific attributes were represented with
CXCursor_UnexposedAttr; now they are actually implemented, including the Python
bindings.

llvm-svn: 209767
2014-05-28 19:29:58 +00:00
Eli Bendersky d31b5963ff Trim trailing whitespace in cindex.py
llvm-svn: 209754
2014-05-28 17:35:14 +00:00
Alp Toker ab54f46eec cindex/test_cursor.py: no need to skip implicit decls in tests
clang was fixed some time ago to always skip "builtins and other cruft" so
tools no longer need hacks like this.

Passes nosetests.

llvm-svn: 209316
2014-05-21 19:17:38 +00:00
Eric Christopher c9e2a68905 Clean up language and grammar.
Based on a patch by jfcaron3@gmail.com!
PR19806

llvm-svn: 209215
2014-05-20 17:10:39 +00:00