<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 12 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Courier New";}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Hi, this commit also broke our internal bot for a different reason:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Courier New";color:#333333">FAILED: /usr/lib/ccache/clang++ -DGTEST_HAS_RTTI=0 -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_LANG_CXX11=1 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
-D__STDC_LIMIT_MACROS -Itools/clang/unittests/StaticAnalyzer -I/home/siadmin/jenkins/w/opensource/opensource_build/llvm/tools/clang/unittests/StaticAnalyzer -I/home/siadmin/jenkins/w/opensource/opensource_build/llvm/tools/clang/include -Itools/clang/include
-Iinclude -I/home/siadmin/jenkins/w/opensource/opensource_build/llvm/include -I/home/siadmin/jenkins/w/opensource/opensource_build/llvm/utils/unittest/googletest/include -I/home/siadmin/jenkins/w/opensource/opensource_build/llvm/utils/unittest/googlemock/include
-fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion
-fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -UNDEBUG -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments -fno-exceptions -fno-rtti -MMD -MT tools/clang/unittests/StaticAnalyzer/CMakeFiles/StaticAnalysisTests.dir/RegisterCustomCheckersTest.cpp.o
-MF tools/clang/unittests/StaticAnalyzer/CMakeFiles/StaticAnalysisTests.dir/RegisterCustomCheckersTest.cpp.o.d -o tools/clang/unittests/StaticAnalyzer/CMakeFiles/StaticAnalysisTests.dir/RegisterCustomCheckersTest.cpp.o -c /home/siadmin/jenkins/w/opensource/opensource_build/llvm/tools/clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Courier New";color:#333333">/home/siadmin/jenkins/w/opensource/opensource_build/llvm/tools/clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp:64:12: error: no viable conversion from
'unique_ptr<clang::ento::AnalysisASTConsumer>' to 'unique_ptr<clang::ASTConsumer>'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Courier New";color:#333333"> return AnalysisConsumer;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Courier New";color:#333333"> ^~~~~~~~~~~~~~~~<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Courier New";color:#333333">/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/unique_ptr.h:157:17: note: candidate constructor not viable: no known conversion from 'std::unique_ptr<AnalysisASTConsumer>'
to 'nullptr_t' for 1st argument<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Courier New";color:#333333"> constexpr unique_ptr(nullptr_t) noexcept : unique_ptr() { }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Courier New";color:#333333"> ^<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Courier New";color:#333333">/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/unique_ptr.h:160:7: note: candidate constructor not viable: no known conversion from 'std::unique_ptr<AnalysisASTConsumer>'
to 'std::unique_ptr<clang::ASTConsumer, std::default_delete<clang::ASTConsumer> > &&' for 1st argument<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Courier New";color:#333333"> unique_ptr(unique_ptr&& __u) noexcept<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Courier New";color:#333333"> ^<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Courier New";color:#333333">/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/unique_ptr.h:169:2: note: candidate constructor [with _Up = clang::ento::AnalysisASTConsumer,
_Ep = std::default_delete<clang::ento::AnalysisASTConsumer>, $2 = void] not viable: no known conversion from 'std::unique_ptr<AnalysisASTConsumer>' to 'unique_ptr<clang::ento::AnalysisASTConsumer, std::default_delete<clang::ento::AnalysisASTConsumer> > &&'
for 1st argument<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Courier New";color:#333333"> unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Courier New";color:#333333"> ^<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Courier New";color:#333333">/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/unique_ptr.h:273:7: note: candidate constructor not viable: no known conversion from 'std::unique_ptr<AnalysisASTConsumer>'
to 'const std::unique_ptr<clang::ASTConsumer, std::default_delete<clang::ASTConsumer> > &' for 1st argument<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Courier New";color:#333333"> unique_ptr(const unique_ptr&) = delete;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Courier New";color:#333333"> ^<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Courier New";color:#333333">/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/unique_ptr.h:176:2: note: candidate template ignored: could not match 'auto_ptr' against 'unique_ptr'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Courier New";color:#333333"> unique_ptr(auto_ptr<_Up>&& __u) noexcept;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Courier New";color:#333333"> ^<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Courier New";color:#333333">1 error generated.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Douglas Yung<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> cfe-commits [mailto:cfe-commits-bounces@lists.llvm.org]
<b>On Behalf Of </b>Artem Belevich via cfe-commits<br>
<b>Sent:</b> Wednesday, June 27, 2018 14:30<br>
<b>To:</b> Alexander Kornienko<br>
<b>Cc:</b> cfe-commits<br>
<b>Subject:</b> Re: r335740 - [analyzer] Allow registering custom statically-linked analyzer checkers<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Verdana","sans-serif"">FYI,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Verdana","sans-serif""><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Verdana","sans-serif"">This commit breaks clang tests. It appears that StaticAnalysisTests misses dependency on clangFrontend.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Verdana","sans-serif""><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Verdana","sans-serif"">--Artem<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Verdana","sans-serif""><o:p> </o:p></span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"">[60/134] Linking CXX executable tools/clang/unittests/StaticAnalyzer/StaticAnalysisTests</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"">FAILED: tools/clang/unittests/StaticAnalyzer/StaticAnalysisTests </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"">: && /usr/local/google/home/tra/local/clang/bin/clang++ -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -Wall -Wextra
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -fno-common -Woverloaded-virtual -Wno-nested-anon-types
-g -fuse-ld=lld -Xlinker --gdb-index -fuse-ld=lld -Wl,--color-diagnostics -Wl,-allow-shlib-undefined tools/clang/unittests/StaticAnalyzer/CMakeFiles/StaticAnalysisTests.dir/AnalyzerOptionsTest.cpp.o tools/clang/unittests/StaticAnalyzer/CMakeFiles/StaticAnalysisTests.dir/RegisterCustomCheckersTest.cpp.o
-o tools/clang/unittests/StaticAnalyzer/StaticAnalysisTests lib/libLLVMSupport.so.7svn -lpthread lib/libgtest_main.so.7svn lib/libgtest.so.7svn -lpthread lib/libclangBasic.so.7svn lib/libclangAnalysis.so.7svn lib/libclangStaticAnalyzerCore.so.7svn lib/libclangStaticAnalyzerFrontend.so.7svn
lib/libclangTooling.so.7svn -Wl,-rpath,/usr/local/google/home/tra/work/llvm/build/release+assert/lib && :</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"">/usr/local/google/home/tra/local/clang/bin/ld.lld: error: undefined symbol: clang::FrontendAction::FrontendAction()</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"">>>> referenced by FrontendAction.h:235 (/usr/local/google/home/tra/work/llvm/repo/clang/include/clang/Frontend/FrontendAction.h:235)</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"">>>> tools/clang/unittests/StaticAnalyzer/CMakeFiles/StaticAnalysisTests.dir/RegisterCustomCheckersTest.cpp.o:(clang::ASTFrontendAction::ASTFrontendAction())</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"">/usr/local/google/home/tra/local/clang/bin/ld.lld: error: undefined symbol: vtable for clang::ASTFrontendAction</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"">>>> referenced by FrontendAction.h:235 (/usr/local/google/home/tra/work/llvm/repo/clang/include/clang/Frontend/FrontendAction.h:235)</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"">>>> tools/clang/unittests/StaticAnalyzer/CMakeFiles/StaticAnalysisTests.dir/RegisterCustomCheckersTest.cpp.o:(clang::ASTFrontendAction::ASTFrontendAction())</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"">/usr/local/google/home/tra/local/clang/bin/ld.lld: error: undefined symbol: clang::FrontendAction::~FrontendAction()</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"">>>> referenced by FrontendAction.h:225 (/usr/local/google/home/tra/work/llvm/repo/clang/include/clang/Frontend/FrontendAction.h:225)</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"">>>> tools/clang/unittests/StaticAnalyzer/CMakeFiles/StaticAnalysisTests.dir/RegisterCustomCheckersTest.cpp.o:(clang::ASTFrontendAction::~ASTFrontendAction())</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"">/usr/local/google/home/tra/local/clang/bin/ld.lld: error: undefined symbol: clang::PCHContainerOperations::PCHContainerOperations()</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"">>>> referenced by new_allocator.h:136 (/usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/ext/new_allocator.h:136)</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"">>>> tools/clang/unittests/StaticAnalyzer/CMakeFiles/StaticAnalysisTests.dir/RegisterCustomCheckersTest.cpp.o:(void __gnu_cxx::new_allocator<clang::PCHContainerOperations>::construct<clang::PCHContainerOperations>(clang::PCHContainerOperations*))</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"">/usr/local/google/home/tra/local/clang/bin/ld.lld: error: undefined symbol: clang::ASTFrontendAction::ExecuteAction()</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"">>>> referenced by RegisterCustomCheckersTest.cpp</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"">>>> tools/clang/unittests/StaticAnalyzer/CMakeFiles/StaticAnalysisTests.dir/RegisterCustomCheckersTest.cpp.o:(vtable for clang::ento::(anonymous namespace)::TestAction)</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"">/usr/local/google/home/tra/local/clang/bin/ld.lld: error: undefined symbol: clang::FrontendAction::shouldEraseOutputFiles()</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"">>>> referenced by RegisterCustomCheckersTest.cpp</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"">>>> tools/clang/unittests/StaticAnalyzer/CMakeFiles/StaticAnalysisTests.dir/RegisterCustomCheckersTest.cpp.o:(vtable for clang::ento::(anonymous namespace)::TestAction)</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"">clang: error: linker command failed with exit code 1 (use -v to see invocation)</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Verdana","sans-serif""><o:p> </o:p></span></p>
</div>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Wed, Jun 27, 2018 at 8:00 AM Alexander Kornienko via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">Author: alexfh<br>
Date: Wed Jun 27 07:56:12 2018<br>
New Revision: 335740<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=335740&view=rev" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=335740&view=rev</a><br>
Log:<br>
[analyzer] Allow registering custom statically-linked analyzer checkers<br>
<br>
Summary:<br>
Add an extension point to allow registration of statically-linked Clang Static<br>
Analyzer checkers that are not a part of the Clang tree. This extension point<br>
employs the mechanism used when checkers are registered from dynamically loaded<br>
plugins.<br>
<br>
Reviewers: george.karpenkov, NoQ, xazax.hun, dcoughlin<br>
<br>
Reviewed By: george.karpenkov<br>
<br>
Subscribers: mgorny, mikhail.ramalho, rnkovacs, xazax.hun, szepet, a.sidorin, cfe-commits<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D45718" target="_blank">
https://reviews.llvm.org/D45718</a><br>
<br>
Added:<br>
cfe/trunk/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp<br>
Modified:<br>
cfe/trunk/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h<br>
cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h<br>
cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp<br>
cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp<br>
cfe/trunk/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp<br>
cfe/trunk/unittests/StaticAnalyzer/CMakeLists.txt<br>
<br>
Modified: cfe/trunk/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h?rev=335740&r1=335739&r2=335740&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h?rev=335740&r1=335739&r2=335740&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h (original)<br>
+++ cfe/trunk/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h Wed Jun 27 07:56:12 2018<br>
@@ -17,6 +17,7 @@<br>
<br>
#include "clang/AST/ASTConsumer.h"<br>
#include "clang/Basic/LLVM.h"<br>
+#include <functional><br>
#include <memory><br>
<br>
namespace clang {<br>
@@ -29,10 +30,24 @@ class CompilerInstance;<br>
namespace ento {<br>
class PathDiagnosticConsumer;<br>
class CheckerManager;<br>
+class CheckerRegistry;<br>
<br>
class AnalysisASTConsumer : public ASTConsumer {<br>
public:<br>
virtual void AddDiagnosticConsumer(PathDiagnosticConsumer *Consumer) = 0;<br>
+<br>
+ /// This method allows registering statically linked custom checkers that are<br>
+ /// not a part of the Clang tree. It employs the same mechanism that is used<br>
+ /// by plugins.<br>
+ ///<br>
+ /// Example:<br>
+ ///<br>
+ /// Consumer->AddCheckerRegistrationFn([] (CheckerRegistry& Registry) {<br>
+ /// Registry.addChecker<MyCustomChecker>("example.MyCustomChecker",<br>
+ /// "Description");<br>
+ /// });<br>
+ virtual void<br>
+ AddCheckerRegistrationFn(std::function<void(CheckerRegistry &)> Fn) = 0;<br>
};<br>
<br>
/// CreateAnalysisConsumer - Creates an ASTConsumer to run various code<br>
<br>
Modified: cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h?rev=335740&r1=335739&r2=335740&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h?rev=335740&r1=335739&r2=335740&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h (original)<br>
+++ cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h Wed Jun 27 07:56:12 2018<br>
@@ -11,6 +11,7 @@<br>
#define LLVM_CLANG_STATICANALYZER_FRONTEND_CHECKERREGISTRATION_H<br>
<br>
#include "clang/Basic/LLVM.h"<br>
+#include <functional><br>
#include <memory><br>
#include <string><br>
<br>
@@ -21,10 +22,13 @@ namespace clang {<br>
<br>
namespace ento {<br>
class CheckerManager;<br>
+ class CheckerRegistry;<br>
<br>
- std::unique_ptr<CheckerManager><br>
- createCheckerManager(AnalyzerOptions &opts, const LangOptions &langOpts,<br>
- ArrayRef<std::string> plugins, DiagnosticsEngine &diags);<br>
+ std::unique_ptr<CheckerManager> createCheckerManager(<br>
+ AnalyzerOptions &opts, const LangOptions &langOpts,<br>
+ ArrayRef<std::string> plugins,<br>
+ ArrayRef<std::function<void(CheckerRegistry &)>> checkerRegistrationFns,<br>
+ DiagnosticsEngine &diags);<br>
<br>
} // end ento namespace<br>
<br>
<br>
Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp?rev=335740&r1=335739&r2=335740&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp?rev=335740&r1=335739&r2=335740&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (original)<br>
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Wed Jun 27 07:56:12 2018<br>
@@ -164,6 +164,8 @@ class AnalysisConsumer : public Analysis<br>
/// Bug Reporter to use while recursively visiting Decls.<br>
BugReporter *RecVisitorBR;<br>
<br>
+ std::vector<std::function<void(CheckerRegistry &)>> CheckerRegistrationFns;<br>
+<br>
public:<br>
ASTContext *Ctx;<br>
const Preprocessor &PP;<br>
@@ -293,8 +295,9 @@ public:<br>
<br>
void Initialize(ASTContext &Context) override {<br>
Ctx = &Context;<br>
- checkerMgr = createCheckerManager(*Opts, PP.getLangOpts(), Plugins,<br>
- PP.getDiagnostics());<br>
+ checkerMgr =<br>
+ createCheckerManager(*Opts, PP.getLangOpts(), Plugins,<br>
+ CheckerRegistrationFns, PP.getDiagnostics());<br>
<br>
Mgr = llvm::make_unique<AnalysisManager>(<br>
*Ctx, PP.getDiagnostics(), PP.getLangOpts(), PathConsumers,<br>
@@ -385,6 +388,10 @@ public:<br>
PathConsumers.push_back(Consumer);<br>
}<br>
<br>
+ void AddCheckerRegistrationFn(std::function<void(CheckerRegistry&)> Fn) override {<br>
+ CheckerRegistrationFns.push_back(std::move(Fn));<br>
+ }<br>
+<br>
private:<br>
void storeTopLevelDecls(DeclGroupRef DG);<br>
std::string getFunctionName(const Decl *D);<br>
<br>
Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp?rev=335740&r1=335739&r2=335740&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp?rev=335740&r1=335739&r2=335740&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp (original)<br>
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp Wed Jun 27 07:56:12 2018<br>
@@ -111,16 +111,21 @@ getCheckerOptList(const AnalyzerOptions<br>
return checkerOpts;<br>
}<br>
<br>
-std::unique_ptr<CheckerManager><br>
-ento::createCheckerManager(AnalyzerOptions &opts, const LangOptions &langOpts,<br>
- ArrayRef<std::string> plugins,<br>
- DiagnosticsEngine &diags) {<br>
+std::unique_ptr<CheckerManager> ento::createCheckerManager(<br>
+ AnalyzerOptions &opts, const LangOptions &langOpts,<br>
+ ArrayRef<std::string> plugins,<br>
+ ArrayRef<std::function<void(CheckerRegistry &)>> checkerRegistrationFns,<br>
+ DiagnosticsEngine &diags) {<br>
std::unique_ptr<CheckerManager> checkerMgr(<br>
new CheckerManager(langOpts, opts));<br>
<br>
SmallVector<CheckerOptInfo, 8> checkerOpts = getCheckerOptList(opts);<br>
<br>
ClangCheckerRegistry allCheckers(plugins, &diags);<br>
+<br>
+ for (const auto &Fn : checkerRegistrationFns)<br>
+ Fn(allCheckers);<br>
+<br>
allCheckers.initializeManager(*checkerMgr, checkerOpts);<br>
allCheckers.validateCheckerOptions(opts, diags);<br>
checkerMgr->finishedCheckerRegistration();<br>
<br>
Modified: cfe/trunk/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp?rev=335740&r1=335739&r2=335740&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp?rev=335740&r1=335739&r2=335740&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp (original)<br>
+++ cfe/trunk/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp Wed Jun 27 07:56:12 2018<br>
@@ -1,4 +1,4 @@<br>
-//===- unittest/Analysis/AnalyzerOptionsTest.cpp - SA Options test --------===//<br>
+//===- unittest/StaticAnalyzer/AnalyzerOptionsTest.cpp - SA Options test --===//<br>
//<br>
// The LLVM Compiler Infrastructure<br>
//<br>
<br>
Modified: cfe/trunk/unittests/StaticAnalyzer/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/StaticAnalyzer/CMakeLists.txt?rev=335740&r1=335739&r2=335740&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/StaticAnalyzer/CMakeLists.txt?rev=335740&r1=335739&r2=335740&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/unittests/StaticAnalyzer/CMakeLists.txt (original)<br>
+++ cfe/trunk/unittests/StaticAnalyzer/CMakeLists.txt Wed Jun 27 07:56:12 2018<br>
@@ -4,11 +4,14 @@ set(LLVM_LINK_COMPONENTS<br>
<br>
add_clang_unittest(StaticAnalysisTests<br>
AnalyzerOptionsTest.cpp<br>
+ RegisterCustomCheckersTest.cpp<br>
)<br>
<br>
target_link_libraries(StaticAnalysisTests<br>
PRIVATE<br>
clangBasic<br>
clangAnalysis<br>
- clangStaticAnalyzerCore <br>
+ clangStaticAnalyzerCore<br>
+ clangStaticAnalyzerFrontend<br>
+ clangTooling<br>
)<br>
<br>
Added: cfe/trunk/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp?rev=335740&view=auto" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp?rev=335740&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp (added)<br>
+++ cfe/trunk/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp Wed Jun 27 07:56:12 2018<br>
@@ -0,0 +1,80 @@<br>
+//===- unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp ------------===//<br>
+//<br>
+// The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#include "clang/Frontend/CompilerInstance.h"<br>
+#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"<br>
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"<br>
+#include "clang/StaticAnalyzer/Core/Checker.h"<br>
+#include "clang/StaticAnalyzer/Core/CheckerRegistry.h"<br>
+#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"<br>
+#include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"<br>
+#include "clang/Tooling/Tooling.h"<br>
+#include "gtest/gtest.h"<br>
+<br>
+namespace clang {<br>
+namespace ento {<br>
+namespace {<br>
+<br>
+class CustomChecker : public Checker<check::ASTCodeBody> {<br>
+public:<br>
+ void checkASTCodeBody(const Decl *D, AnalysisManager &Mgr,<br>
+ BugReporter &BR) const {<br>
+ BR.EmitBasicReport(D, this, "Custom diagnostic", categories::LogicError,<br>
+ "Custom diagnostic description",<br>
+ PathDiagnosticLocation(D, Mgr.getSourceManager()), {});<br>
+ }<br>
+};<br>
+<br>
+class TestAction : public ASTFrontendAction {<br>
+ class DiagConsumer : public PathDiagnosticConsumer {<br>
+ llvm::raw_ostream &Output;<br>
+<br>
+ public:<br>
+ DiagConsumer(llvm::raw_ostream &Output) : Output(Output) {}<br>
+ void FlushDiagnosticsImpl(std::vector<const PathDiagnostic *> &Diags,<br>
+ FilesMade *filesMade) override {<br>
+ for (const auto *PD : Diags)<br>
+ Output << PD->getCheckName() << ":" << PD->getShortDescription();<br>
+ }<br>
+<br>
+ StringRef getName() const override { return "Test"; }<br>
+ };<br>
+<br>
+ llvm::raw_ostream &DiagsOutput;<br>
+<br>
+public:<br>
+ TestAction(llvm::raw_ostream &DiagsOutput) : DiagsOutput(DiagsOutput) {}<br>
+<br>
+ std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &Compiler,<br>
+ StringRef File) override {<br>
+ std::unique_ptr<AnalysisASTConsumer> AnalysisConsumer =<br>
+ CreateAnalysisConsumer(Compiler);<br>
+ AnalysisConsumer->AddDiagnosticConsumer(new DiagConsumer(DiagsOutput));<br>
+ Compiler.getAnalyzerOpts()->CheckersControlList = {<br>
+ {"custom.CustomChecker", true}};<br>
+ AnalysisConsumer->AddCheckerRegistrationFn([](CheckerRegistry &Registry) {<br>
+ Registry.addChecker<CustomChecker>("custom.CustomChecker", "Description");<br>
+ });<br>
+ return AnalysisConsumer;<br>
+ }<br>
+};<br>
+<br>
+<br>
+TEST(RegisterCustomCheckers, RegisterChecker) {<br>
+ std::string Diags;<br>
+ {<br>
+ llvm::raw_string_ostream OS(Diags);<br>
+ EXPECT_TRUE(tooling::runToolOnCode(new TestAction(OS), "void f() {;}"));<br>
+ }<br>
+ EXPECT_EQ(Diags, "custom.CustomChecker:Custom diagnostic description");<br>
+}<br>
+<br>
+}<br>
+}<br>
+}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">-- <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal">--Artem Belevich<o:p></o:p></p>
</div>
</div>
</div>
</div>
</body>
</html>