Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[analyzer] Add a test for plugins using checker dependencies
Also, I moved the existing analyzer plugin to test/ as well, in order not to give the illusion that the analyzer supports plugins -- it's capable of handling them, but does not _support_ them. Differential Revision: https://reviews.llvm.org/D59464 llvm-svn: 360799
- Loading branch information
Kristof Umann
committed
May 15, 2019
1 parent
1ca0499
commit 47241aa
Showing
11 changed files
with
89 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
add_subdirectory(SampleAnalyzer) | ||
add_subdirectory(CheckerDependencyHandling) | ||
|
||
set(CLANG_ANALYZER_PLUGIN_DEPS | ||
SampleAnalyzerPlugin | ||
CheckerDependencyHandlingAnalyzerPlugin | ||
) | ||
|
||
add_custom_target(clang-analyzer-plugin | ||
DEPENDS ${CLANG_ANALYZER_PLUGIN_DEPS}) |
11 changes: 11 additions & 0 deletions
11
clang/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
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,11 @@ | ||
set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/CheckerDependencyHandlingAnalyzerPlugin.exports) | ||
add_llvm_library(CheckerDependencyHandlingAnalyzerPlugin MODULE CheckerDependencyHandling.cpp PLUGIN_TOOL clang) | ||
|
||
if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN)) | ||
target_link_libraries(CheckerDependencyHandlingAnalyzerPlugin PRIVATE | ||
clangAnalysis | ||
clangAST | ||
clangStaticAnalyzerCore | ||
LLVMSupport | ||
) | ||
endif() |
28 changes: 28 additions & 0 deletions
28
clang/test/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandling.cpp
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 "clang/StaticAnalyzer/Core/BugReporter/BugType.h" | ||
#include "clang/StaticAnalyzer/Core/Checker.h" | ||
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" | ||
#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h" | ||
|
||
using namespace clang; | ||
using namespace ento; | ||
|
||
namespace { | ||
struct Dependency : public Checker<check::BeginFunction> { | ||
void checkBeginFunction(CheckerContext &Ctx) const {} | ||
}; | ||
struct DependendentChecker : public Checker<check::BeginFunction> { | ||
void checkBeginFunction(CheckerContext &Ctx) const {} | ||
}; | ||
} // end anonymous namespace | ||
|
||
// Register plugin! | ||
extern "C" void clang_registerCheckers(CheckerRegistry ®istry) { | ||
registry.addChecker<Dependency>("example.Dependency", "", ""); | ||
registry.addChecker<DependendentChecker>("example.DependendentChecker", "", | ||
""); | ||
|
||
registry.addDependency("example.DependendentChecker", "example.Dependency"); | ||
} | ||
|
||
extern "C" const char clang_analyzerAPIVersionString[] = | ||
CLANG_ANALYZER_API_VERSION_STRING; |
File renamed without changes.
File renamed without changes.
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
2 changes: 2 additions & 0 deletions
2
clang/test/Analysis/plugins/SampleAnalyzer/SampleAnalyzerPlugin.exports
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,2 @@ | ||
clang_registerCheckers | ||
clang_analyzerAPIVersionString |
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