steveire updated this revision to Diff 167619.
steveire added a comment.

Doc fix


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52334

Files:
  CMakeLists.txt
  clang-tidy/CMakeLists.txt
  clang-tidy/ClangTidy.cpp
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/plugin/ClangTidyPlugin.cpp
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  docs/clang-tidy/index.rst
  test/CMakeLists.txt
  test/clang-tidy/enable-alpha-checks.cpp
  test/clang-tidy/mpi-buffer-deref.cpp
  test/clang-tidy/mpi-type-mismatch.cpp
  test/clang-tidy/nolint.cpp
  test/clang-tidy/read_file_config.cpp
  test/clang-tidy/static-analyzer-config.cpp
  test/clang-tidy/static-analyzer.cpp
  test/clang-tidy/temporaries.cpp
  test/lit.cfg
  unittests/CMakeLists.txt

Index: unittests/CMakeLists.txt
===================================================================
--- unittests/CMakeLists.txt
+++ unittests/CMakeLists.txt
@@ -18,8 +18,6 @@
 add_subdirectory(clang-apply-replacements)
 add_subdirectory(clang-move)
 add_subdirectory(clang-query)
-if(CLANG_ENABLE_STATIC_ANALYZER)
-  add_subdirectory(clang-tidy)
-endif()
+add_subdirectory(clang-tidy)
 add_subdirectory(clangd)
 add_subdirectory(include-fixer)
Index: test/lit.cfg
===================================================================
--- test/lit.cfg
+++ test/lit.cfg
@@ -119,24 +119,22 @@
 
 if config.clang_staticanalyzer:
     config.available_features.add('static-analyzer')
-    check_clang_tidy = os.path.join(
-        config.test_source_root, "clang-tidy", "check_clang_tidy.py")
-    config.substitutions.append(
-        ('%check_clang_tidy',
-         '%s %s' % (config.python_executable, check_clang_tidy)) )
-    clang_tidy_diff = os.path.join(
-        config.test_source_root, "..", "clang-tidy", "tool", "clang-tidy-diff.py")
-    config.substitutions.append(
-        ('%clang_tidy_diff',
-         '%s %s' % (config.python_executable, clang_tidy_diff)) )
-    run_clang_tidy = os.path.join(
-        config.test_source_root, "..", "clang-tidy", "tool", "run-clang-tidy.py")
-    config.substitutions.append(
-        ('%run_clang_tidy',
-         '%s %s' % (config.python_executable, run_clang_tidy)) )
-else:
-    # exclude the clang-tidy test directory
-    config.excludes.append('clang-tidy')
+
+check_clang_tidy = os.path.join(
+    config.test_source_root, "clang-tidy", "check_clang_tidy.py")
+config.substitutions.append(
+    ('%check_clang_tidy',
+     '%s %s' % (config.python_executable, check_clang_tidy)) )
+clang_tidy_diff = os.path.join(
+    config.test_source_root, "..", "clang-tidy", "tool", "clang-tidy-diff.py")
+config.substitutions.append(
+    ('%clang_tidy_diff',
+     '%s %s' % (config.python_executable, clang_tidy_diff)) )
+run_clang_tidy = os.path.join(
+    config.test_source_root, "..", "clang-tidy", "tool", "run-clang-tidy.py")
+config.substitutions.append(
+    ('%run_clang_tidy',
+     '%s %s' % (config.python_executable, run_clang_tidy)) )
 
 clangd_benchmarks_dir = os.path.join(os.path.dirname(config.clang_tools_dir),
                                      "tools", "clang", "tools", "extra",
Index: test/clang-tidy/temporaries.cpp
===================================================================
--- test/clang-tidy/temporaries.cpp
+++ test/clang-tidy/temporaries.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: static-analyzer
 // RUN: clang-tidy -checks='-*,clang-analyzer-core.NullDereference' %s -- | FileCheck %s
 
 struct NoReturnDtor {
Index: test/clang-tidy/static-analyzer.cpp
===================================================================
--- test/clang-tidy/static-analyzer.cpp
+++ test/clang-tidy/static-analyzer.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: static-analyzer
 // RUN: clang-tidy %s -checks='-*,clang-analyzer-*' -- | FileCheck %s
 extern void *malloc(unsigned long);
 extern void free(void *);
Index: test/clang-tidy/static-analyzer-config.cpp
===================================================================
--- test/clang-tidy/static-analyzer-config.cpp
+++ test/clang-tidy/static-analyzer-config.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: static-analyzer
 // RUN: clang-tidy %s -checks='-*,clang-analyzer-unix.Malloc' -config='{CheckOptions: [{ key: "clang-analyzer-unix.Malloc:Optimistic", value: true}]}' -- | FileCheck %s
 typedef __typeof(sizeof(int)) size_t;
 void *malloc(size_t);
Index: test/clang-tidy/read_file_config.cpp
===================================================================
--- test/clang-tidy/read_file_config.cpp
+++ test/clang-tidy/read_file_config.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: static-analyzer
 // RUN: mkdir -p %T/read-file-config/
 // RUN: cp %s %T/read-file-config/test.cpp
 // RUN: echo 'Checks: "-*,modernize-use-nullptr"' > %T/read-file-config/.clang-tidy
Index: test/clang-tidy/nolint.cpp
===================================================================
--- test/clang-tidy/nolint.cpp
+++ test/clang-tidy/nolint.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: static-analyzer
 // RUN: %check_clang_tidy %s google-explicit-constructor,clang-diagnostic-unused-variable,clang-analyzer-core.UndefinedBinaryOperatorResult %t -- -extra-arg=-Wunused-variable -- -I%S/Inputs/nolint
 
 #include "trigger_warning.h"
Index: test/clang-tidy/mpi-type-mismatch.cpp
===================================================================
--- test/clang-tidy/mpi-type-mismatch.cpp
+++ test/clang-tidy/mpi-type-mismatch.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: static-analyzer
 // RUN: %check_clang_tidy %s mpi-type-mismatch %t -- -- -I %S/Inputs/mpi-type-mismatch
 
 #include "mpimock.h"
Index: test/clang-tidy/mpi-buffer-deref.cpp
===================================================================
--- test/clang-tidy/mpi-buffer-deref.cpp
+++ test/clang-tidy/mpi-buffer-deref.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: static-analyzer
 // RUN: %check_clang_tidy %s mpi-buffer-deref %t -- -- -I %S/Inputs/mpi-type-mismatch
 
 #include "mpimock.h"
Index: test/clang-tidy/enable-alpha-checks.cpp
===================================================================
--- test/clang-tidy/enable-alpha-checks.cpp
+++ test/clang-tidy/enable-alpha-checks.cpp
@@ -1,3 +1,5 @@
+// REQUIRES: static-analyzer
+
 // Check if '-allow-enabling-analyzer-alpha-checkers' is visible for users.
 // RUN: clang-tidy -help | not grep 'allow-enabling-analyzer-alpha-checkers'
 
Index: test/CMakeLists.txt
===================================================================
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -60,18 +60,14 @@
 
   # Unit tests
   ExtraToolsUnitTests
-  )
 
-if(CLANG_ENABLE_STATIC_ANALYZER)
-  list(APPEND CLANG_TOOLS_TEST_DEPS
-    # For the clang-tidy libclang integration test.
-    c-index-test
-    # clang-tidy tests require it.
-    clang-headers
+  # For the clang-tidy libclang integration test.
+  c-index-test
+  # clang-tidy tests require it.
+  clang-headers
 
-    clang-tidy
-    )
-endif()
+  clang-tidy
+  )
 
 set(llvm_utils
   FileCheck count not
Index: docs/clang-tidy/index.rst
===================================================================
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -337,6 +337,10 @@
   * `clang-check`_ with the ``-ast-dump`` (and optionally ``-ast-dump-filter``)
     provides a convenient way to dump AST of a C++ program.
 
+If CMake is configured with ``CLANG_ENABLE_STATIC_ANALYZER``,
+:program:`clang-tidy` will not be built with support for the 
+``clang-analyzer-*`` checks or the ``mpi-*`` checks.
+
 
 .. _AST Matchers: http://clang.llvm.org/docs/LibASTMatchers.html
 .. _PPCallbacks: http://clang.llvm.org/doxygen/classclang_1_1PPCallbacks.html
Index: clang-tidy/tool/ClangTidyMain.cpp
===================================================================
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -534,10 +534,12 @@
 static int LLVM_ATTRIBUTE_UNUSED ModernizeModuleAnchorDestination =
     ModernizeModuleAnchorSource;
 
+#if CLANG_ENABLE_STATIC_ANALYZER
 // This anchor is used to force the linker to link the MPIModule.
 extern volatile int MPIModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED MPIModuleAnchorDestination =
     MPIModuleAnchorSource;
+#endif
 
 // This anchor is used to force the linker to link the PerformanceModule.
 extern volatile int PerformanceModuleAnchorSource;
Index: clang-tidy/tool/CMakeLists.txt
===================================================================
--- clang-tidy/tool/CMakeLists.txt
+++ clang-tidy/tool/CMakeLists.txt
@@ -29,7 +29,6 @@
   clangTidyLLVMModule
   clangTidyMiscModule
   clangTidyModernizeModule
-  clangTidyMPIModule
   clangTidyObjCModule
   clangTidyPerformanceModule
   clangTidyPortabilityModule
@@ -39,6 +38,12 @@
   clangToolingCore
   )
 
