[PATCH] D105263: [X86] AVX512FP16 instructions enabling 1/6

2022-04-12 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.
Herald added a subscriber: StephenFan.
Herald added a project: All.

I was tracking back a recent ABI break (also failing now in gcc 12, so maybe 
this irregularity is intentional), and was concerned that this commit is 
observed to cause the platform ABI to change depending on the feature flags of 
the current compilation unit. Prior to this change, f16 was always treated as 
i16 for the purpose of the calling-convention (e.g. returned in %ax). But after 
this change, the ABI of the value is now inconsistent between compile units. I 
made a small change to one of the existing tests to show this. Note how the 
callq result was in %ax without this mattr flag, and in %xmm0 with this mattr 
flag added. But the function known as "identity.half" is external, and did not 
change between those two calls to the llvm.

  diff --git a/llvm/test/CodeGen/X86/half.ll b/llvm/test/CodeGen/X86/half.ll
  index 46179e7d9113..8c1b8c4b76ff 100644
  --- a/llvm/test/CodeGen/X86/half.ll
  +++ b/llvm/test/CodeGen/X86/half.ll
  @@ -5,6 +5,8 @@
   ; RUN:   | FileCheck %s -check-prefixes=CHECK,CHECK-LIBCALL,BWOFF
   ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mattr=+f16c 
-fixup-byte-word-insts=1 \
   ; RUN:| FileCheck %s -check-prefixes=CHECK,BWON,BWON-F16C
  +; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mattr=+avx512fp16 
-fixup-byte-word-insts=0 \
  +; RUN:| FileCheck %s -check-prefixes=CHECK-CC
   ; RUN: llc < %s -mtriple=i686-unknown-linux-gnu -mattr +sse2 
-fixup-byte-word-insts=0  \
   ; RUN:| FileCheck %s -check-prefixes=CHECK-I686
  
  @@ -163,16 +199,31 @@ define void @test_trunc32(float %in, half* %addr) #0 {
 ret void
   }
   
  +declare half @identity.half(half)
  +
   define void @test_trunc64(double %in, half* %addr) #0 {
   ; CHECK-LABEL: test_trunc64:
   ; CHECK:   # %bb.0:
   ; CHECK-NEXT:pushq %rbx
   ; CHECK-NEXT:movq %rdi, %rbx
   ; CHECK-NEXT:callq __truncdfhf2@PLT
  +; CHECK-NEXT:# kill: def $ax killed $ax def $eax
  +; CHECK-NEXT:movl %eax, %edi
  +; CHECK-NEXT:callq identity.half@PLT
   ; CHECK-NEXT:movw %ax, (%rbx)
   ; CHECK-NEXT:popq %rbx
   ; CHECK-NEXT:retq
   ;
  +; CHECK-CC-LABEL: test_trunc64:
  +; CHECK-CC:   # %bb.0:
  +; CHECK-CC-NEXT:pushq %rbx
  +; CHECK-CC-NEXT:movq %rdi, %rbx
  +; CHECK-CC-NEXT:vcvtsd2sh %xmm0, %xmm0, %xmm0
  +; CHECK-CC-NEXT:callq identity.half@PLT
  +; CHECK-CC-NEXT:vmovsh %xmm0, (%rbx)
  +; CHECK-CC-NEXT:popq %rbx
  +; CHECK-CC-NEXT:retq
  +;
   ; CHECK-I686-LABEL: test_trunc64:
   ; CHECK-I686:   # %bb.0:
   ; CHECK-I686-NEXT:pushl %esi
  @@ -181,12 +232,16 @@ define void @test_trunc64(double %in, half* %addr) #0 {
   ; CHECK-I686-NEXT:movsd {{.*#+}} xmm0 = mem[0],zero
   ; CHECK-I686-NEXT:movsd %xmm0, (%esp)
   ; CHECK-I686-NEXT:calll __truncdfhf2
  +; CHECK-I686-NEXT:# kill: def $ax killed $ax def $eax
  +; CHECK-I686-NEXT:movl %eax, (%esp)
  +; CHECK-I686-NEXT:calll identity.half@PLT
   ; CHECK-I686-NEXT:movw %ax, (%esi)
   ; CHECK-I686-NEXT:addl $8, %esp
   ; CHECK-I686-NEXT:popl %esi
   ; CHECK-I686-NEXT:retl
 %val16 = fptrunc double %in to half
  -  store half %val16, half* %addr
  +  %val16b = call half @identity.half(half %val16)
  +  store half %val16b, half* %addr
 ret void
   }

Is this intentional? We do already have code to handle the ABI dependency on 
vector-sizes, and could add this to the list of flags that change the ABI (i.e. 
we disable it if it will break the ABI), but wanted to confirm first if that 
was the intent here.

discovered from https://github.com/JuliaLang/julia/issues/44829


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105263/new/

https://reviews.llvm.org/D105263

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


[PATCH] D111100: enable plugins for clang-tidy

2022-02-07 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

It is a somewhat worthless test IMO, and might belong better in LLVM itself 
(where this functionality is defined), but there does not appear to be any 
other like it currently, and it was requested by a previous reviewer. Comparing 
to the code in LLVMTestingSupport, does this fix it for you:

  diff --git a/clang-tools-extra/test/CMakeLists.txt 
b/clang-tools-extra/test/CMakeLists.txt
  index 9321457ae1a3..17cc12473565 100644
  --- a/clang-tools-extra/test/CMakeLists.txt
  +++ b/clang-tools-extra/test/CMakeLists.txt
  @@ -87,6 +87,15 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
 PLUGIN_TOOL clang-tidy
 DEPENDS clang-tidy-headers)
   
  +  if(CLANG_BUILT_STANDALONE)
  +# LLVMHello library is needed below
  +if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Transforms/Hello
  +   AND NOT TARGET LLVMHello)
  +  add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Transforms/Hello
  +lib/Transforms/Hello)
  +endif()
  +  endif()
  +
 if(TARGET CTTestTidyModule)
 list(APPEND CLANG_TOOLS_TEST_DEPS CTTestTidyModule LLVMHello)
 target_include_directories(CTTestTidyModule PUBLIC BEFORE 
"${CLANG_TOOLS_SOURCE_DIR}")


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

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


[PATCH] D111100: enable plugins for clang-tidy

2022-02-07 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

Ah, this looks annoying: there are apparently two flags, CLANG_PLUGIN_SUPPORT 
and LLVM_ENABLE_PLUGINS, but the existing build for clang uses 
CLANG_PLUGIN_SUPPORT to turn off the build support and LLVM_ENABLE_PLUGINS to 
turn off the tests (you might not have noticed this existing issue since you 
turned off CLANG_ENABLE_STATIC_ANALYZER support, and CLANG_BUILD_EXAMPLES is 
off by default, which looks like it would disable all of the existing tests for 
this functionality). This might fix this particular test?

  diff --git a/clang-tools-extra/test/CMakeLists.txt 
b/clang-tools-extra/test/CMakeLists.txt
  index 9321457ae1a3..c98ec90a179b 100644
  --- a/clang-tools-extra/test/CMakeLists.txt
  +++ b/clang-tools-extra/test/CMakeLists.txt
  @@ -17,7 +17,7 @@ string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} 
CLANG_TOOLS_DIR ${LLVM_RUN
   
   llvm_canonicalize_cmake_booleans(
 CLANG_TIDY_ENABLE_STATIC_ANALYZER
  -  LLVM_ENABLE_PLUGINS
  +  CLANG_PLUGIN_SUPPORT
 LLVM_INSTALL_TOOLCHAIN_ONLY
 )
   
  diff --git a/clang-tools-extra/test/lit.site.cfg.py.in 
b/clang-tools-extra/test/lit.site.cfg.py.in
  index e7db0e2ef2cb..d30e6664816b 100644
  --- a/clang-tools-extra/test/lit.site.cfg.py.in
  +++ b/clang-tools-extra/test/lit.site.cfg.py.in
  @@ -12,7 +12,7 @@ config.clang_libs_dir = "@SHLIBDIR@"
   config.python_executable = "@Python3_EXECUTABLE@"
   config.target_triple = "@TARGET_TRIPLE@"
   config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
  -config.has_plugins = @LLVM_ENABLE_PLUGINS@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@
  +config.has_plugins = @CLANG_PLUGIN_SUPPORT@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@
   
   # Support substitution of the tools and libs dirs with user parameters. This 
is
   # used when we can't determine the tool dir at configuration time.

but it means there are a few other places that need to be changed also to make 
your configuration work fully.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

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


[PATCH] D119199: replace clang LLVM_ENABLE_PLUGINS -> CLANG_PLUGIN_SUPPORT in tests

2022-02-07 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash created this revision.
Herald added a subscriber: mgorny.
vtjnash requested review of this revision.
Herald added projects: clang, clang-tools-extra.
Herald added a subscriber: cfe-commits.

Fixes an issue noted in D00 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119199

Files:
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/lit.site.cfg.py.in
  clang/examples/AnnotateFunctions/CMakeLists.txt
  clang/examples/Attribute/CMakeLists.txt
  clang/examples/CallSuperAttribute/CMakeLists.txt
  clang/examples/PluginsOrder/CMakeLists.txt
  clang/examples/PrintFunctionNames/CMakeLists.txt
  clang/lib/Analysis/plugins/CMakeLists.txt
  clang/test/CMakeLists.txt
  clang/test/lit.site.cfg.py.in

Index: clang/test/lit.site.cfg.py.in
===
--- clang/test/lit.site.cfg.py.in
+++ clang/test/lit.site.cfg.py.in
@@ -34,7 +34,7 @@
 config.host_arch = "@HOST_ARCH@"
 config.python_executable = "@Python3_EXECUTABLE@"
 config.use_z3_solver = lit_config.params.get('USE_Z3_SOLVER', "@USE_Z3_SOLVER@")
-config.has_plugins = @LLVM_ENABLE_PLUGINS@
+config.has_plugins = @CLANG_PLUGIN_SUPPORT@
 config.clang_vendor_uti = "@CLANG_VENDOR_UTI@"
 config.llvm_external_lit = path(r"@LLVM_EXTERNAL_LIT@")
 
Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -14,12 +14,12 @@
   CLANG_DEFAULT_PIE_ON_LINUX
   CLANG_ENABLE_ARCMT
   CLANG_ENABLE_STATIC_ANALYZER
+  CLANG_PLUGIN_SUPPORT
   CLANG_SPAWN_CC1
   ENABLE_BACKTRACES
   LLVM_ENABLE_NEW_PASS_MANAGER
   LLVM_ENABLE_ZLIB
   LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
-  LLVM_ENABLE_PLUGINS
   LLVM_ENABLE_THREADS
   LLVM_WITH_Z3
   )
@@ -146,7 +146,7 @@
 endif()
 
 if (CLANG_ENABLE_STATIC_ANALYZER)
