cindex/Python: Add TranslationUnit.get_includes, patch by Andrew Sutton!

llvm-svn: 96106
diff --git a/clang/bindings/python/tests/cindex/INPUTS/header1.h b/clang/bindings/python/tests/cindex/INPUTS/header1.h
new file mode 100644
index 0000000..b4eacbe
--- /dev/null
+++ b/clang/bindings/python/tests/cindex/INPUTS/header1.h
@@ -0,0 +1,6 @@
+#ifndef HEADER1
+#define HEADER1
+
+#include "header3.h"
+
+#endif
diff --git a/clang/bindings/python/tests/cindex/INPUTS/header2.h b/clang/bindings/python/tests/cindex/INPUTS/header2.h
new file mode 100644
index 0000000..c4eddc0
--- /dev/null
+++ b/clang/bindings/python/tests/cindex/INPUTS/header2.h
@@ -0,0 +1,6 @@
+#ifndef HEADER2
+#define HEADER2
+
+#include "header3.h"
+
+#endif
diff --git a/clang/bindings/python/tests/cindex/INPUTS/header3.h b/clang/bindings/python/tests/cindex/INPUTS/header3.h
new file mode 100644
index 0000000..6dca764
--- /dev/null
+++ b/clang/bindings/python/tests/cindex/INPUTS/header3.h
@@ -0,0 +1,3 @@
+// Not a guarded header!
+
+void f();
diff --git a/clang/bindings/python/tests/cindex/INPUTS/include.cpp b/clang/bindings/python/tests/cindex/INPUTS/include.cpp
new file mode 100644
index 0000000..60cfdaa
--- /dev/null
+++ b/clang/bindings/python/tests/cindex/INPUTS/include.cpp
@@ -0,0 +1,5 @@
+#include "header1.h"
+#include "header2.h"
+#include "header1.h"
+
+int main() { }
diff --git a/clang/bindings/python/tests/cindex/test_translation_unit.py b/clang/bindings/python/tests/cindex/test_translation_unit.py
index ec12e68..3c05c3f 100644
--- a/clang/bindings/python/tests/cindex/test_translation_unit.py
+++ b/clang/bindings/python/tests/cindex/test_translation_unit.py
@@ -49,3 +49,25 @@
             ('fake.c', StringIO.StringIO('int x;'))])
     spellings = [c.spelling for c in tu.cursor.get_children()]
     assert spellings[-1] == 'x'
+
+
+def test_includes():
+    def eq(expected, actual):
+        if not actual.is_input_file:
+            return expected[0] == actual.source.name and \
+                   expected[1] == actual.include.name
+        else:
+            return expected[1] == actual.include.name
+
+    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 = [(None, src), (src, h1), (h1, h3), (src, h2), (h2, h3)]
+
+    index = Index.create()
+    tu = index.parse(src)
+    for i in zip(inc, tu.get_includes()):
+        assert eq(i[0], i[1])
+
+