r298424 - [CMake] fix CLANG_INCLUDE_DIRS CMake export

2017-03-21 Thread Guillaume Papin via cfe-commits
Author: papin_g
Date: Tue Mar 21 14:17:53 2017
New Revision: 298424

URL: http://llvm.org/viewvc/llvm-project?rev=298424&view=rev
Log:
[CMake] fix CLANG_INCLUDE_DIRS CMake export

Summary:
This change should fixes the export of CLANG_INCLUDE_DIRS variable in 
ClangConfig.cmake.

Unlike for the other variables, CLANG_INSTALL_PREFIX wasn't escaped meaning 
CLANG_INCLUDE_DIRS
resulting in the path "/include" instead of "${CLANG_INSTALL_PREFIX}/include".

Reviewers: beanz

Subscribers: mgorny

Differential Revision: https://reviews.llvm.org/D30911

Modified:
cfe/trunk/cmake/modules/CMakeLists.txt

Modified: cfe/trunk/cmake/modules/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/CMakeLists.txt?rev=298424&r1=298423&r2=298424&view=diff
==
--- cfe/trunk/cmake/modules/CMakeLists.txt (original)
+++ cfe/trunk/cmake/modules/CMakeLists.txt Tue Mar 21 14:17:53 2017
@@ -42,7 +42,7 @@ set(CLANG_CONFIG_CMAKE_DIR "\${CLANG_INS
 set(CLANG_CONFIG_LLVM_CMAKE_DIR 
"\${CLANG_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
 set(CLANG_CONFIG_EXPORTS_FILE "\${CLANG_CMAKE_DIR}/ClangTargets.cmake")
 set(CLANG_CONFIG_INCLUDE_DIRS
-  "${CLANG_INSTALL_PREFIX}/include"
+  "\${CLANG_INSTALL_PREFIX}/include"
   )
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r248723 - [clang-tidy] add option to specify build path

2015-09-28 Thread Guillaume Papin via cfe-commits
Author: papin_g
Date: Mon Sep 28 12:53:04 2015
New Revision: 248723

URL: http://llvm.org/viewvc/llvm-project?rev=248723&view=rev
Log:
[clang-tidy] add option to specify build path

Summary:
compile_commands.json is usually generated in the build directory.
Projects like LLVM/Clang enforce out-of-source builds.
This option allow allow such projects to work out of the box, without
moving the compilation database manually.

The naming of the option is similar to the one use by other tools:

clang-{check,modernize,query,rename,tidy} -p= <...>

Reviewers: alexfh

Differential Revision: http://reviews.llvm.org/D13199

Modified:
clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py

Modified: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py?rev=248723&r1=248722&r2=248723&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py Mon Sep 28 
12:53:04 2015
@@ -128,10 +128,21 @@ def main():
   parser.add_argument('-fix', action='store_true', help='apply fix-its')
   parser.add_argument('-format', action='store_true', help='Reformat code '
   'after applying fixes')
+  parser.add_argument('-p', dest='build_path',
+  help='Path used to read a compile command database.')
   args = parser.parse_args()
 
+  db_path = 'compile_commands.json'
+
+  if args.build_path is not None:
+build_path = args.build_path
+  else:
+# Find our database
+build_path = find_compilation_database(db_path)
+
   try:
 invocation = [args.clang_tidy_binary, '-list-checks']
+invocation.append('-p=' + build_path)
 if args.checks:
   invocation.append('-checks=' + args.checks)
 invocation.append('-')
@@ -140,10 +151,6 @@ def main():
 print >>sys.stderr, "Unable to run clang-tidy."
 sys.exit(1)
 
-  # Find our database.
-  db_path = 'compile_commands.json'
-  build_path = find_compilation_database(db_path)
-
   # Load the database and extract all files.
   database = json.load(open(os.path.join(build_path, db_path)))
   files = [entry['file'] for entry in database]


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262845 - python binding: expose compile command filename

2016-03-07 Thread Guillaume Papin via cfe-commits
Author: papin_g
Date: Mon Mar  7 12:44:42 2016
New Revision: 262845

URL: http://llvm.org/viewvc/llvm-project?rev=262845&view=rev
Log:
python binding: expose compile command filename

Reviewers: compnerd, skalinichev

Differential Revision: http://reviews.llvm.org/D17278

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/bindings/python/tests/cindex/test_cdb.py

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=262845&r1=262844&r2=262845&view=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Mon Mar  7 12:44:42 2016
@@ -2703,6 +2703,11 @@ class CompileCommand(object):
 return conf.lib.clang_CompileCommand_getDirectory(self.cmd)
 
 @property
+def filename(self):
+"""Get the working filename for this CompileCommand"""
+return conf.lib.clang_CompileCommand_getFilename(self.cmd)
+
+@property
 def arguments(self):
 """
 Get an iterable object providing each argument in the
@@ -2883,6 +2888,11 @@ functionList = [
[c_object_p],
_CXString,
_CXString.from_result),
+
+  ("clang_CompileCommand_getFilename",
+   [c_object_p],
+   _CXString,
+   _CXString.from_result),
 
   ("clang_CompileCommand_getNumArgs",
[c_object_p],

Modified: cfe/trunk/bindings/python/tests/cindex/test_cdb.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_cdb.py?rev=262845&r1=262844&r2=262845&view=diff
==
--- cfe/trunk/bindings/python/tests/cindex/test_cdb.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_cdb.py Mon Mar  7 12:44:42 2016
@@ -38,27 +38,34 @@ def test_all_compilecommand():
 cmds = cdb.getAllCompileCommands()
 assert len(cmds) == 3
 expected = [
+{ 'wd': '/home/john.doe/MyProject',
+  'file': '/home/john.doe/MyProject/project.cpp',
+  'line': ['clang++', '-o', 'project.o', '-c',
+   '/home/john.doe/MyProject/project.cpp']},
 { 'wd': '/home/john.doe/MyProjectA',
+  'file': '/home/john.doe/MyProject/project2.cpp',
   'line': ['clang++', '-o', 'project2.o', '-c',
'/home/john.doe/MyProject/project2.cpp']},
 { 'wd': '/home/john.doe/MyProjectB',
+  'file': '/home/john.doe/MyProject/project2.cpp',
   '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']
+assert cmds[i].filename == expected[i]['file']
 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)
-cmds = cdb.getCompileCommands('/home/john.doe/MyProject/project.cpp')
+file = '/home/john.doe/MyProject/project.cpp'
+cmds = cdb.getCompileCommands(file)
 assert len(cmds) == 1
-assert cmds[0].directory == '/home/john.doe/MyProject'
+assert cmds[0].directory == os.path.dirname(file)
+assert cmds[0].filename == file
 expected = [ 'clang++', '-o', 'project.o', '-c',
  '/home/john.doe/MyProject/project.cpp']
 for arg, exp in zip(cmds[0].arguments, expected):


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits