Clang static analyzer

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_ptrclang::CompilerInvocation invocation, clang::FileManager* files, std::shared_ptrclang::PCHContainerOperations PCHContainerOps, clang::DiagnosticConsumer* diagConsumer) override
{
invocation->getPreprocessorOpts().SetUpStaticAnalyzer = true;
return clang::tooling::FrontendActionFactory::runInvocation(invocation, files, PCHContainerOps, diagConsumer);
}

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.

Thanks Artem. I will try that.