-  if (LLVM_ENABLE_PLUGINS)
+  if (CLANG_PLUGIN_SUPPORT)
 list(APPEND CLANG_TEST_DEPS
   SampleAnalyzerPlugin
   CheckerDependencyHandlingAnalyzerPlugin
Index: clang/lib/Analysis/plugins/CMakeLists.txt
===
--- clang/lib/Analysis/plugins/CMakeLists.txt
+++ clang/lib/Analysis/plugins/CMakeLists.txt
@@ -1,4 +1,4 @@
-if(CLANG_ENABLE_STATIC_ANALYZER AND LLVM_ENABLE_PLUGINS)
+if(CLANG_ENABLE_STATIC_ANALYZER AND CLANG_PLUGIN_SUPPORT)
   add_subdirectory(SampleAnalyzer)
   add_subdirectory(CheckerDependencyHandling)
   add_subdirectory(CheckerOptionHandling)
Index: clang/examples/PrintFunctionNames/CMakeLists.txt
===
--- clang/examples/PrintFunctionNames/CMakeLists.txt
+++ clang/examples/PrintFunctionNames/CMakeLists.txt
@@ -11,7 +11,7 @@
 
 add_llvm_library(PrintFunctionNames MODULE PrintFunctionNames.cpp PLUGIN_TOOL clang)
 
-if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/PluginsOrder/CMakeLists.txt
===
--- clang/examples/PluginsOrder/CMakeLists.txt
+++ clang/examples/PluginsOrder/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(PluginsOrder MODULE PluginsOrder.cpp PLUGIN_TOOL clang)
 
-if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/CallSuperAttribute/CMakeLists.txt
===
--- clang/examples/CallSuperAttribute/CMakeLists.txt
+++ clang/examples/CallSuperAttribute/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(CallSuperAttr MODULE CallSuperAttrInfo.cpp PLUGIN_TOOL clang)
 
-if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/Attribute/CMakeLists.txt
===
--- clang/examples/Attribute/CMakeLists.txt
+++ clang/examples/Attribute/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(Attribute MODULE Attribute.cpp PLUGIN_TOOL clang)
 
-if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
   target_link_libraries(Attribute PRIVATE
 clangAST
 clangBasic
Index: clang/examples/AnnotateFunctions/CMakeLists.txt
===
--- clang/examples/AnnotateFunctions/CMakeLists.txt
+++ clang/examples/AnnotateFunctions/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(AnnotateFunctions MODULE AnnotateFunctions.cpp PLUGIN_TOOL clang)
 
-if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in

[PATCH] D111100: enable plugins for clang-tidy

2022-02-07 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash accepted this revision.
vtjnash added a comment.

Fixed by D119199 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

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


[PATCH] D119199: replace clang LLVM_ENABLE_PLUGINS -> CLANG_PLUGIN_SUPPORT in tests

2022-02-08 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash updated this revision to Diff 406856.
vtjnash added a comment.

  ensure CLANG_PLUGIN_SUPPORT setting is compatible with llvm_add_library


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119199/new/

https://reviews.llvm.org/D119199

Files:
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/lit.site.cfg.py.in
  clang/CMakeLists.txt
  clang/examples/AnnotateFunctions/CMakeLists.txt
  clang/examples/Attribute/CMakeLists.txt
  clang/examples/CallSuperAttribute/CMakeLists.txt
  clang/examples/PluginsOrder/CMakeLists.txt
  clang/examples/PrintFunctionNames/CMakeLists.txt
  clang/lib/Analysis/plugins/CMakeLists.txt
  clang/test/CMakeLists.txt
  clang/test/lit.site.cfg.py.in
  clang/tools/driver/CMakeLists.txt

Index: clang/tools/driver/CMakeLists.txt
===
--- clang/tools/driver/CMakeLists.txt
+++ clang/tools/driver/CMakeLists.txt
@@ -17,8 +17,6 @@
   Vectorize
   )
 
-option(CLANG_PLUGIN_SUPPORT "Build clang with plugin support" ON)
-
 # Support plugins.
 if(CLANG_PLUGIN_SUPPORT)
   set(support_plugins SUPPORT_PLUGINS)
Index: clang/test/lit.site.cfg.py.in
===
--- clang/test/lit.site.cfg.py.in
+++ clang/test/lit.site.cfg.py.in
@@ -34,7 +34,7 @@
 config.host_arch = "@HOST_ARCH@"
 config.python_executable = "@Python3_EXECUTABLE@"
 config.use_z3_solver = lit_config.params.get('USE_Z3_SOLVER', "@USE_Z3_SOLVER@")
-config.has_plugins = @LLVM_ENABLE_PLUGINS@
+config.has_plugins = @CLANG_PLUGIN_SUPPORT@
 config.clang_vendor_uti = "@CLANG_VENDOR_UTI@"
 config.llvm_external_lit = path(r"@LLVM_EXTERNAL_LIT@")
 
Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -14,12 +14,12 @@
   CLANG_DEFAULT_PIE_ON_LINUX
   CLANG_ENABLE_ARCMT
   CLANG_ENABLE_STATIC_ANALYZER
+  CLANG_PLUGIN_SUPPORT
   CLANG_SPAWN_CC1
   ENABLE_BACKTRACES
   LLVM_ENABLE_NEW_PASS_MANAGER
   LLVM_ENABLE_ZLIB
   LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
-  LLVM_ENABLE_PLUGINS
   LLVM_ENABLE_THREADS
   LLVM_WITH_Z3
   )
@@ -146,7 +146,7 @@
 endif()
 
 if (CLANG_ENABLE_STATIC_ANALYZER)
-  if (LLVM_ENABLE_PLUGINS)
+  if (CLANG_PLUGIN_SUPPORT)
 list(APPEND CLANG_TEST_DEPS
   SampleAnalyzerPlugin
   CheckerDependencyHandlingAnalyzerPlugin
Index: clang/lib/Analysis/plugins/CMakeLists.txt
===
--- clang/lib/Analysis/plugins/CMakeLists.txt
+++ clang/lib/Analysis/plugins/CMakeLists.txt
@@ -1,4 +1,4 @@
-if(CLANG_ENABLE_STATIC_ANALYZER AND LLVM_ENABLE_PLUGINS)
+if(CLANG_ENABLE_STATIC_ANALYZER AND CLANG_PLUGIN_SUPPORT)
   add_subdirectory(SampleAnalyzer)
   add_subdirectory(CheckerDependencyHandling)
   add_subdirectory(CheckerOptionHandling)
Index: clang/examples/PrintFunctionNames/CMakeLists.txt
===
--- clang/examples/PrintFunctionNames/CMakeLists.txt
+++ clang/examples/PrintFunctionNames/CMakeLists.txt
@@ -11,7 +11,7 @@
 
 add_llvm_library(PrintFunctionNames MODULE PrintFunctionNames.cpp PLUGIN_TOOL clang)
 
-if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/PluginsOrder/CMakeLists.txt
===
--- clang/examples/PluginsOrder/CMakeLists.txt
+++ clang/examples/PluginsOrder/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(PluginsOrder MODULE PluginsOrder.cpp PLUGIN_TOOL clang)
 
-if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/CallSuperAttribute/CMakeLists.txt
===
--- clang/examples/CallSuperAttribute/CMakeLists.txt
+++ clang/examples/CallSuperAttribute/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(CallSuperAttr MODULE CallSuperAttrInfo.cpp PLUGIN_TOOL clang)
 
-if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/Attribute/CMakeLists.txt
===
--- clang/examples/Attribute/CMakeLists.txt
+++ clang/examples/Attribute/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(Attribute MODULE Attribute.cpp PLUGIN_TOOL clang)
 
-if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
   target_link_libraries(Attribute PRIVATE
 clangAST
 clangBasic
Index: clang/examples/AnnotateFunctions/CMakeLists.txt
===
--- clang/examples/AnnotateFunctions/CMakeLists.txt
+++ clang/examples/AnnotateFunctions/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_ll

[PATCH] D119199: replace clang LLVM_ENABLE_PLUGINS -> CLANG_PLUGIN_SUPPORT in tests

2022-02-09 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

@cristian.adam Is this good now? You are blocking merging this, but I think it 
is ready to land, and I would like to not hold it up for other people if it is 
fixing their issues (and the issues you discovered too)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119199/new/

https://reviews.llvm.org/D119199

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


[PATCH] D119199: replace clang LLVM_ENABLE_PLUGINS -> CLANG_PLUGIN_SUPPORT in tests

2022-02-09 Thread Jameson Nash via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG76cad51ba700: replace clang LLVM_ENABLE_PLUGINS -> 
CLANG_PLUGIN_SUPPORT in tests (authored by vtjnash).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119199/new/

https://reviews.llvm.org/D119199

Files:
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/lit.site.cfg.py.in
  clang/CMakeLists.txt
  clang/examples/AnnotateFunctions/CMakeLists.txt
  clang/examples/Attribute/CMakeLists.txt
  clang/examples/CallSuperAttribute/CMakeLists.txt
  clang/examples/PluginsOrder/CMakeLists.txt
  clang/examples/PrintFunctionNames/CMakeLists.txt
  clang/lib/Analysis/plugins/CMakeLists.txt
  clang/test/CMakeLists.txt
  clang/test/lit.site.cfg.py.in
  clang/tools/driver/CMakeLists.txt

Index: clang/tools/driver/CMakeLists.txt
===
--- clang/tools/driver/CMakeLists.txt
+++ clang/tools/driver/CMakeLists.txt
@@ -17,8 +17,6 @@
   Vectorize
   )
 
-option(CLANG_PLUGIN_SUPPORT "Build clang with plugin support" ON)
-
 # Support plugins.
 if(CLANG_PLUGIN_SUPPORT)
   set(support_plugins SUPPORT_PLUGINS)
Index: clang/test/lit.site.cfg.py.in
===
--- clang/test/lit.site.cfg.py.in
+++ clang/test/lit.site.cfg.py.in
@@ -34,7 +34,7 @@
 config.host_arch = "@HOST_ARCH@"
 config.python_executable = "@Python3_EXECUTABLE@"
 config.use_z3_solver = lit_config.params.get('USE_Z3_SOLVER', "@USE_Z3_SOLVER@")
-config.has_plugins = @LLVM_ENABLE_PLUGINS@
+config.has_plugins = @CLANG_PLUGIN_SUPPORT@
 config.clang_vendor_uti = "@CLANG_VENDOR_UTI@"
 config.llvm_external_lit = path(r"@LLVM_EXTERNAL_LIT@")
 
Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -14,12 +14,12 @@
   CLANG_DEFAULT_PIE_ON_LINUX
   CLANG_ENABLE_ARCMT
   CLANG_ENABLE_STATIC_ANALYZER
+  CLANG_PLUGIN_SUPPORT
   CLANG_SPAWN_CC1
   ENABLE_BACKTRACES
   LLVM_ENABLE_NEW_PASS_MANAGER
   LLVM_ENABLE_ZLIB
   LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
-  LLVM_ENABLE_PLUGINS
   LLVM_ENABLE_THREADS
   LLVM_WITH_Z3
   )
@@ -146,7 +146,7 @@
 endif()
 
 if (CLANG_ENABLE_STATIC_ANALYZER)
