[cfe-dev] Implement Checker with LibTooling

Artem Dergachev via cfe-dev cfe-dev at lists.llvm.org
Mon Aug 24 09:01:32 PDT 2020

Static Analyzer's CheckerContext is a temporary entity that only makes 
sense during path-sensitive analysis. libTooling doesn't conduct 
path-sensitive analysis for you; in order to obtain CheckerContext 
you'll need to instantiate the entire Static Analyzer. Clang-Tidy is an 
example of a tool that does that but that isn't supposed to be easy.

Generally, you most likely don't want to use path-sensitive analysis for 
anything other than bug-finding because it doesn't tell you anything 
except "there *exists* an execution path through your code that 
satisfies certain criteria";  in particular, it can't be used for 
proving absence of such path in your code. And you definitely shouldn't 
try to build a tool that only runs one checker in isolation; Static 
Analyzer's checker depend on each other for correctness. For these 
reasons what you're doing probably doesn't make sense and you'll have 
better luck either writing a new Static Analyzer checker without 
creating a separate tool, or create a separate tool without trying to 
use CheckerContext.

On 8/21/20 6:33 AM, Thien Tran via cfe-dev wrote:
> Hi everyone,
> I'm writing a C/C++ static analysis tool with LibTooling. The program 
> walks through the source code and searches for custom criterias. The 
> program works well but I still don't know how to implement Clang 
> Checker into LibTooling.
> I'm reading the instruction "CLANG STATIC ANALYZER - A Checker 
> Developer’s Guide". Please tell me how to know/get the current 
> CheckerContext in a location of source code.
> Thank you!
> ----------------
> Best regards,
> Thien Tran.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200824/45e564a4/attachment-0001.html>

More information about the cfe-dev mailing list