Clang static analyzer

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Clang static analyzer

Vassil Vassilev via cfe-dev
Hi All,

In my clang tool I setup the static analyzer using the following code:
But I am not sure if this is sufficient. I don't see any analyzer messages in the output. Is there any way to test if it is active?


bool runInvocation(std::shared_ptr<clang::CompilerInvocation> invocation, clang::FileManager* files, std::shared_ptr<clang::PCHContainerOperations> PCHContainerOps, clang::DiagnosticConsumer* diagConsumer) override
{
invocation->getPreprocessorOpts().SetUpStaticAnalyzer = true;
return clang::tooling::FrontendActionFactory::runInvocation(invocation, files, PCHContainerOps, diagConsumer);
}


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang static analyzer

Vassil Vassilev via cfe-dev
I never tried this but what you're doing is clearly not sufficient.
SetUpStaticAnalyzer only asks the preprocessor to act as if the static
analyzer is eventually going to be run.

You should start with making sure your action is AnalysisAction. You can
probably use clang-check as an example.

On 5/28/20 8:53 PM, Billy Araujo via cfe-dev wrote:

> Hi All,
>
> In my clang tool I setup the static analyzer using the following code:
> But I am not sure if this is sufficient. I don't see any analyzer
> messages in the output. Is there any way to test if it is active?
>
>
> bool runInvocation(std::shared_ptr<clang::CompilerInvocation>
> invocation, clang::FileManager* files,
> std::shared_ptr<clang::PCHContainerOperations> PCHContainerOps,
> clang::DiagnosticConsumer* diagConsumer) override
> {
> invocation->getPreprocessorOpts().SetUpStaticAnalyzer = true;
> return
> clang::tooling::FrontendActionFactory::runInvocation(invocation,
> files, PCHContainerOps, diagConsumer);
> }
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang static analyzer

Vassil Vassilev via cfe-dev
Thanks Artem. I will try that. 


On Fri, May 29, 2020 at 1:13 PM Artem Dergachev <[hidden email]> wrote:
I never tried this but what you're doing is clearly not sufficient.
SetUpStaticAnalyzer only asks the preprocessor to act as if the static
analyzer is eventually going to be run.

You should start with making sure your action is AnalysisAction. You can
probably use clang-check as an example.

On 5/28/20 8:53 PM, Billy Araujo via cfe-dev wrote:
> Hi All,
>
> In my clang tool I setup the static analyzer using the following code:
> But I am not sure if this is sufficient. I don't see any analyzer
> messages in the output. Is there any way to test if it is active?
>
>
> bool runInvocation(std::shared_ptr<clang::CompilerInvocation>
> invocation, clang::FileManager* files,
> std::shared_ptr<clang::PCHContainerOperations> PCHContainerOps,
> clang::DiagnosticConsumer* diagConsumer) override
> {
> invocation->getPreprocessorOpts().SetUpStaticAnalyzer = true;
> return
> clang::tooling::FrontendActionFactory::runInvocation(invocation,
> files, PCHContainerOps, diagConsumer);
> }
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev