accessing command line options

Hi list,

How can I get command line options, especially “-o” of scan-build (output directory), in a checker function such as “checkEndAnalysis”?



You may use the AnalyzerOptions class to retrieve analyzer specific command line options, and you can get one easily from CheckerContext. For the output directory, FrontendOptions should be used, but I don’t think you can get your hands on it from a checker callback. What would you like to achieve?


Thanks a lot.

I want to keep some additional information and intermediate results during analysis and dump it in the given output directory. What would be the simplest way?


      1. 오전 8:59, Kristóf Umann <> 작성:

Hmm. Yea, I don’t think you can do that now. It might be possible somehow, I just don’t know how, and I doubt that there is a way. The best course of action would be to add a checker option.

  1. Add a brief documentation about that flag in the file’s headings (below the licence thingie)
  2. Add a new string field to your checker class. Initialize it in the checker registry function (registerYourChecker) by calling AnalyzerOptions::getCheckerStringOption().
  3. You may configure your checker on the command line by appending this to the analyzer invocation: -analyzer-config package.subpackage.YourChecker:YourConfig="/some/output/location"

Mind you, there are around 10 patches on review that will overhaul the checker option interface, so you might need to rebase sometime soon on top of it :slight_smile:

Thanks for reaching out, I might take a look at this later! There are some legitimate cases where accessing the output dir would be neat, for example, we could get rid of the “ctu-dir” option entirely.


Meant to say “Cheers, Kristóf”.