+if(CLANG_ENABLE_STATIC_ANALYZER)
+  target_link_libraries(clang-tidy PRIVATE
+    clangTidyMPIModule
+  )
+endif()
+
 install(PROGRAMS clang-tidy-diff.py
   DESTINATION share/clang
   COMPONENT clang-tidy)
Index: clang-tidy/plugin/ClangTidyPlugin.cpp
===================================================================
--- clang-tidy/plugin/ClangTidyPlugin.cpp
+++ clang-tidy/plugin/ClangTidyPlugin.cpp
@@ -133,10 +133,12 @@
 static int LLVM_ATTRIBUTE_UNUSED ModernizeModuleAnchorDestination =
     ModernizeModuleAnchorSource;
 
+#if CLANG_ENABLE_STATIC_ANALYZER
 // This anchor is used to force the linker to link the MPIModule.
 extern volatile int MPIModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED MPIModuleAnchorDestination =
     MPIModuleAnchorSource;
+#endif
 
 // This anchor is used to force the linker to link the ObjCModule.
 extern volatile int ObjCModuleAnchorSource;
Index: clang-tidy/plugin/CMakeLists.txt
===================================================================
--- clang-tidy/plugin/CMakeLists.txt
+++ clang-tidy/plugin/CMakeLists.txt
@@ -20,11 +20,16 @@
   clangTidyLLVMModule
   clangTidyMiscModule
   clangTidyModernizeModule
-  clangTidyMPIModule
   clangTidyObjCModule
   clangTidyPerformanceModule
   clangTidyPortabilityModule
   clangTidyReadabilityModule
   clangTidyZirconModule
   clangTooling
   )
+
+if(CLANG_ENABLE_STATIC_ANALYZER)
+  target_link_libraries(clangTidyPlugin PRIVATE
+    clangTidyMPIModule
+  )
+endif()
Index: clang-tidy/ClangTidy.cpp
===================================================================
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -34,8 +34,10 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Rewrite/Frontend/FixItRewriter.h"
 #include "clang/Rewrite/Frontend/FrontendActions.h"
+#if CLANG_ENABLE_STATIC_ANALYZER
 #include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h"
 #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
