[clang-tools-extra] c29513f - [clangd] Fix check-clangd with no clang built

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 2 12:10:54 PST 2020


Author: Sam McCall
Date: 2020-11-02T21:10:43+01:00
New Revision: c29513f7e023f125c6d221db179dc40b79e5c074

URL: https://github.com/llvm/llvm-project/commit/c29513f7e023f125c6d221db179dc40b79e5c074
DIFF: https://github.com/llvm/llvm-project/commit/c29513f7e023f125c6d221db179dc40b79e5c074.diff

LOG: [clangd] Fix check-clangd with no clang built

- pass required=False to use_clang(), as we don't need it
- fix required=False (which was unused and rotted):
  - make derived substitutions conditional on it
  - add a feature so we can disable tests that need it
- conditionally disable our one test that depends on %resource_dir.
  This doesn't seem right from first principles, but isn't a big deal.

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

Added: 
    

Modified: 
    clang-tools-extra/clangd/test/document-link.test
    clang-tools-extra/clangd/test/lit.cfg.py
    llvm/utils/lit/lit/llvm/config.py

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/test/document-link.test b/clang-tools-extra/clangd/test/document-link.test
index a4c82e5b2fb6..63f8ca099322 100644
--- a/clang-tools-extra/clangd/test/document-link.test
+++ b/clang-tools-extra/clangd/test/document-link.test
@@ -1,3 +1,4 @@
+# for %resource_dir: REQUIRES: clang
 # %resource_dir actually points at builtin_include_dir, go up one directory.
 # RUN: clangd -lit-test -resource-dir=%resource_dir/.. < %s | FileCheck -strict-whitespace %s
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}

diff  --git a/clang-tools-extra/clangd/test/lit.cfg.py b/clang-tools-extra/clangd/test/lit.cfg.py
index a085f6a58dac..a8a38a7fafd3 100644
--- a/clang-tools-extra/clangd/test/lit.cfg.py
+++ b/clang-tools-extra/clangd/test/lit.cfg.py
@@ -1,7 +1,7 @@
 import lit.llvm
 
 lit.llvm.initialize(lit_config, config)
-lit.llvm.llvm_config.use_clang()
+lit.llvm.llvm_config.use_clang([], [], required=False)
 lit.llvm.llvm_config.use_default_substitutions()
 
 config.name = 'Clangd'

diff  --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py
index 8897deb24cde..498e34cae3a5 100644
--- a/llvm/utils/lit/lit/llvm/config.py
+++ b/llvm/utils/lit/lit/llvm/config.py
@@ -396,11 +396,6 @@ def use_clang(self, additional_tool_dirs=[], additional_flags=[], required=True)
 
         self.with_environment('LD_LIBRARY_PATH', paths, append_path=True)
 
-        # Discover the 'clang' and 'clangcc' to use.
-
-        self.config.clang = self.use_llvm_tool(
-            'clang', search_env='CLANG', required=required)
-
         shl = getattr(self.config, 'llvm_shlib_dir', None)
         pext = getattr(self.config, 'llvm_plugin_ext', None)
         if shl:
@@ -408,23 +403,28 @@ def use_clang(self, additional_tool_dirs=[], additional_flags=[], required=True)
         if pext:
             self.config.substitutions.append(('%pluginext', pext))
 
-        builtin_include_dir = self.get_clang_builtin_include_dir(self.config.clang)
-        tool_substitutions = [
-            ToolSubst('%clang', command=self.config.clang, extra_args=additional_flags),
-            ToolSubst('%clang_analyze_cc1', command='%clang_cc1', extra_args=['-analyze', '%analyze', '-setup-static-analyzer']+additional_flags),
-            ToolSubst('%clang_cc1', command=self.config.clang, extra_args=['-cc1', '-internal-isystem', builtin_include_dir, '-nostdsysteminc']+additional_flags),
-            ToolSubst('%clang_cpp', command=self.config.clang, extra_args=['--driver-mode=cpp']+additional_flags),
-            ToolSubst('%clang_cl', command=self.config.clang, extra_args=['--driver-mode=cl']+additional_flags),
-            ToolSubst('%clangxx', command=self.config.clang, extra_args=['--driver-mode=g++']+additional_flags),
-            ]
-        self.add_tool_substitutions(tool_substitutions)
+        # Discover the 'clang' and 'clangcc' to use.
+        self.config.clang = self.use_llvm_tool(
+            'clang', search_env='CLANG', required=required)
+        if self.config.clang:
+          self.config.available_features.add('clang')
+          builtin_include_dir = self.get_clang_builtin_include_dir(self.config.clang)
+          tool_substitutions = [
+              ToolSubst('%clang', command=self.config.clang, extra_args=additional_flags),
+              ToolSubst('%clang_analyze_cc1', command='%clang_cc1', extra_args=['-analyze', '%analyze', '-setup-static-analyzer']+additional_flags),
+              ToolSubst('%clang_cc1', command=self.config.clang, extra_args=['-cc1', '-internal-isystem', builtin_include_dir, '-nostdsysteminc']+additional_flags),
+              ToolSubst('%clang_cpp', command=self.config.clang, extra_args=['--driver-mode=cpp']+additional_flags),
+              ToolSubst('%clang_cl', command=self.config.clang, extra_args=['--driver-mode=cl']+additional_flags),
+              ToolSubst('%clangxx', command=self.config.clang, extra_args=['--driver-mode=g++']+additional_flags),
+              ]
+          self.add_tool_substitutions(tool_substitutions)
+          self.config.substitutions.append(
+              ('%resource_dir', builtin_include_dir))
 
         self.config.substitutions.append(('%itanium_abi_triple',
                                           self.make_itanium_abi_triple(self.config.target_triple)))
         self.config.substitutions.append(('%ms_abi_triple',
                                           self.make_msabi_triple(self.config.target_triple)))
-        self.config.substitutions.append(
-            ('%resource_dir', builtin_include_dir))
 
         # The host triple might not be set, at least if we're compiling clang from
         # an already installed llvm.


        


More information about the cfe-commits mailing list