diff options
author | Alex Lorenz <arphaman@gmail.com> | 2017-07-12 11:35:11 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2017-07-12 11:35:11 +0000 |
commit | ff7f42e61a13e8b8e26c43891d02f573d86b8ce5 (patch) | |
tree | 61d0b4edf903e6832eddb1c0f8236933cb2a62b2 /clang/bindings/python/tests/cindex/test_cursor.py | |
parent | 4fabc97c432a43f0c8efc0b307ca9741b016a66c (diff) | |
download | bcm5719-llvm-ff7f42e61a13e8b8e26c43891d02f573d86b8ce5.tar.gz bcm5719-llvm-ff7f42e61a13e8b8e26c43891d02f573d86b8ce5.zip |
[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
Diffstat (limited to 'clang/bindings/python/tests/cindex/test_cursor.py')
-rw-r--r-- | clang/bindings/python/tests/cindex/test_cursor.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/bindings/python/tests/cindex/test_cursor.py b/clang/bindings/python/tests/cindex/test_cursor.py index 8103e96df4f..4787ea931e1 100644 --- a/clang/bindings/python/tests/cindex/test_cursor.py +++ b/clang/bindings/python/tests/cindex/test_cursor.py @@ -255,6 +255,22 @@ def test_is_virtual_method(): assert foo.is_virtual_method() assert not bar.is_virtual_method() +def test_is_scoped_enum(): + """Ensure Cursor.is_scoped_enum works.""" + source = 'class X {}; enum RegularEnum {}; enum class ScopedEnum {};' + tu = get_tu(source, lang='cpp') + + cls = get_cursor(tu, 'X') + regular_enum = get_cursor(tu, 'RegularEnum') + scoped_enum = get_cursor(tu, 'ScopedEnum') + assert cls is not None + assert regular_enum is not None + assert scoped_enum is not None + + assert not cls.is_scoped_enum() + assert not regular_enum.is_scoped_enum() + assert scoped_enum.is_scoped_enum() + def test_underlying_type(): tu = get_tu('typedef int foo;') typedef = get_cursor(tu, 'foo') |