+#endif // CLANG_ENABLE_STATIC_ANALYZER
 #include "clang/Tooling/DiagnosticsYaml.h"
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/ReplacementsYaml.h"
@@ -56,6 +58,7 @@
 namespace tidy {
 
 namespace {
+#if CLANG_ENABLE_STATIC_ANALYZER
 static const char *AnalyzerCheckNamePrefix = "clang-analyzer-";
 
 class AnalyzerDiagnosticConsumer : public ento::PathDiagnosticConsumer {
@@ -87,6 +90,7 @@
 private:
   ClangTidyContext &Context;
 };
+#endif // CLANG_ENABLE_STATIC_ANALYZER
 
 class ErrorReporter {
 public:
@@ -296,6 +300,7 @@
   }
 }
 
+#if CLANG_ENABLE_STATIC_ANALYZER
 static void setStaticAnalyzerCheckerOpts(const ClangTidyOptions &Opts,
                                          AnalyzerOptionsRef AnalyzerOptions) {
   StringRef AnalyzerPrefix(AnalyzerCheckNamePrefix);
@@ -339,6 +344,7 @@
   }
   return List;
 }
+#endif // CLANG_ENABLE_STATIC_ANALYZER
 
 std::unique_ptr<clang::ASTConsumer>
 ClangTidyASTConsumerFactory::CreateASTConsumer(
@@ -380,6 +386,7 @@
   if (!Checks.empty())
     Consumers.push_back(Finder->newASTConsumer());
 
+#if CLANG_ENABLE_STATIC_ANALYZER
   AnalyzerOptionsRef AnalyzerOptions = Compiler.getAnalyzerOpts();
   AnalyzerOptions->CheckersControlList =
       getCheckersControlList(Context, Context.canEnableAnalyzerAlphaCheckers());
@@ -395,6 +402,7 @@
         new AnalyzerDiagnosticConsumer(Context));
     Consumers.push_back(std::move(AnalysisConsumer));
   }
+#endif // CLANG_ENABLE_STATIC_ANALYZER
   return llvm::make_unique<ClangTidyASTConsumer>(
       std::move(Consumers), std::move(Profiling), std::move(Finder),
       std::move(Checks));
@@ -407,9 +415,11 @@
       CheckNames.push_back(CheckFactory.first);
   }
 
+#if CLANG_ENABLE_STATIC_ANALYZER
   for (const auto &AnalyzerCheck : getCheckersControlList(
            Context, Context.canEnableAnalyzerAlphaCheckers()))
     CheckNames.push_back(AnalyzerCheckNamePrefix + AnalyzerCheck.first);
+#endif // CLANG_ENABLE_STATIC_ANALYZER
 
   std::sort(CheckNames.begin(), CheckNames.end());
   return CheckNames;
Index: clang-tidy/CMakeLists.txt
===================================================================
--- clang-tidy/CMakeLists.txt
+++ clang-tidy/CMakeLists.txt
@@ -21,12 +21,17 @@
   clangLex
   clangRewrite
   clangSema
-  clangStaticAnalyzerCore
-  clangStaticAnalyzerFrontend
   clangTooling
   clangToolingCore
   )
 
+if(CLANG_ENABLE_STATIC_ANALYZER)
+  target_link_libraries(clangTidy PRIVATE
+    clangStaticAnalyzerCore
+    clangStaticAnalyzerFrontend
+  )
+endif()
+
 add_subdirectory(android)
 add_subdirectory(abseil)
 add_subdirectory(boost)
@@ -39,7 +44,9 @@
 add_subdirectory(llvm)
 add_subdirectory(misc)
 add_subdirectory(modernize)
-add_subdirectory(mpi)
+if(CLANG_ENABLE_STATIC_ANALYZER)
+  add_subdirectory(mpi)
+endif()
 add_subdirectory(objc)
 add_subdirectory(performance)
 add_subdirectory(plugin)
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -1,10 +1,8 @@
 add_subdirectory(clang-apply-replacements)
 add_subdirectory(clang-reorder-fields)
 add_subdirectory(modularize)
-if(CLANG_ENABLE_STATIC_ANALYZER)
 add_subdirectory(clang-tidy)
 add_subdirectory(clang-tidy-vs)
-endif()
 
 add_subdirectory(change-namespace)
 add_subdirectory(clang-doc)
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to