-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30886 from jbytheway/custom_clang_tidy
Custom clang tidy plugin
- Loading branch information
Showing
17 changed files
with
505 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
include(ExternalProject) | ||
|
||
find_package(LLVM REQUIRED CONFIG) | ||
find_package(Clang REQUIRED CONFIG) | ||
|
||
add_library( | ||
CataAnalyzerPlugin MODULE | ||
CataTidyModule.cpp NoLongCheck.cpp) | ||
|
||
target_include_directories( | ||
CataAnalyzerPlugin SYSTEM PRIVATE | ||
${LLVM_INCLUDE_DIRS} ${CLANG_INCLUDE_DIRS}) | ||
|
||
if ("${CATA_CLANG_TIDY_INCLUDE_DIR}" STREQUAL "") | ||
SET(ctps_releases | ||
https://github.com/jbytheway/clang-tidy-plugin-support/releases/download) | ||
SET(ctps_version llvm-8.0.1-r12) | ||
SET(ctps_src | ||
${CMAKE_CURRENT_BINARY_DIR}/clang-tidy-plugin-support) | ||
|
||
ExternalProject_Add( | ||
clang-tidy-plugin-support | ||
URL ${ctps_releases}/${ctps_version}/clang-tidy-plugin-support-${ctps_version}.tar.xz | ||
URL_HASH SHA256=00ffab0df11250f394830735514c62ae787bd2eb6eb9d5e97471206d270c54e2 | ||
SOURCE_DIR ${ctps_src} | ||
CONFIGURE_COMMAND "" | ||
BUILD_COMMAND "" | ||
INSTALL_COMMAND "" | ||
TEST_COMMAND "" | ||
) | ||
|
||
add_dependencies(CataAnalyzerPlugin clang-tidy-plugin-support) | ||
target_include_directories( | ||
CataAnalyzerPlugin SYSTEM PRIVATE ${ctps_src}/include) | ||
else() | ||
target_include_directories( | ||
CataAnalyzerPlugin SYSTEM PRIVATE ${CATA_CLANG_TIDY_INCLUDE_DIR}) | ||
endif() | ||
|
||
target_compile_definitions( | ||
CataAnalyzerPlugin PRIVATE ${LLVM_DEFINITIONS}) | ||
|
||
# We need to turn off exceptions and RTTI to match the LLVM build. | ||
# I feel there ought to be a way to extract these flags from the | ||
# LLVMConfig.cmake as we have done for e.g. LLVM_INCLUDE_DIRS above, but I | ||
# haven't found one. | ||
if(MSVC) | ||
else() | ||
target_compile_options( | ||
CataAnalyzerPlugin PRIVATE -fno-exceptions -fno-rtti) | ||
endif() | ||
|
||
configure_file(test/lit.site.cfg.in test/lit.site.cfg @ONLY) | ||
configure_file(test/.clang-tidy test/.clang-tidy COPYONLY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "ClangTidy.h" | ||
#include "ClangTidyModule.h" | ||
#include "ClangTidyModuleRegistry.h" | ||
#include "NoLongCheck.h" | ||
|
||
namespace clang | ||
{ | ||
namespace tidy | ||
{ | ||
namespace cata | ||
{ | ||
|
||
class CataModule : public ClangTidyModule | ||
{ | ||
public: | ||
void addCheckFactories( ClangTidyCheckFactories &CheckFactories ) override { | ||
CheckFactories.registerCheck<NoLongCheck>( "cata-no-long" ); | ||
} | ||
}; | ||
|
||
} // namespace cata | ||
|
||
// Register the MiscTidyModule using this statically initialized variable. | ||
static ClangTidyModuleRegistry::Add<cata::CataModule> | ||
X( "cata-module", "Adds Cataclysm-DDA checks." ); | ||
|
||
} // namespace tidy | ||
} // namespace clang |
Oops, something went wrong.