summaryrefslogtreecommitdiffstats
path: root/clang/bindings/python
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-12-20 01:34:00 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-12-20 01:34:00 +0000
commitb0188f246aada86f2f37afe87c49bf0c666490f0 (patch)
treeffba346df9125ae8f290653303a75ed0f81dc9e0 /clang/bindings/python
parent99e80c14b341359045381c27e991d64044232a4a (diff)
downloadbcm5719-llvm-b0188f246aada86f2f37afe87c49bf0c666490f0.tar.gz
bcm5719-llvm-b0188f246aada86f2f37afe87c49bf0c666490f0.zip
[libclang/python] Add CompilationDatabase.getAllCompileCommands to the python bindings.
Patch by Laszlo Nagy! llvm-svn: 197765
Diffstat (limited to 'clang/bindings/python')
-rw-r--r--clang/bindings/python/clang/cindex.py13
-rw-r--r--clang/bindings/python/tests/cindex/test_cdb.py21
2 files changed, 34 insertions, 0 deletions
diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py
index 00aaed57d11..9b65bef2cef 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -2607,6 +2607,14 @@ class CompilationDatabase(ClangObject):
return conf.lib.clang_CompilationDatabase_getCompileCommands(self,
filename)
+ def getAllCompileCommands(self):
+ """
+ Get an iterable object providing all the CompileCommands available from
+ the database.
+ """
+ return conf.lib.clang_CompilationDatabase_getAllCompileCommands(self)
+
+
class Token(Structure):
"""Represents a single token from the preprocessor.
@@ -2673,6 +2681,11 @@ functionList = [
c_object_p,
CompilationDatabase.from_result),
+ ("clang_CompilationDatabase_getAllCompileCommands",
+ [c_object_p],
+ c_object_p,
+ CompileCommands.from_result),
+
("clang_CompilationDatabase_getCompileCommands",
[c_object_p, c_char_p],
c_object_p,
diff --git a/clang/bindings/python/tests/cindex/test_cdb.py b/clang/bindings/python/tests/cindex/test_cdb.py
index d0f580ea9f4..e1f824f797f 100644
--- a/clang/bindings/python/tests/cindex/test_cdb.py
+++ b/clang/bindings/python/tests/cindex/test_cdb.py
@@ -32,6 +32,27 @@ def test_lookup_succeed():
cmds = cdb.getCompileCommands('/home/john.doe/MyProject/project.cpp')
assert len(cmds) != 0
+def test_all_compilecommand():
+ """Check we get all results from the db"""
+ cdb = CompilationDatabase.fromDirectory(kInputsDir)
+ cmds = cdb.getAllCompileCommands()
+ assert len(cmds) == 3
+ expected = [
+ { 'wd': '/home/john.doe/MyProjectA',
+ 'line': ['clang++', '-o', 'project2.o', '-c',
+ '/home/john.doe/MyProject/project2.cpp']},
+ { 'wd': '/home/john.doe/MyProjectB',
+ 'line': ['clang++', '-DFEATURE=1', '-o', 'project2-feature.o', '-c',
+ '/home/john.doe/MyProject/project2.cpp']},
+ { 'wd': '/home/john.doe/MyProject',
+ 'line': ['clang++', '-o', 'project.o', '-c',
+ '/home/john.doe/MyProject/project.cpp']}
+ ]
+ for i in range(len(cmds)):
+ assert cmds[i].directory == expected[i]['wd']
+ for arg, exp in zip(cmds[i].arguments, expected[i]['line']):
+ assert arg == exp
+
def test_1_compilecommand():
"""Check file with single compile command"""
cdb = CompilationDatabase.fromDirectory(kInputsDir)
OpenPOWER on IntegriCloud