diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2015-10-27 15:50:22 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2015-10-27 15:50:22 +0000 |
commit | 08e335a6480652848ff006cdd0534f26307803b7 (patch) | |
tree | b4ecd45a4ee73f8d8ab3b0dff9ddf001920f973b /bindings | |
parent | f0ecf646e05ea51f0c2d7603700d24f6bb214c8f (diff) |
Index: expose is_mutable_field
Expose isMutable via libClang and python bindings.
Patch by Jonathan B Coe!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251410 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings')
-rw-r--r-- | bindings/python/clang/cindex.py | 10 | ||||
-rw-r--r-- | bindings/python/tests/cindex/test_cursor.py | 15 |
2 files changed, 25 insertions, 0 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py index 62b8596dea..49b2fd873f 100644 --- a/bindings/python/clang/cindex.py +++ b/bindings/python/clang/cindex.py @@ -1170,6 +1170,12 @@ class Cursor(Structure): """ return conf.lib.clang_CXXMethod_isConst(self) + def is_mutable_field(self): + """Returns True if the cursor refers to a C++ field that is declared + 'mutable'. + """ + return conf.lib.clang_CXXField_isMutable(self) + def is_pure_virtual_method(self): """Returns True if the cursor refers to a C++ member function or member function template that is declared pure virtual. @@ -2897,6 +2903,10 @@ functionList = [ [Index, c_char_p], c_object_p), + ("clang_CXXField_isMutable", + [Cursor], + bool), + ("clang_CXXMethod_isConst", [Cursor], bool), diff --git a/bindings/python/tests/cindex/test_cursor.py b/bindings/python/tests/cindex/test_cursor.py index 68fc8fa4ac..c5ea50516a 100644 --- a/bindings/python/tests/cindex/test_cursor.py +++ b/bindings/python/tests/cindex/test_cursor.py @@ -112,6 +112,21 @@ def test_is_const_method(): assert foo.is_const_method() assert not bar.is_const_method() +def test_is_mutable_field(): + """Ensure Cursor.is_mutable_field works.""" + source = 'class X { int x_; mutable int y_; };' + tu = get_tu(source, lang='cpp') + + cls = get_cursor(tu, 'X') + x_ = get_cursor(tu, 'x_') + y_ = get_cursor(tu, 'y_') + assert cls is not None + assert x_ is not None + assert y_ is not None + + assert not x_.is_mutable_field() + assert y_.is_mutable_field() + def test_is_static_method(): """Ensure Cursor.is_static_method works.""" |