-  if (LLVM_ENABLE_PLUGINS)
+  if (CLANG_PLUGIN_SUPPORT)
 list(APPEND CLANG_TEST_DEPS
   SampleAnalyzerPlugin
   CheckerDependencyHandlingAnalyzerPlugin
Index: clang/lib/Analysis/plugins/CMakeLists.txt
===
--- clang/lib/Analysis/plugins/CMakeLists.txt
+++ clang/lib/Analysis/plugins/CMakeLists.txt
@@ -1,4 +1,4 @@
-if(CLANG_ENABLE_STATIC_ANALYZER AND LLVM_ENABLE_PLUGINS)
+if(CLANG_ENABLE_STATIC_ANALYZER AND CLANG_PLUGIN_SUPPORT)
   add_subdirectory(SampleAnalyzer)
   add_subdirectory(CheckerDependencyHandling)
   add_subdirectory(CheckerOptionHandling)
Index: clang/examples/PrintFunctionNames/CMakeLists.txt
===
--- clang/examples/PrintFunctionNames/CMakeLists.txt
+++ clang/examples/PrintFunctionNames/CMakeLists.txt
@@ -11,7 +11,7 @@
 
 add_llvm_library(PrintFunctionNames MODULE PrintFunctionNames.cpp PLUGIN_TOOL clang)
 
-if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/PluginsOrder/CMakeLists.txt
===
--- clang/examples/PluginsOrder/CMakeLists.txt
+++ clang/examples/PluginsOrder/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(PluginsOrder MODULE PluginsOrder.cpp PLUGIN_TOOL clang)
 
-if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/CallSuperAttribute/CMakeLists.txt
===
--- clang/examples/CallSuperAttribute/CMakeLists.txt
+++ clang/examples/CallSuperAttribute/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(CallSuperAttr MODULE CallSuperAttrInfo.cpp PLUGIN_TOOL clang)
 
-if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/Attribute/CMakeLists.txt
===
--- clang/examples/Attribute/CMakeLists.txt
+++ clang/examples/Attribute/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(Attribute MODULE Attribute.cpp PLUGIN_TOOL clang)
 
-if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
   target_link_libraries(Attribute PRIVATE
 clangAST
 clangBasic
Index: clang/examples/AnnotateFunctions/CMakeLists.txt
===
--- clang/examples/AnnotateFunctions/CMakeLists.txt
+++ clang/examples/Annot

[PATCH] D119199: replace clang LLVM_ENABLE_PLUGINS -> CLANG_PLUGIN_SUPPORT in tests

2022-02-09 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

Thanks, if you encounter more issues next week, let me know, and I will 
continue trying to adjust it to work for all config option combinations.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119199/new/

https://reviews.llvm.org/D119199

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


[PATCH] D119591: clang-analyzer plugins require LLVM_ENABLE_PLUGINS also

2022-02-11 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash created this revision.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
a.sidorin, baloghadamsoftware, mgorny.
vtjnash requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The clang-analyzer plugins are not linked to a particular tool, so they
can only be compiled if plugins are broadly supported. We could opt
instead to decide whether to link them to specifically against clang or
with undefined symbols, depending on the value of LLVM_ENABLE_PLUGINS,
but we do not currently expect there to be a use case for that rather
niche configuration.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119591

Files:
  clang/examples/AnnotateFunctions/CMakeLists.txt
  clang/examples/Attribute/CMakeLists.txt
  clang/examples/CMakeLists.txt
  clang/examples/CallSuperAttribute/CMakeLists.txt
  clang/examples/PluginsOrder/CMakeLists.txt
  clang/examples/PrintFunctionNames/CMakeLists.txt
  clang/lib/Analysis/plugins/CMakeLists.txt
  clang/test/CMakeLists.txt

Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -145,8 +145,8 @@
   endif()
 endif()
 
-if (CLANG_ENABLE_STATIC_ANALYZER)
-  if (CLANG_PLUGIN_SUPPORT)
+if(CLANG_ENABLE_STATIC_ANALYZER)
+  if(CLANG_PLUGIN_SUPPORT AND LLVM_ENABLE_PLUGINS) # Determine if we built them
 list(APPEND CLANG_TEST_DEPS
   SampleAnalyzerPlugin
   CheckerDependencyHandlingAnalyzerPlugin
Index: clang/lib/Analysis/plugins/CMakeLists.txt
===
--- clang/lib/Analysis/plugins/CMakeLists.txt
+++ clang/lib/Analysis/plugins/CMakeLists.txt
@@ -1,4 +1,7 @@
-if(CLANG_ENABLE_STATIC_ANALYZER AND CLANG_PLUGIN_SUPPORT)
+# Since these do not specify a specific PLUGIN_TOOL (which could be clang or
+# clang-tidy), we cannot compile this unless the platform supports plugins with
+# undefined symbols, and cannot use it unless the user has opted for clang plugins).
+if(CLANG_ENABLE_STATIC_ANALYZER AND CLANG_PLUGIN_SUPPORT AND LLVM_ENABLE_PLUGINS)
   add_subdirectory(SampleAnalyzer)
   add_subdirectory(CheckerDependencyHandling)
   add_subdirectory(CheckerOptionHandling)
Index: clang/examples/PrintFunctionNames/CMakeLists.txt
===
--- clang/examples/PrintFunctionNames/CMakeLists.txt
+++ clang/examples/PrintFunctionNames/CMakeLists.txt
@@ -11,7 +11,7 @@
 
 add_llvm_library(PrintFunctionNames MODULE PrintFunctionNames.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/PluginsOrder/CMakeLists.txt
===
--- clang/examples/PluginsOrder/CMakeLists.txt
+++ clang/examples/PluginsOrder/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(PluginsOrder MODULE PluginsOrder.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/CallSuperAttribute/CMakeLists.txt
===
--- clang/examples/CallSuperAttribute/CMakeLists.txt
+++ clang/examples/CallSuperAttribute/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(CallSuperAttr MODULE CallSuperAttrInfo.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/CMakeLists.txt
===
--- clang/examples/CMakeLists.txt
+++ clang/examples/CMakeLists.txt
@@ -3,8 +3,10 @@
   set(EXCLUDE_FROM_ALL ON)
 endif()
 
-add_subdirectory(PrintFunctionNames)
-add_subdirectory(AnnotateFunctions)
-add_subdirectory(Attribute)
-add_subdirectory(CallSuperAttribute)
-add_subdirectory(PluginsOrder)
+if(CLANG_PLUGIN_SUPPORT)
+  add_subdirectory(PrintFunctionNames)
+  add_subdirectory(AnnotateFunctions)
+  add_subdirectory(Attribute)
+  add_subdirectory(CallSuperAttribute)
+  add_subdirectory(PluginsOrder)
+endif()
Index: clang/examples/Attribute/CMakeLists.txt
===
--- clang/examples/Attribute/CMakeLists.txt
+++ clang/examples/Attribute/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(Attribute MODULE Attribute.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   target_link_libraries(Attribute PRIVATE
 clangAST
 clangBasic
Index: clang/examples/AnnotateFunctions/CMakeLists.txt
===
--- clang/examples/AnnotateFunctions/CMakeLists.txt
+++ clang/examples/AnnotateFunctions/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(AnnotateFunctions MODULE AnnotateFunctions.cpp PLUGIN_TOOL clang)
 
-if(CLANG

[PATCH] D119591: clang-analyzer plugins require LLVM_ENABLE_PLUGINS also

2022-02-14 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash updated this revision to Diff 408491.
vtjnash added a comment.

cleanup


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119591/new/

https://reviews.llvm.org/D119591

Files:
  clang/CMakeLists.txt
  clang/examples/AnnotateFunctions/CMakeLists.txt
  clang/examples/Attribute/CMakeLists.txt
  clang/examples/CMakeLists.txt
  clang/examples/CallSuperAttribute/CMakeLists.txt
  clang/examples/PluginsOrder/CMakeLists.txt
  clang/examples/PrintFunctionNames/CMakeLists.txt
  clang/lib/Analysis/plugins/CMakeLists.txt
  clang/test/CMakeLists.txt

Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -145,8 +145,8 @@
   endif()
 endif()
 
-if (CLANG_ENABLE_STATIC_ANALYZER)
-  if (CLANG_PLUGIN_SUPPORT)
+if(CLANG_ENABLE_STATIC_ANALYZER)
+  if(CLANG_PLUGIN_SUPPORT AND LLVM_ENABLE_PLUGINS) # Determine if we built them
 list(APPEND CLANG_TEST_DEPS
   SampleAnalyzerPlugin
   CheckerDependencyHandlingAnalyzerPlugin
Index: clang/lib/Analysis/plugins/CMakeLists.txt
===
--- clang/lib/Analysis/plugins/CMakeLists.txt
+++ clang/lib/Analysis/plugins/CMakeLists.txt
@@ -1,4 +1,7 @@
-if(CLANG_ENABLE_STATIC_ANALYZER AND CLANG_PLUGIN_SUPPORT)
+# Since these do not specify a specific PLUGIN_TOOL (which could be clang or
+# clang-tidy), we cannot compile this unless the platform supports plugins with
+# undefined symbols, and cannot use it unless the user has opted for clang plugins).
+if(CLANG_ENABLE_STATIC_ANALYZER AND CLANG_PLUGIN_SUPPORT AND LLVM_ENABLE_PLUGINS)
   add_subdirectory(SampleAnalyzer)
   add_subdirectory(CheckerDependencyHandling)
   add_subdirectory(CheckerOptionHandling)
Index: clang/examples/PrintFunctionNames/CMakeLists.txt
===
--- clang/examples/PrintFunctionNames/CMakeLists.txt
+++ clang/examples/PrintFunctionNames/CMakeLists.txt
@@ -11,7 +11,7 @@
 
 add_llvm_library(PrintFunctionNames MODULE PrintFunctionNames.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/PluginsOrder/CMakeLists.txt
===
--- clang/examples/PluginsOrder/CMakeLists.txt
+++ clang/examples/PluginsOrder/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(PluginsOrder MODULE PluginsOrder.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/CallSuperAttribute/CMakeLists.txt
===
--- clang/examples/CallSuperAttribute/CMakeLists.txt
+++ clang/examples/CallSuperAttribute/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(CallSuperAttr MODULE CallSuperAttrInfo.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/CMakeLists.txt
===
--- clang/examples/CMakeLists.txt
+++ clang/examples/CMakeLists.txt
@@ -3,8 +3,10 @@
   set(EXCLUDE_FROM_ALL ON)
 endif()
 
-add_subdirectory(PrintFunctionNames)
-add_subdirectory(AnnotateFunctions)
-add_subdirectory(Attribute)
-add_subdirectory(CallSuperAttribute)
-add_subdirectory(PluginsOrder)
+if(CLANG_PLUGIN_SUPPORT)
+  add_subdirectory(PrintFunctionNames)
+  add_subdirectory(AnnotateFunctions)
+  add_subdirectory(Attribute)
+  add_subdirectory(CallSuperAttribute)
+  add_subdirectory(PluginsOrder)
+endif()
Index: clang/examples/Attribute/CMakeLists.txt
===
--- clang/examples/Attribute/CMakeLists.txt
+++ clang/examples/Attribute/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(Attribute MODULE Attribute.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   target_link_libraries(Attribute PRIVATE
 clangAST
 clangBasic
Index: clang/examples/AnnotateFunctions/CMakeLists.txt
===
--- clang/examples/AnnotateFunctions/CMakeLists.txt
+++ clang/examples/AnnotateFunctions/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(AnnotateFunctions MODULE AnnotateFunctions.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -476,9 +476,10 @@
 option(CLANG_BUILD_TOOLS
   "Build the Clang tools. If OFF, just generate build targets." ON)
 
+set(HAVE_CLANG_PLUGIN_SUPPORT LLVM_ENABLE_PLUGINS OR LLVM_EXPORT_SYMBOLS_FOR_PLUGINS)
 CMAKE_DEPEN

[PATCH] D119591: clang-analyzer plugins require LLVM_ENABLE_PLUGINS also

2022-02-14 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

We are not going to start exporting plugin support if the user explicitly 
disabled it with CLANG_PLUGIN_SUPPORT=OFF, but why is it trying to read that 
directory at all, when it should be disallowed by this PR unless 
CLANG_PLUGIN_SUPPORT=ON


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119591/new/

https://reviews.llvm.org/D119591

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


[PATCH] D119591: clang-analyzer plugins require LLVM_ENABLE_PLUGINS also

2022-02-14 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash updated this revision to Diff 408498.
vtjnash added a comment.

fixup


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119591/new/

https://reviews.llvm.org/D119591

Files:
  clang/CMakeLists.txt
  clang/examples/AnnotateFunctions/CMakeLists.txt
  clang/examples/Attribute/CMakeLists.txt
  clang/examples/CMakeLists.txt
  clang/examples/CallSuperAttribute/CMakeLists.txt
  clang/examples/PluginsOrder/CMakeLists.txt
  clang/examples/PrintFunctionNames/CMakeLists.txt
  clang/lib/Analysis/plugins/CMakeLists.txt
  clang/test/CMakeLists.txt

Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -145,8 +145,8 @@
   endif()
 endif()
 
-if (CLANG_ENABLE_STATIC_ANALYZER)
-  if (CLANG_PLUGIN_SUPPORT)
+if(CLANG_ENABLE_STATIC_ANALYZER)
+  if(CLANG_PLUGIN_SUPPORT AND LLVM_ENABLE_PLUGINS) # Determine if we built them
 list(APPEND CLANG_TEST_DEPS
   SampleAnalyzerPlugin
   CheckerDependencyHandlingAnalyzerPlugin
Index: clang/lib/Analysis/plugins/CMakeLists.txt
===
--- clang/lib/Analysis/plugins/CMakeLists.txt
+++ clang/lib/Analysis/plugins/CMakeLists.txt
@@ -1,4 +1,7 @@
-if(CLANG_ENABLE_STATIC_ANALYZER AND CLANG_PLUGIN_SUPPORT)
+# Since these do not specify a specific PLUGIN_TOOL (which could be clang or
+# clang-tidy), we cannot compile this unless the platform supports plugins with
+# undefined symbols, and cannot use it unless the user has opted for clang plugins).
+if(CLANG_ENABLE_STATIC_ANALYZER AND CLANG_PLUGIN_SUPPORT AND LLVM_ENABLE_PLUGINS)
   add_subdirectory(SampleAnalyzer)
   add_subdirectory(CheckerDependencyHandling)
   add_subdirectory(CheckerOptionHandling)
Index: clang/examples/PrintFunctionNames/CMakeLists.txt
===
--- clang/examples/PrintFunctionNames/CMakeLists.txt
+++ clang/examples/PrintFunctionNames/CMakeLists.txt
@@ -11,7 +11,7 @@
 
 add_llvm_library(PrintFunctionNames MODULE PrintFunctionNames.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/PluginsOrder/CMakeLists.txt
===
--- clang/examples/PluginsOrder/CMakeLists.txt
+++ clang/examples/PluginsOrder/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(PluginsOrder MODULE PluginsOrder.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/CallSuperAttribute/CMakeLists.txt
===
--- clang/examples/CallSuperAttribute/CMakeLists.txt
+++ clang/examples/CallSuperAttribute/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(CallSuperAttr MODULE CallSuperAttrInfo.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/CMakeLists.txt
===
--- clang/examples/CMakeLists.txt
+++ clang/examples/CMakeLists.txt
@@ -3,8 +3,10 @@
   set(EXCLUDE_FROM_ALL ON)
 endif()
 
-add_subdirectory(PrintFunctionNames)
-add_subdirectory(AnnotateFunctions)
-add_subdirectory(Attribute)
-add_subdirectory(CallSuperAttribute)
-add_subdirectory(PluginsOrder)
+if(CLANG_PLUGIN_SUPPORT)
+  add_subdirectory(PrintFunctionNames)
+  add_subdirectory(AnnotateFunctions)
+  add_subdirectory(Attribute)
+  add_subdirectory(CallSuperAttribute)
+  add_subdirectory(PluginsOrder)
+endif()
Index: clang/examples/Attribute/CMakeLists.txt
===
--- clang/examples/Attribute/CMakeLists.txt
+++ clang/examples/Attribute/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(Attribute MODULE Attribute.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   target_link_libraries(Attribute PRIVATE
 clangAST
 clangBasic
Index: clang/examples/AnnotateFunctions/CMakeLists.txt
===
--- clang/examples/AnnotateFunctions/CMakeLists.txt
+++ clang/examples/AnnotateFunctions/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(AnnotateFunctions MODULE AnnotateFunctions.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -476,9 +476,14 @@
 option(CLANG_BUILD_TOOLS
   "Build the Clang tools. If OFF, just generate build targets." ON)
 
+if(LLVM_ENABLE_PLUGINS OR LLVM_EXPORT_SYMBOLS_FOR_PLUGINS)
+  set(HAVE_CLANG_PLUGIN_SUPPORT ON)
+els

[PATCH] D119591: clang-analyzer plugins require LLVM_ENABLE_PLUGINS also

2022-02-16 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash updated this revision to Diff 409241.
vtjnash added a comment.

add one more missing case to check


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119591/new/

https://reviews.llvm.org/D119591

Files:
  clang/CMakeLists.txt
  clang/examples/AnnotateFunctions/CMakeLists.txt
  clang/examples/Attribute/CMakeLists.txt
  clang/examples/CMakeLists.txt
  clang/examples/CallSuperAttribute/CMakeLists.txt
  clang/examples/PluginsOrder/CMakeLists.txt
  clang/examples/PrintFunctionNames/CMakeLists.txt
  clang/lib/Analysis/plugins/CMakeLists.txt
  clang/test/CMakeLists.txt

Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -95,7 +95,7 @@
   )
 endif ()
 
-if (CLANG_BUILD_EXAMPLES)
+if(CLANG_BUILD_EXAMPLES AND CLANG_PLUGIN_SUPPORT)
   list(APPEND CLANG_TEST_DEPS
 Attribute
 AnnotateFunctions
@@ -145,8 +145,8 @@
   endif()
 endif()
 
-if (CLANG_ENABLE_STATIC_ANALYZER)
-  if (CLANG_PLUGIN_SUPPORT)
+if(CLANG_ENABLE_STATIC_ANALYZER)
+  if(CLANG_PLUGIN_SUPPORT AND LLVM_ENABLE_PLUGINS) # Determine if we built them
 list(APPEND CLANG_TEST_DEPS
   SampleAnalyzerPlugin
   CheckerDependencyHandlingAnalyzerPlugin
Index: clang/lib/Analysis/plugins/CMakeLists.txt
===
--- clang/lib/Analysis/plugins/CMakeLists.txt
+++ clang/lib/Analysis/plugins/CMakeLists.txt
@@ -1,4 +1,7 @@
-if(CLANG_ENABLE_STATIC_ANALYZER AND CLANG_PLUGIN_SUPPORT)
+# Since these do not specify a specific PLUGIN_TOOL (which could be clang or
+# clang-tidy), we cannot compile this unless the platform supports plugins with
+# undefined symbols, and cannot use it unless the user has opted for clang plugins).
+if(CLANG_ENABLE_STATIC_ANALYZER AND CLANG_PLUGIN_SUPPORT AND LLVM_ENABLE_PLUGINS)
   add_subdirectory(SampleAnalyzer)
   add_subdirectory(CheckerDependencyHandling)
   add_subdirectory(CheckerOptionHandling)
Index: clang/examples/PrintFunctionNames/CMakeLists.txt
===
--- clang/examples/PrintFunctionNames/CMakeLists.txt
+++ clang/examples/PrintFunctionNames/CMakeLists.txt
@@ -11,7 +11,7 @@
 
 add_llvm_library(PrintFunctionNames MODULE PrintFunctionNames.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/PluginsOrder/CMakeLists.txt
===
--- clang/examples/PluginsOrder/CMakeLists.txt
+++ clang/examples/PluginsOrder/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(PluginsOrder MODULE PluginsOrder.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/CallSuperAttribute/CMakeLists.txt
===
--- clang/examples/CallSuperAttribute/CMakeLists.txt
+++ clang/examples/CallSuperAttribute/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(CallSuperAttr MODULE CallSuperAttrInfo.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/CMakeLists.txt
===
--- clang/examples/CMakeLists.txt
+++ clang/examples/CMakeLists.txt
@@ -3,8 +3,10 @@
   set(EXCLUDE_FROM_ALL ON)
 endif()
 
-add_subdirectory(PrintFunctionNames)
-add_subdirectory(AnnotateFunctions)
-add_subdirectory(Attribute)
-add_subdirectory(CallSuperAttribute)
-add_subdirectory(PluginsOrder)
+if(CLANG_PLUGIN_SUPPORT)
+  add_subdirectory(PrintFunctionNames)
+  add_subdirectory(AnnotateFunctions)
+  add_subdirectory(Attribute)
+  add_subdirectory(CallSuperAttribute)
+  add_subdirectory(PluginsOrder)
+endif()
Index: clang/examples/Attribute/CMakeLists.txt
===
--- clang/examples/Attribute/CMakeLists.txt
+++ clang/examples/Attribute/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(Attribute MODULE Attribute.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   target_link_libraries(Attribute PRIVATE
 clangAST
 clangBasic
Index: clang/examples/AnnotateFunctions/CMakeLists.txt
===
--- clang/examples/AnnotateFunctions/CMakeLists.txt
+++ clang/examples/AnnotateFunctions/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(AnnotateFunctions MODULE AnnotateFunctions.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -476,

[PATCH] D119591: clang-analyzer plugins require LLVM_ENABLE_PLUGINS also

2022-02-16 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

Okay, this should work now for those cases! Sorry, I kept thinking it was 
clang/examples that was broken, and missed that it was clang/test that was 
failing, so I failed to see what I needed to fix there too, so that we were not 
trying to build the tests in configurations where the functionality is disabled.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119591/new/

https://reviews.llvm.org/D119591

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


[PATCH] D119591: clang-analyzer plugins require LLVM_ENABLE_PLUGINS also

2022-02-16 Thread Jameson Nash via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9d59cfc67ead: clang-analyzer plugins require 
LLVM_ENABLE_PLUGINS also (authored by vtjnash).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119591/new/

https://reviews.llvm.org/D119591

Files:
  clang/CMakeLists.txt
  clang/examples/AnnotateFunctions/CMakeLists.txt
  clang/examples/Attribute/CMakeLists.txt
  clang/examples/CMakeLists.txt
  clang/examples/CallSuperAttribute/CMakeLists.txt
  clang/examples/PluginsOrder/CMakeLists.txt
  clang/examples/PrintFunctionNames/CMakeLists.txt
  clang/lib/Analysis/plugins/CMakeLists.txt
  clang/test/CMakeLists.txt

Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -95,7 +95,7 @@
   )
 endif ()
 
-if (CLANG_BUILD_EXAMPLES)
+if(CLANG_BUILD_EXAMPLES AND CLANG_PLUGIN_SUPPORT)
   list(APPEND CLANG_TEST_DEPS
 Attribute
 AnnotateFunctions
@@ -145,8 +145,8 @@
   endif()
 endif()
 
-if (CLANG_ENABLE_STATIC_ANALYZER)
-  if (CLANG_PLUGIN_SUPPORT)
+if(CLANG_ENABLE_STATIC_ANALYZER)
+  if(CLANG_PLUGIN_SUPPORT AND LLVM_ENABLE_PLUGINS) # Determine if we built them
 list(APPEND CLANG_TEST_DEPS
   SampleAnalyzerPlugin
   CheckerDependencyHandlingAnalyzerPlugin
Index: clang/lib/Analysis/plugins/CMakeLists.txt
===
--- clang/lib/Analysis/plugins/CMakeLists.txt
+++ clang/lib/Analysis/plugins/CMakeLists.txt
@@ -1,4 +1,7 @@
-if(CLANG_ENABLE_STATIC_ANALYZER AND CLANG_PLUGIN_SUPPORT)
+# Since these do not specify a specific PLUGIN_TOOL (which could be clang or
+# clang-tidy), we cannot compile this unless the platform supports plugins with
+# undefined symbols, and cannot use it unless the user has opted for clang plugins).
+if(CLANG_ENABLE_STATIC_ANALYZER AND CLANG_PLUGIN_SUPPORT AND LLVM_ENABLE_PLUGINS)
   add_subdirectory(SampleAnalyzer)
   add_subdirectory(CheckerDependencyHandling)
   add_subdirectory(CheckerOptionHandling)
Index: clang/examples/PrintFunctionNames/CMakeLists.txt
===
--- clang/examples/PrintFunctionNames/CMakeLists.txt
+++ clang/examples/PrintFunctionNames/CMakeLists.txt
@@ -11,7 +11,7 @@
 
 add_llvm_library(PrintFunctionNames MODULE PrintFunctionNames.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/PluginsOrder/CMakeLists.txt
===
--- clang/examples/PluginsOrder/CMakeLists.txt
+++ clang/examples/PluginsOrder/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(PluginsOrder MODULE PluginsOrder.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/CallSuperAttribute/CMakeLists.txt
===
--- clang/examples/CallSuperAttribute/CMakeLists.txt
+++ clang/examples/CallSuperAttribute/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(CallSuperAttr MODULE CallSuperAttrInfo.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/examples/CMakeLists.txt
===
--- clang/examples/CMakeLists.txt
+++ clang/examples/CMakeLists.txt
@@ -3,8 +3,10 @@
   set(EXCLUDE_FROM_ALL ON)
 endif()
 
-add_subdirectory(PrintFunctionNames)
-add_subdirectory(AnnotateFunctions)
-add_subdirectory(Attribute)
-add_subdirectory(CallSuperAttribute)
-add_subdirectory(PluginsOrder)
+if(CLANG_PLUGIN_SUPPORT)
+  add_subdirectory(PrintFunctionNames)
+  add_subdirectory(AnnotateFunctions)
+  add_subdirectory(Attribute)
+  add_subdirectory(CallSuperAttribute)
+  add_subdirectory(PluginsOrder)
+endif()
Index: clang/examples/Attribute/CMakeLists.txt
===
--- clang/examples/Attribute/CMakeLists.txt
+++ clang/examples/Attribute/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(Attribute MODULE Attribute.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   target_link_libraries(Attribute PRIVATE
 clangAST
 clangBasic
Index: clang/examples/AnnotateFunctions/CMakeLists.txt
===
--- clang/examples/AnnotateFunctions/CMakeLists.txt
+++ clang/examples/AnnotateFunctions/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(AnnotateFunctions MODULE AnnotateFunctions.cpp PLUGIN_TOOL clang)
 
-if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
+if(WIN32 OR CYGWIN)
   set(LLVM_LINK_COMPONENTS
 Support
   )
Index: clang/CMakeLists.txt
===

[PATCH] D111100: enable plugins for clang-tidy

2022-02-17 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added inline comments.



Comment at: clang-tools-extra/test/CMakeLists.txt:91
+  if(TARGET CTTestTidyModule)
+  list(APPEND CLANG_TOOLS_TEST_DEPS CTTestTidyModule LLVMHello)
+  target_include_directories(CTTestTidyModule PUBLIC BEFORE 
"${CLANG_TOOLS_SOURCE_DIR}")

tstellar wrote:
> aaron.ballman wrote:
> > tstellar wrote:
> > > Our stand-alone builds for Fedora are still not working after this patch, 
> > > even with D119199.  Why is it necesary to add LLVMHello as a test 
> > > dependency?  Which test is using it?
> > CTestTidyModule.cpp is using it:
> > ```
> > // RUN: clang-tidy -checks='-*,mytest*' --list-checks -load 
> > %llvmshlibdir/CTTestTidyModule%pluginext -load 
> > %llvmshlibdir/LLVMHello%pluginext | FileCheck --check-prefix=CHECK-LIST %s
> > ```
> > I *think* this is testing that we can load a clang-tidy plugin and an llvm 
> > plugin at the same time and not hit conflicting symbols or other issues. If 
> > I'm correct, then I think that's useful test functionality, but I wouldn't 
> > describe it as critical, so I'd be fine if we dropped it for now to get 
> > this patch in, and then added the extra testing in a subsequent patch if we 
> > think it's necessary.
> OK, that does sound like a useful test.  I will spend some time investigating 
> how to make this work with stand-alone builds.
Yes, that is the purpose. It is only a test dependency, so we could prevent it 
from running these tests instead. However, in theory, it should have figured 
out the relative path to the llvm/ source directory in the repo and re-built 
this target it if required for the test and not already available (with 
D119199):
https://github.com/llvm/llvm-project/blob/27f72eb25e366cf6fd79ea7495fec5d926a5b895/clang-tools-extra/test/CMakeLists.txt#L92

As this seemed to be the way other subprojects were implementing it already:
https://github.com/llvm/llvm-project/blob/27f72eb25e366cf6fd79ea7495fec5d926a5b895/clang-tools-extra/clangd/unittests/CMakeLists.txt#L9


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

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


[PATCH] D88138: [NPM] Add target specific hook to add passes for New Pass Manager

2020-11-16 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

I think this, and similar recent commits, are causing the shared library builds 
to fail some tests if this code gets linked into libLLVM.so: 
https://bugs.llvm.org/show_bug.cgi?id=48181. I assume it might actually a bug 
in ld (GNU Binutils for Ubuntu 2.34), as I don't understand the linker behavior 
there?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88138/new/

https://reviews.llvm.org/D88138

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


[PATCH] D111100: enable plugins for clang-tidy

2021-10-04 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash created this revision.
Herald added a subscriber: mgorny.
vtjnash requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Fixes 32739


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D00

Files:
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp


Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -20,6 +20,7 @@
 #include "../GlobList.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/PluginLoader.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
Index: clang-tools-extra/clang-tidy/tool/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/tool/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/tool/CMakeLists.txt
@@ -29,11 +29,17 @@
   clangToolingCore
   )
 
+# Support plugins.
+if(CLANG_PLUGIN_SUPPORT)
+  set(support_plugins SUPPORT_PLUGINS)
+endif()
+
 add_clang_tool(clang-tidy
   ClangTidyToolMain.cpp
-  )
-add_dependencies(clang-tidy
+
+  DEPENDS
   clang-resource-headers
+  ${support_plugins}
   )
 clang_target_link_libraries(clang-tidy
   PRIVATE
@@ -50,6 +56,9 @@
   ${ALL_CLANG_TIDY_CHECKS}
   )
 
+if(CLANG_PLUGIN_SUPPORT)
+  export_executable_symbols_for_plugins(clang-tidy)
+endif()
 
 install(PROGRAMS clang-tidy-diff.py
   DESTINATION share/clang


Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -20,6 +20,7 @@
 #include "../GlobList.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/PluginLoader.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
Index: clang-tools-extra/clang-tidy/tool/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/tool/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/tool/CMakeLists.txt
@@ -29,11 +29,17 @@
   clangToolingCore
   )
 
+# Support plugins.
+if(CLANG_PLUGIN_SUPPORT)
+  set(support_plugins SUPPORT_PLUGINS)
+endif()
+
 add_clang_tool(clang-tidy
   ClangTidyToolMain.cpp
-  )
-add_dependencies(clang-tidy
+
+  DEPENDS
   clang-resource-headers
+  ${support_plugins}
   )
 clang_target_link_libraries(clang-tidy
   PRIVATE
@@ -50,6 +56,9 @@
   ${ALL_CLANG_TIDY_CHECKS}
   )
 
+if(CLANG_PLUGIN_SUPPORT)
+  export_executable_symbols_for_plugins(clang-tidy)
+endif()
 
 install(PROGRAMS clang-tidy-diff.py
   DESTINATION share/clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111100: enable plugins for clang-tidy

2021-11-03 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

bump? tagging some more people who seemed like possible reviewers. I realized 
my original list of candidates might have mostly been inactive people.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

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


[PATCH] D111100: enable plugins for clang-tidy

2021-11-16 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

Yes, this header does everything


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

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


[PATCH] D114571: add release notes, docs mention, and test example

2021-11-24 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash created this revision.
Herald added subscribers: arphaman, mgorny.
vtjnash requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114571

Files:
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
  clang-tools-extra/test/lit.cfg.py
  clang-tools-extra/test/lit.site.cfg.py.in

Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -4,6 +4,7 @@
 
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
@@ -11,6 +12,7 @@
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
+config.has_plugins = @LLVM_ENABLE_PLUGINS@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: clang-tools-extra/test/lit.cfg.py
===
--- clang-tools-extra/test/lit.cfg.py
+++ clang-tools-extra/test/lit.cfg.py
@@ -149,3 +149,5 @@
  "clangd", "benchmarks")
 config.substitutions.append(('%clangd-benchmark-dir',
  '%s' % (clangd_benchmarks_dir)))
+config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
+config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
Index: clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
@@ -0,0 +1,50 @@
+// REQUIRES: plugins
+// RUN: clang-tidy -checks='-*,mytest' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext | FileCheck %s
+// CHECK: Enabled checks:
+// CHECK-NEXT:mytest
+
+#include "clang-tidy/ClangTidy.h"
+#include "clang-tidy/ClangTidyCheck.h"
+#include "clang-tidy/ClangTidyModule.h"
+#include "clang-tidy/ClangTidyModuleRegistry.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang;
+using namespace clang::tidy;
+using namespace clang::ast_matchers;
+
+namespace {
+class MyTestCheck : public ClangTidyCheck {
+
+public:
+  MyTestCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+
+  //void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  //void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+
+private:
+};
+
+class CTTestModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck("mytest");
+  }
+};
+} // namespace
+
+namespace clang {
+namespace tidy {
+
+// Register the CTTestTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("mytest-module", "Adds my checks.");
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the CTTestModule.
+volatile int CTTestModuleAnchorSource = 0;
+
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/test/CMakeLists.txt
===
--- clang-tools-extra/test/CMakeLists.txt
+++ clang-tools-extra/test/CMakeLists.txt
@@ -17,6 +17,7 @@
 
 llvm_canonicalize_cmake_booleans(
   CLANG_TIDY_ENABLE_STATIC_ANALYZER
+  LLVM_ENABLE_PLUGINS
   )
 
 configure_lit_site_cfg(
@@ -89,3 +90,17 @@
 add_lit_testsuites(CLANG-EXTRA ${CMAKE_CURRENT_SOURCE_DIR}
   DEPENDS ${CLANG_TOOLS_TEST_DEPS}
   )
+
+llvm_add_library(
+CTTestTidyModule
+MODULE clang-tidy/CTTestTidyModule.cpp
+PLUGIN_TOOL clang-tidy
+DEPENDS clang-tidy-headers)
+
+target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}")
+
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+  set(LLVM_LINK_COMPONENTS
+Support
+  )
+endif()
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -218,6 +218,14 @@
 --list-checks  -
  List all enabled checks and exit. Use with
  -checks=* to list all available checks.
+-load=

[PATCH] D111100: enable plugins for clang-tidy

2021-11-24 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash updated this revision to Diff 389652.
vtjnash added a comment.
Herald added a subscriber: arphaman.

add release notes, docs mention, and test example


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

Files:
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
  clang-tools-extra/test/lit.cfg.py
  clang-tools-extra/test/lit.site.cfg.py.in

Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -4,6 +4,7 @@
 
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
@@ -11,6 +12,7 @@
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
+config.has_plugins = @LLVM_ENABLE_PLUGINS@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: clang-tools-extra/test/lit.cfg.py
===
--- clang-tools-extra/test/lit.cfg.py
+++ clang-tools-extra/test/lit.cfg.py
@@ -149,3 +149,5 @@
  "clangd", "benchmarks")
 config.substitutions.append(('%clangd-benchmark-dir',
  '%s' % (clangd_benchmarks_dir)))
+config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
+config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
Index: clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
@@ -0,0 +1,50 @@
+// REQUIRES: plugins
+// RUN: clang-tidy -checks='-*,mytest' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext | FileCheck %s
+// CHECK: Enabled checks:
+// CHECK-NEXT:mytest
+
+#include "clang-tidy/ClangTidy.h"
+#include "clang-tidy/ClangTidyCheck.h"
+#include "clang-tidy/ClangTidyModule.h"
+#include "clang-tidy/ClangTidyModuleRegistry.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang;
+using namespace clang::tidy;
+using namespace clang::ast_matchers;
+
+namespace {
+class MyTestCheck : public ClangTidyCheck {
+
+public:
+  MyTestCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+
+  //void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  //void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+
+private:
+};
+
+class CTTestModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck("mytest");
+  }
+};
+} // namespace
+
+namespace clang {
+namespace tidy {
+
+// Register the CTTestTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("mytest-module", "Adds my checks.");
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the CTTestModule.
+volatile int CTTestModuleAnchorSource = 0;
+
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/test/CMakeLists.txt
===
--- clang-tools-extra/test/CMakeLists.txt
+++ clang-tools-extra/test/CMakeLists.txt
@@ -17,6 +17,7 @@
 
 llvm_canonicalize_cmake_booleans(
   CLANG_TIDY_ENABLE_STATIC_ANALYZER
+  LLVM_ENABLE_PLUGINS
   )
 
 configure_lit_site_cfg(
@@ -89,3 +90,17 @@
 add_lit_testsuites(CLANG-EXTRA ${CMAKE_CURRENT_SOURCE_DIR}
   DEPENDS ${CLANG_TOOLS_TEST_DEPS}
   )
+
+llvm_add_library(
+CTTestTidyModule
+MODULE clang-tidy/CTTestTidyModule.cpp
+PLUGIN_TOOL clang-tidy
+DEPENDS clang-tidy-headers)
+
+target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}")
+
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+  set(LLVM_LINK_COMPONENTS
+Support
+  )
+endif()
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -218,6 +218,14 @@
 --list-checks  -
  List all enabled checks and exit. Use with
  -checks=* to list all availab

[PATCH] D111100: enable plugins for clang-tidy

2021-11-24 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash updated this revision to Diff 389653.
vtjnash added a comment.

add release notes, docs mention, and test example


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

Files:
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
  clang-tools-extra/test/lit.cfg.py
  clang-tools-extra/test/lit.site.cfg.py.in

Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -4,6 +4,7 @@
 
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
@@ -11,6 +12,7 @@
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
+config.has_plugins = @LLVM_ENABLE_PLUGINS@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: clang-tools-extra/test/lit.cfg.py
===
--- clang-tools-extra/test/lit.cfg.py
+++ clang-tools-extra/test/lit.cfg.py
@@ -149,3 +149,5 @@
  "clangd", "benchmarks")
 config.substitutions.append(('%clangd-benchmark-dir',
  '%s' % (clangd_benchmarks_dir)))
+config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
+config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
Index: clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
@@ -0,0 +1,50 @@
+// REQUIRES: plugins
+// RUN: clang-tidy -checks='-*,mytest' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext | FileCheck %s
+// CHECK: Enabled checks:
+// CHECK-NEXT:mytest
+
+#include "clang-tidy/ClangTidy.h"
+#include "clang-tidy/ClangTidyCheck.h"
+#include "clang-tidy/ClangTidyModule.h"
+#include "clang-tidy/ClangTidyModuleRegistry.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang;
+using namespace clang::tidy;
+using namespace clang::ast_matchers;
+
+namespace {
+class MyTestCheck : public ClangTidyCheck {
+
+public:
+  MyTestCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+
+  //void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  //void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+
+private:
+};
+
+class CTTestModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck("mytest");
+  }
+};
+} // namespace
+
+namespace clang {
+namespace tidy {
+
+// Register the CTTestTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("mytest-module", "Adds my checks.");
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the CTTestModule.
+volatile int CTTestModuleAnchorSource = 0;
+
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/test/CMakeLists.txt
===
--- clang-tools-extra/test/CMakeLists.txt
+++ clang-tools-extra/test/CMakeLists.txt
@@ -17,6 +17,7 @@
 
 llvm_canonicalize_cmake_booleans(
   CLANG_TIDY_ENABLE_STATIC_ANALYZER
+  LLVM_ENABLE_PLUGINS
   )
 
 configure_lit_site_cfg(
@@ -89,3 +90,17 @@
 add_lit_testsuites(CLANG-EXTRA ${CMAKE_CURRENT_SOURCE_DIR}
   DEPENDS ${CLANG_TOOLS_TEST_DEPS}
   )
+
+llvm_add_library(
+CTTestTidyModule
+MODULE clang-tidy/CTTestTidyModule.cpp
+PLUGIN_TOOL clang-tidy
+DEPENDS clang-tidy-headers)
+
+target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}")
+
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+  set(LLVM_LINK_COMPONENTS
+Support
+  )
+endif()
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -218,6 +218,14 @@
 --list-checks  -
  List all enabled checks and exit. Use with

[PATCH] D111100: enable plugins for clang-tidy

2021-11-24 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash updated this revision to Diff 389655.
vtjnash added a comment.

oops


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

Files:
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
  clang-tools-extra/test/lit.cfg.py
  clang-tools-extra/test/lit.site.cfg.py.in

Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -4,6 +4,7 @@
 
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
@@ -11,6 +12,7 @@
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
+config.has_plugins = @LLVM_ENABLE_PLUGINS@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: clang-tools-extra/test/lit.cfg.py
===
--- clang-tools-extra/test/lit.cfg.py
+++ clang-tools-extra/test/lit.cfg.py
@@ -149,3 +149,9 @@
  "clangd", "benchmarks")
 config.substitutions.append(('%clangd-benchmark-dir',
  '%s' % (clangd_benchmarks_dir)))
+config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
+config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
+
+# Plugins (loadable modules)
+if config.has_plugins and config.llvm_plugin_ext:
+config.available_features.add('plugins')
Index: clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
@@ -0,0 +1,50 @@
+// REQUIRES: plugins
+// RUN: clang-tidy -checks='-*,mytest' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext | FileCheck %s
+// CHECK: Enabled checks:
+// CHECK-NEXT:mytest
+
+#include "clang-tidy/ClangTidy.h"
+#include "clang-tidy/ClangTidyCheck.h"
+#include "clang-tidy/ClangTidyModule.h"
+#include "clang-tidy/ClangTidyModuleRegistry.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang;
+using namespace clang::tidy;
+using namespace clang::ast_matchers;
+
+namespace {
+class MyTestCheck : public ClangTidyCheck {
+
+public:
+  MyTestCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+
+  //void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  //void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+
+private:
+};
+
+class CTTestModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck("mytest");
+  }
+};
+} // namespace
+
+namespace clang {
+namespace tidy {
+
+// Register the CTTestTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("mytest-module", "Adds my checks.");
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the CTTestModule.
+volatile int CTTestModuleAnchorSource = 0;
+
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/test/CMakeLists.txt
===
--- clang-tools-extra/test/CMakeLists.txt
+++ clang-tools-extra/test/CMakeLists.txt
@@ -17,6 +17,7 @@
 
 llvm_canonicalize_cmake_booleans(
   CLANG_TIDY_ENABLE_STATIC_ANALYZER
+  LLVM_ENABLE_PLUGINS
   )
 
 configure_lit_site_cfg(
@@ -89,3 +90,17 @@
 add_lit_testsuites(CLANG-EXTRA ${CMAKE_CURRENT_SOURCE_DIR}
   DEPENDS ${CLANG_TOOLS_TEST_DEPS}
   )
+
+llvm_add_library(
+CTTestTidyModule
+MODULE clang-tidy/CTTestTidyModule.cpp
+PLUGIN_TOOL clang-tidy
+DEPENDS clang-tidy-headers)
+
+target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}")
+
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+  set(LLVM_LINK_COMPONENTS
+Support
+  )
+endif()
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -218,6 +218,14 @@
 --list-checks  -
  List all enabled checks and exit. Use with

[PATCH] D111100: enable plugins for clang-tidy

2021-11-24 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash updated this revision to Diff 389656.
vtjnash added a comment.

oops


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

Files:
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
  clang-tools-extra/test/lit.cfg.py
  clang-tools-extra/test/lit.site.cfg.py.in

Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -4,6 +4,7 @@
 
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
@@ -11,6 +12,7 @@
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
+config.has_plugins = @LLVM_ENABLE_PLUGINS@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: clang-tools-extra/test/lit.cfg.py
===
--- clang-tools-extra/test/lit.cfg.py
+++ clang-tools-extra/test/lit.cfg.py
@@ -149,3 +149,9 @@
  "clangd", "benchmarks")
 config.substitutions.append(('%clangd-benchmark-dir',
  '%s' % (clangd_benchmarks_dir)))
+config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
+config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
+
+# Plugins (loadable modules)
+if config.has_plugins and config.llvm_plugin_ext:
+config.available_features.add('plugins')
Index: clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
@@ -0,0 +1,50 @@
+// REQUIRES: plugins
+// RUN: clang-tidy -checks='-*,mytest' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext | FileCheck %s
+// CHECK: Enabled checks:
+// CHECK-NEXT:mytest
+
+#include "clang-tidy/ClangTidy.h"
+#include "clang-tidy/ClangTidyCheck.h"
+#include "clang-tidy/ClangTidyModule.h"
+#include "clang-tidy/ClangTidyModuleRegistry.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang;
+using namespace clang::tidy;
+using namespace clang::ast_matchers;
+
+namespace {
+class MyTestCheck : public ClangTidyCheck {
+
+public:
+  MyTestCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+
+  //void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  //void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+
+private:
+};
+
+class CTTestModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck("mytest");
+  }
+};
+} // namespace
+
+namespace clang {
+namespace tidy {
+
+// Register the CTTestTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("mytest-module", "Adds my checks.");
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the CTTestModule.
+volatile int CTTestModuleAnchorSource = 0;
+
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/test/CMakeLists.txt
===
--- clang-tools-extra/test/CMakeLists.txt
+++ clang-tools-extra/test/CMakeLists.txt
@@ -17,6 +17,7 @@
 
 llvm_canonicalize_cmake_booleans(
   CLANG_TIDY_ENABLE_STATIC_ANALYZER
+  LLVM_ENABLE_PLUGINS
   )
 
 configure_lit_site_cfg(
@@ -89,3 +90,17 @@
 add_lit_testsuites(CLANG-EXTRA ${CMAKE_CURRENT_SOURCE_DIR}
   DEPENDS ${CLANG_TOOLS_TEST_DEPS}
   )
+
+llvm_add_library(
+CTTestTidyModule
+MODULE clang-tidy/CTTestTidyModule.cpp
+PLUGIN_TOOL clang-tidy
+DEPENDS clang-tidy-headers)
+
+target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}")
+
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+  set(LLVM_LINK_COMPONENTS
+Support
+  )
+endif()
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -218,6 +218,14 @@
 --list-checks

[PATCH] D111100: enable plugins for clang-tidy

2021-11-24 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash updated this revision to Diff 389658.
vtjnash added a comment.

enable help


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

Files:
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
  clang-tools-extra/test/lit.cfg.py
  clang-tools-extra/test/lit.site.cfg.py.in

Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -4,6 +4,7 @@
 
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
@@ -11,6 +12,7 @@
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
+config.has_plugins = @LLVM_ENABLE_PLUGINS@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: clang-tools-extra/test/lit.cfg.py
===
--- clang-tools-extra/test/lit.cfg.py
+++ clang-tools-extra/test/lit.cfg.py
@@ -149,3 +149,9 @@
  "clangd", "benchmarks")
 config.substitutions.append(('%clangd-benchmark-dir',
  '%s' % (clangd_benchmarks_dir)))
+config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
+config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
+
+# Plugins (loadable modules)
+if config.has_plugins and config.llvm_plugin_ext:
+config.available_features.add('plugins')
Index: clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
@@ -0,0 +1,50 @@
+// REQUIRES: plugins
+// RUN: clang-tidy -checks='-*,mytest' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext | FileCheck %s
+// CHECK: Enabled checks:
+// CHECK-NEXT:mytest
+
+#include "clang-tidy/ClangTidy.h"
+#include "clang-tidy/ClangTidyCheck.h"
+#include "clang-tidy/ClangTidyModule.h"
+#include "clang-tidy/ClangTidyModuleRegistry.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang;
+using namespace clang::tidy;
+using namespace clang::ast_matchers;
+
+namespace {
+class MyTestCheck : public ClangTidyCheck {
+
+public:
+  MyTestCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+
+  //void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  //void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+
+private:
+};
+
+class CTTestModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck("mytest");
+  }
+};
+} // namespace
+
+namespace clang {
+namespace tidy {
+
+// Register the CTTestTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("mytest-module", "Adds my checks.");
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the CTTestModule.
+volatile int CTTestModuleAnchorSource = 0;
+
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/test/CMakeLists.txt
===
--- clang-tools-extra/test/CMakeLists.txt
+++ clang-tools-extra/test/CMakeLists.txt
@@ -17,6 +17,7 @@
 
 llvm_canonicalize_cmake_booleans(
   CLANG_TIDY_ENABLE_STATIC_ANALYZER
+  LLVM_ENABLE_PLUGINS
   )
 
 configure_lit_site_cfg(
@@ -89,3 +90,17 @@
 add_lit_testsuites(CLANG-EXTRA ${CMAKE_CURRENT_SOURCE_DIR}
   DEPENDS ${CLANG_TOOLS_TEST_DEPS}
   )
+
+llvm_add_library(
+CTTestTidyModule
+MODULE clang-tidy/CTTestTidyModule.cpp
+PLUGIN_TOOL clang-tidy
+DEPENDS clang-tidy-headers)
+
+target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}")
+
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+  set(LLVM_LINK_COMPONENTS
+Support
+  )
+endif()
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -218,6 +218,14 @@
 --list-checks 

[PATCH] D111100: enable plugins for clang-tidy

2021-11-24 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

This is probably just a draft, but please let me know what you think


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

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


[PATCH] D111100: enable plugins for clang-tidy

2021-11-30 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

There is clearly some more work to do to get the cmake file to be correct, but 
was hoping to check this looked like the direction you thought looked right for 
adding this test, since there isn't an obvious example to follow.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

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


[PATCH] D117895: address review feedback

2022-01-21 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash created this revision.
Herald added subscribers: carlosgalvezp, arphaman, mgorny.
vtjnash requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117895

Files:
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp

Index: clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
===
--- clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
+++ clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
@@ -1,7 +1,11 @@
 // REQUIRES: plugins
-// RUN: clang-tidy -checks='-*,mytest' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext | FileCheck %s
-// CHECK: Enabled checks:
-// CHECK-NEXT:mytest
+// RUN: clang-tidy -checks='-*,mytest*' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext -load %llvmshlibdir/LLVMHello%pluginext | FileCheck --check-prefix=CHECK-LIST %s
+// CHECK-LIST: Enabled checks:
+// CHECK-LIST-NEXT:mytest1
+// CHECK-LIST-NEXT:mytest2
+// RUN: clang-tidy -checks='-*,mytest*,misc-definitions-in-headers' -load %llvmshlibdir/CTTestTidyModule%pluginext /dev/null -- -xc 2>&1 | FileCheck %s
+// CHECK: 3 warnings generated.
+// CHECK-NEXT: warning: mytest success [misc-definitions-in-headers,mytest1,mytest2]
 
 #include "clang-tidy/ClangTidy.h"
 #include "clang-tidy/ClangTidyCheck.h"
@@ -21,8 +25,15 @@
   MyTestCheck(StringRef Name, ClangTidyContext *Context)
   : ClangTidyCheck(Name, Context) {}
 
-  //void registerMatchers(ast_matchers::MatchFinder *Finder) override;
-  //void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override {
+Finder->addMatcher(translationUnitDecl().bind("tu"), this);
+  }
+
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override {
+auto S = Result.Nodes.getNodeAs("tu");
+if (S)
+  diag("mytest success");
+  }
 
 private:
 };
@@ -30,21 +41,26 @@
 class CTTestModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
-CheckFactories.registerCheck("mytest");
+CheckFactories.registerCheck("mytest1");
+CheckFactories.registerCheck("mytest2");
+// intentionally collide with an existing test name, overriding it
+CheckFactories.registerCheck("misc-definitions-in-headers");
   }
 };
 } // namespace
 
-namespace clang {
-namespace tidy {
-
+namespace tidy1 {
 // Register the CTTestTidyModule using this statically initialized variable.
 static ClangTidyModuleRegistry::Add<::CTTestModule>
 X("mytest-module", "Adds my checks.");
+} // namespace tidy1
+
+namespace tidy2 {
+// intentionally collide with an existing test group name, merging with it
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("misc-module", "Adds miscellaneous lint checks.");
+} // namespace tidy2
 
 // This anchor is used to force the linker to link in the generated object file
 // and thus register the CTTestModule.
 volatile int CTTestModuleAnchorSource = 0;
-
-} // namespace tidy
-} // namespace clang
Index: clang-tools-extra/test/CMakeLists.txt
===
--- clang-tools-extra/test/CMakeLists.txt
+++ clang-tools-extra/test/CMakeLists.txt
@@ -86,7 +86,7 @@
 DEPENDS clang-tidy-headers)
 
 if(TARGET CTTestTidyModule)
-list(APPEND CLANG_TOOLS_TEST_DEPS CTTestTidyModule)
+list(APPEND CLANG_TOOLS_TEST_DEPS CTTestTidyModule LLVMHello)
 target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}")
 if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
   set(LLVM_LINK_COMPONENTS
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -220,10 +220,11 @@
  -checks=* to list all available checks.
 -load= -
  Load the dynamic object ``plugin``. This
- object should register new static analyzer or clang-tidy passes. Once loaded, the object
- will add new command line options to run
- various analyses. To see the new complete
- list of passes, use the
+ object should register new static analyzer
+ or clang-tidy passes. Once loaded, the
+ object will add new command line options
+   

[PATCH] D111100: enable plugins for clang-tidy

2022-01-21 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash updated this revision to Diff 401997.
vtjnash added a comment.

address review feedback


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

Files:
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
  clang-tools-extra/test/lit.cfg.py
  clang-tools-extra/test/lit.site.cfg.py.in

Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -4,6 +4,7 @@
 
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
@@ -11,6 +12,7 @@
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
+config.has_plugins = @LLVM_ENABLE_PLUGINS@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: clang-tools-extra/test/lit.cfg.py
===
--- clang-tools-extra/test/lit.cfg.py
+++ clang-tools-extra/test/lit.cfg.py
@@ -149,3 +149,9 @@
  "clangd", "benchmarks")
 config.substitutions.append(('%clangd-benchmark-dir',
  '%s' % (clangd_benchmarks_dir)))
+config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
+config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
+
+# Plugins (loadable modules)
+if config.has_plugins and config.llvm_plugin_ext:
+config.available_features.add('plugins')
Index: clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
@@ -0,0 +1,66 @@
+// REQUIRES: plugins
+// RUN: clang-tidy -checks='-*,mytest*' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext -load %llvmshlibdir/LLVMHello%pluginext | FileCheck --check-prefix=CHECK-LIST %s
+// CHECK-LIST: Enabled checks:
+// CHECK-LIST-NEXT:mytest1
+// CHECK-LIST-NEXT:mytest2
+// RUN: clang-tidy -checks='-*,mytest*,misc-definitions-in-headers' -load %llvmshlibdir/CTTestTidyModule%pluginext /dev/null -- -xc 2>&1 | FileCheck %s
+// CHECK: 3 warnings generated.
+// CHECK-NEXT: warning: mytest success [misc-definitions-in-headers,mytest1,mytest2]
+
+#include "clang-tidy/ClangTidy.h"
+#include "clang-tidy/ClangTidyCheck.h"
+#include "clang-tidy/ClangTidyModule.h"
+#include "clang-tidy/ClangTidyModuleRegistry.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang;
+using namespace clang::tidy;
+using namespace clang::ast_matchers;
+
+namespace {
+class MyTestCheck : public ClangTidyCheck {
+
+public:
+  MyTestCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override {
+Finder->addMatcher(translationUnitDecl().bind("tu"), this);
+  }
+
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override {
+auto S = Result.Nodes.getNodeAs("tu");
+if (S)
+  diag("mytest success");
+  }
+
+private:
+};
+
+class CTTestModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck("mytest1");
+CheckFactories.registerCheck("mytest2");
+// intentionally collide with an existing test name, overriding it
+CheckFactories.registerCheck("misc-definitions-in-headers");
+  }
+};
+} // namespace
+
+namespace tidy1 {
+// Register the CTTestTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("mytest-module", "Adds my checks.");
+} // namespace tidy1
+
+namespace tidy2 {
+// intentionally collide with an existing test group name, merging with it
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("misc-module", "Adds miscellaneous lint checks.");
+} // namespace tidy2
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the CTTestModule.
+volatile int CTTestModuleAnchorSource = 0;
Index: clang-tools-extra/test/CMakeLists.txt
===
--- clang-tools-extra/test/C

[PATCH] D117895: address review feedback

2022-01-21 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash abandoned this revision.
vtjnash added a comment.

arc error


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117895/new/

https://reviews.llvm.org/D117895

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


[PATCH] D111100: enable plugins for clang-tidy

2022-01-26 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

@aaron.ballman I think I incorporated all of your feedback. Is this okay for me 
to merge to main? I would like to get it in before the feature branch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

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


[PATCH] D111100: enable plugins for clang-tidy

2022-01-29 Thread Jameson Nash via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG36892727e4f1: enable plugins for clang-tidy (authored by 
vtjnash).

Changed prior to commit:
  https://reviews.llvm.org/D00?vs=401997&id=404294#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

Files:
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
  clang-tools-extra/test/lit.cfg.py
  clang-tools-extra/test/lit.site.cfg.py.in

Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -4,6 +4,7 @@
 
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
@@ -11,6 +12,7 @@
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
+config.has_plugins = @LLVM_ENABLE_PLUGINS@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: clang-tools-extra/test/lit.cfg.py
===
--- clang-tools-extra/test/lit.cfg.py
+++ clang-tools-extra/test/lit.cfg.py
@@ -149,3 +149,9 @@
  "clangd", "benchmarks")
 config.substitutions.append(('%clangd-benchmark-dir',
  '%s' % (clangd_benchmarks_dir)))
+config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
+config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
+
+# Plugins (loadable modules)
+if config.has_plugins and config.llvm_plugin_ext:
+config.available_features.add('plugins')
Index: clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
@@ -0,0 +1,66 @@
+// REQUIRES: plugins
+// RUN: clang-tidy -checks='-*,mytest*' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext -load %llvmshlibdir/LLVMHello%pluginext | FileCheck --check-prefix=CHECK-LIST %s
+// CHECK-LIST: Enabled checks:
+// CHECK-LIST-NEXT:mytest1
+// CHECK-LIST-NEXT:mytest2
+// RUN: clang-tidy -checks='-*,mytest*,misc-definitions-in-headers' -load %llvmshlibdir/CTTestTidyModule%pluginext /dev/null -- -xc 2>&1 | FileCheck %s
+// CHECK: 3 warnings generated.
+// CHECK-NEXT: warning: mytest success [misc-definitions-in-headers,mytest1,mytest2]
+
+#include "clang-tidy/ClangTidy.h"
+#include "clang-tidy/ClangTidyCheck.h"
+#include "clang-tidy/ClangTidyModule.h"
+#include "clang-tidy/ClangTidyModuleRegistry.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang;
+using namespace clang::tidy;
+using namespace clang::ast_matchers;
+
+namespace {
+class MyTestCheck : public ClangTidyCheck {
+
+public:
+  MyTestCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override {
+Finder->addMatcher(translationUnitDecl().bind("tu"), this);
+  }
+
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override {
+auto S = Result.Nodes.getNodeAs("tu");
+if (S)
+  diag("mytest success");
+  }
+
+private:
+};
+
+class CTTestModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck("mytest1");
+CheckFactories.registerCheck("mytest2");
+// intentionally collide with an existing test name, overriding it
+CheckFactories.registerCheck("misc-definitions-in-headers");
+  }
+};
+} // namespace
+
+namespace tidy1 {
+// Register the CTTestTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("mytest-module", "Adds my checks.");
+} // namespace tidy1
+
+namespace tidy2 {
+// intentionally collide with an existing test group name, merging with it
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("misc-module", "Adds miscellaneous lint checks.");
+} // namespace tidy2
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the CTTestModule.
+volatile int CTTestModuleAnchorSour

[PATCH] D111100: enable plugins for clang-tidy

2022-01-30 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

Yes, please push a revert so I can look later. Do you have a link to the 
buildbot configuration, so I can reproduce that?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

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


[PATCH] D111100: enable plugins for clang-tidy

2022-01-31 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

It looks like this is probably the first time that a test was written for a 
PLUGIN_TOOL, outside of the docs, so we are likely in new territory here :/

There seem to be a couple of paths forward:

1. disable the PLUGIN_TOOL option in cmake if the user has disabled the headers 
needed to make that usable to cmake
2. define the headers target unconditionally (as done by 
https://github.com/llvm/llvm-project/blob/ab3b89855c5318f0009e1f016ffe5b1483507fd0/clang/lib/Headers/CMakeLists.txt#L232)
3. disable the added test if the headers required to use plugins are disabled 
by the user


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

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


[PATCH] D111100: enable plugins for clang-tidy

2022-02-01 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash updated this revision to Diff 404993.
vtjnash added a comment.

- Reland "enable plugins for clang-tidy"
- fixup! Reland "enable plugins for clang-tidy": Disable the test if the user 
has disabled support for building it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

Files:
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
  clang-tools-extra/test/lit.cfg.py
  clang-tools-extra/test/lit.site.cfg.py.in

Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -4,6 +4,7 @@
 
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
@@ -11,6 +12,7 @@
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
+config.has_plugins = @LLVM_ENABLE_PLUGINS@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: clang-tools-extra/test/lit.cfg.py
===
--- clang-tools-extra/test/lit.cfg.py
+++ clang-tools-extra/test/lit.cfg.py
@@ -149,3 +149,9 @@
  "clangd", "benchmarks")
 config.substitutions.append(('%clangd-benchmark-dir',
  '%s' % (clangd_benchmarks_dir)))
+config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
+config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
+
+# Plugins (loadable modules)
+if config.has_plugins and config.llvm_plugin_ext:
+config.available_features.add('plugins')
Index: clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
@@ -0,0 +1,66 @@
+// REQUIRES: plugins
+// RUN: clang-tidy -checks='-*,mytest*' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext -load %llvmshlibdir/LLVMHello%pluginext | FileCheck --check-prefix=CHECK-LIST %s
+// CHECK-LIST: Enabled checks:
+// CHECK-LIST-NEXT:mytest1
+// CHECK-LIST-NEXT:mytest2
+// RUN: clang-tidy -checks='-*,mytest*,misc-definitions-in-headers' -load %llvmshlibdir/CTTestTidyModule%pluginext /dev/null -- -xc 2>&1 | FileCheck %s
+// CHECK: 3 warnings generated.
+// CHECK-NEXT: warning: mytest success [misc-definitions-in-headers,mytest1,mytest2]
+
+#include "clang-tidy/ClangTidy.h"
+#include "clang-tidy/ClangTidyCheck.h"
+#include "clang-tidy/ClangTidyModule.h"
+#include "clang-tidy/ClangTidyModuleRegistry.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang;
+using namespace clang::tidy;
+using namespace clang::ast_matchers;
+
+namespace {
+class MyTestCheck : public ClangTidyCheck {
+
+public:
+  MyTestCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override {
+Finder->addMatcher(translationUnitDecl().bind("tu"), this);
+  }
+
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override {
+auto S = Result.Nodes.getNodeAs("tu");
+if (S)
+  diag("mytest success");
+  }
+
+private:
+};
+
+class CTTestModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck("mytest1");
+CheckFactories.registerCheck("mytest2");
+// intentionally collide with an existing test name, overriding it
+CheckFactories.registerCheck("misc-definitions-in-headers");
+  }
+};
+} // namespace
+
+namespace tidy1 {
+// Register the CTTestTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("mytest-module", "Adds my checks.");
+} // namespace tidy1
+
+namespace tidy2 {
+// intentionally collide with an existing test group name, merging with it
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("misc-module", "Adds miscellaneous lint checks.");
+} // namespace tidy2
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the CTTestModule.
+volatile int CTTe

[PATCH] D111100: enable plugins for clang-tidy

2022-02-01 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

I decided it made the most sense to me to go with option 3, so this should be 
ready to land again.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

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


[PATCH] D111100: enable plugins for clang-tidy

2022-02-01 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash updated this revision to Diff 405105.
vtjnash added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

Files:
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
  clang-tools-extra/test/lit.cfg.py
  clang-tools-extra/test/lit.site.cfg.py.in

Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -4,6 +4,7 @@
 
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
@@ -11,6 +12,7 @@
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
+config.has_plugins = @LLVM_ENABLE_PLUGINS@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: clang-tools-extra/test/lit.cfg.py
===
--- clang-tools-extra/test/lit.cfg.py
+++ clang-tools-extra/test/lit.cfg.py
@@ -149,3 +149,9 @@
  "clangd", "benchmarks")
 config.substitutions.append(('%clangd-benchmark-dir',
  '%s' % (clangd_benchmarks_dir)))
+config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
+config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
+
+# Plugins (loadable modules)
+if config.has_plugins and config.llvm_plugin_ext:
+config.available_features.add('plugins')
Index: clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
@@ -0,0 +1,66 @@
+// REQUIRES: plugins
+// RUN: clang-tidy -checks='-*,mytest*' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext -load %llvmshlibdir/LLVMHello%pluginext | FileCheck --check-prefix=CHECK-LIST %s
+// CHECK-LIST: Enabled checks:
+// CHECK-LIST-NEXT:mytest1
+// CHECK-LIST-NEXT:mytest2
+// RUN: clang-tidy -checks='-*,mytest*,misc-definitions-in-headers' -load %llvmshlibdir/CTTestTidyModule%pluginext /dev/null -- -xc 2>&1 | FileCheck %s
+// CHECK: 3 warnings generated.
+// CHECK-NEXT: warning: mytest success [misc-definitions-in-headers,mytest1,mytest2]
+
+#include "clang-tidy/ClangTidy.h"
+#include "clang-tidy/ClangTidyCheck.h"
+#include "clang-tidy/ClangTidyModule.h"
+#include "clang-tidy/ClangTidyModuleRegistry.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang;
+using namespace clang::tidy;
+using namespace clang::ast_matchers;
+
+namespace {
+class MyTestCheck : public ClangTidyCheck {
+
+public:
+  MyTestCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override {
+Finder->addMatcher(translationUnitDecl().bind("tu"), this);
+  }
+
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override {
+auto S = Result.Nodes.getNodeAs("tu");
+if (S)
+  diag("mytest success");
+  }
+
+private:
+};
+
+class CTTestModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck("mytest1");
+CheckFactories.registerCheck("mytest2");
+// intentionally collide with an existing test name, overriding it
+CheckFactories.registerCheck("misc-definitions-in-headers");
+  }
+};
+} // namespace
+
+namespace tidy1 {
+// Register the CTTestTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("mytest-module", "Adds my checks.");
+} // namespace tidy1
+
+namespace tidy2 {
+// intentionally collide with an existing test group name, merging with it
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("misc-module", "Adds miscellaneous lint checks.");
+} // namespace tidy2
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the CTTestModule.
+volatile int CTTestModuleAnchorSource = 0;
Index: clang-tools-extra/test/CMakeLists.txt
===
--- clang-to

[PATCH] D111100: enable plugins for clang-tidy

2022-02-01 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash closed this revision.
vtjnash added a comment.

Closed by rG84f137a590e7de25c4105303e5938c40566c2dfb 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

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


[PATCH] D119199: replace clang LLVM_ENABLE_PLUGINS -> CLANG_PLUGIN_SUPPORT in tests

2022-02-22 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

Is that a bug in clang or in MSVC2019? We expected that CLANG_PLUGIN_SUPPORT=ON 
can expose problems with the Windows linker, and we add new tests here for 
verifying that configuration is functioning as expected. You might need to 
disable CLANG_PLUGIN_SUPPORT on that target?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119199/new/

https://reviews.llvm.org/D119199

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


[PATCH] D120301: clang-tools-extra: Make test dependency on LLVMHello optional

2022-02-25 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a subscriber: MaskRay.
vtjnash added a comment.

Seems extra complexity, and less desirable to lose test coverage, when it seems 
the option may already be unreliable and soon to be deprecated by 
https://reviews.llvm.org/D119383. @MaskRay is that accurate?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120301/new/

https://reviews.llvm.org/D120301

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


[PATCH] D111100: enable plugins for clang-tidy

2021-12-08 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash updated this revision to Diff 392835.
vtjnash added a comment.

  fix cmake


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

Files:
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
  clang-tools-extra/test/lit.cfg.py
  clang-tools-extra/test/lit.site.cfg.py.in

Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -4,6 +4,7 @@
 
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
@@ -11,6 +12,7 @@
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
+config.has_plugins = @LLVM_ENABLE_PLUGINS@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: clang-tools-extra/test/lit.cfg.py
===
--- clang-tools-extra/test/lit.cfg.py
+++ clang-tools-extra/test/lit.cfg.py
@@ -149,3 +149,9 @@
  "clangd", "benchmarks")
 config.substitutions.append(('%clangd-benchmark-dir',
  '%s' % (clangd_benchmarks_dir)))
+config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
+config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
+
+# Plugins (loadable modules)
+if config.has_plugins and config.llvm_plugin_ext:
+config.available_features.add('plugins')
Index: clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
@@ -0,0 +1,50 @@
+// REQUIRES: plugins
+// RUN: clang-tidy -checks='-*,mytest' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext | FileCheck %s
+// CHECK: Enabled checks:
+// CHECK-NEXT:mytest
+
+#include "clang-tidy/ClangTidy.h"
+#include "clang-tidy/ClangTidyCheck.h"
+#include "clang-tidy/ClangTidyModule.h"
+#include "clang-tidy/ClangTidyModuleRegistry.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang;
+using namespace clang::tidy;
+using namespace clang::ast_matchers;
+
+namespace {
+class MyTestCheck : public ClangTidyCheck {
+
+public:
+  MyTestCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+
+  //void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  //void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+
+private:
+};
+
+class CTTestModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck("mytest");
+  }
+};
+} // namespace
+
+namespace clang {
+namespace tidy {
+
+// Register the CTTestTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("mytest-module", "Adds my checks.");
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the CTTestModule.
+volatile int CTTestModuleAnchorSource = 0;
+
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/test/CMakeLists.txt
===
--- clang-tools-extra/test/CMakeLists.txt
+++ clang-tools-extra/test/CMakeLists.txt
@@ -17,6 +17,7 @@
 
 llvm_canonicalize_cmake_booleans(
   CLANG_TIDY_ENABLE_STATIC_ANALYZER
+  LLVM_ENABLE_PLUGINS
   )
 
 configure_lit_site_cfg(
@@ -78,6 +79,22 @@
   endif()
 endforeach()
 
+llvm_add_library(
+CTTestTidyModule
+MODULE clang-tidy/CTTestTidyModule.cpp
+PLUGIN_TOOL clang-tidy
+DEPENDS clang-tidy-headers)
+
+if(TARGET CTTestTidyModule)
+list(APPEND CLANG_TOOLS_TEST_DEPS CTTestTidyModule)
+target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}")
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+  set(LLVM_LINK_COMPONENTS
+Support
+  )
+endif()
+endif()
+
 add_lit_testsuite(check-clang-tools "Running the Clang extra tools' regression tests"
   ${CMAKE_CURRENT_BINARY_DIR}
   DEPENDS ${CLANG_TOOLS_TEST_DEPS}
Index: clang-tools-extra/docs/clang-tidy/index.rst
===

[PATCH] D111100: enable plugins for clang-tidy

2021-12-16 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

Thanks! I will work on making those changes




Comment at: clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp:24-25
+
+  //void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  //void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+

aaron.ballman wrote:
> Shouldn't these functions be overloaded? We don't need it to be particularly 
> functional, but the plugin should demonstrate that it works and can be run by 
> clang-tidy (not just loaded and listed as a check).
I figured that is guaranteed by the C++ linker, if it can successfully list the 
check, so I didn't think it seemed essential to test for that also. I put these 
here mostly just to help anyone copying the file to getting started with 
adopting it to their use case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

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


[PATCH] D111100: enable plugins for clang-tidy

2021-10-14 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

bump?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

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


[PATCH] D111100: enable plugins for clang-tidy

2021-10-21 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

bump?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D00/new/

https://reviews.llvm.org/D00

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