summaryrefslogtreecommitdiffstats
path: root/clang/bindings/python/tests/cindex
diff options
context:
space:
mode:
authorJonathan Coe <jbcoe@me.com>2018-05-10 21:39:29 +0000
committerJonathan Coe <jbcoe@me.com>2018-05-10 21:39:29 +0000
commite7e1d9349b04a250b9f67eb5efd3dec0d942c9d4 (patch)
tree82098629f1a2a76b939af7a67df3eeef07a11a1c /clang/bindings/python/tests/cindex
parent86e6742c178e1e50dddb2a40cb8900b98a65c05d (diff)
downloadbcm5719-llvm-e7e1d9349b04a250b9f67eb5efd3dec0d942c9d4.tar.gz
bcm5719-llvm-e7e1d9349b04a250b9f67eb5efd3dec0d942c9d4.zip
implementing Cursor.get_included_file in python bindings
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) llvm-svn: 332045
Diffstat (limited to 'clang/bindings/python/tests/cindex')
-rw-r--r--clang/bindings/python/tests/cindex/test_translation_unit.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/bindings/python/tests/cindex/test_translation_unit.py b/clang/bindings/python/tests/cindex/test_translation_unit.py
index 1b3973d59f6..09230d1da2d 100644
--- a/clang/bindings/python/tests/cindex/test_translation_unit.py
+++ b/clang/bindings/python/tests/cindex/test_translation_unit.py
@@ -108,6 +108,18 @@ int SOME_DEFINE;
for i in zip(inc, tu.get_includes()):
eq(i[0], i[1])
+ def test_inclusion_directive(self):
+ src = os.path.join(kInputsDir, 'include.cpp')
+ h1 = os.path.join(kInputsDir, "header1.h")
+ h2 = os.path.join(kInputsDir, "header2.h")
+ h3 = os.path.join(kInputsDir, "header3.h")
+ inc = [h1, h3, h2, h3, h1]
+
+ tu = TranslationUnit.from_source(src, options=TranslationUnit.PARSE_DETAILED_PROCESSING_RECORD)
+ inclusion_directive_files = [c.get_included_file().name for c in tu.cursor.get_children() if c.kind == CursorKind.INCLUSION_DIRECTIVE]
+ for i in zip(inc, inclusion_directive_files):
+ self.assert_normpaths_equal(i[0], i[1])
+
def test_save(self):
"""Ensure TranslationUnit.save() works."""
OpenPOWER on IntegriCloud