Index: www/analyzer/faq.html =================================================================== --- www/analyzer/faq.html +++ www/analyzer/faq.html @@ -35,6 +35,7 @@
  • The analyzer assumes that a loop body is never entered. How can I tell it that the loop body will be entered at least once?
  • How can I suppress a specific analyzer warning?
  • How can I selectively exclude code the analyzer examines?
  • +
  • How can I run the analyzer on a single file from the command line?
  • @@ -220,6 +221,41 @@ false positives.

    +

    Q: How can I run the analyzer on a single file from command line?

    + +

    The clang command line option --analyze enables usage on a single +file:

    + +
    +clang --analyze myfile.c
    +
    + +

    All usual clang flags may be used, +e.g. a custom include directory may be specified:

    + +
    +clang --analyze -Iinclude myotherfile.c
    +
    + +

    Moreover, the clang-check +tool can be used to automatically extract +flags from the +compilation database:

    + +
    +clang-check -analyze -p db-folder myfile.c
    +
    + +

    HTML reports can be generated by passing the following command line flag:

    + +
    +clang --analyze -Xclang -analyzer-output=html mythirdfile.c -o report
    +
    + +

    This invocation would generate an HTML report for each issue found +in a translation unit, and place it in the directory report.

    + + Index: www/analyzer/scan-build.html =================================================================== --- www/analyzer/scan-build.html +++ www/analyzer/scan-build.html @@ -43,6 +43,12 @@ the best use of scan-build, which includes getting it to work when the aforementioned hack fails to work.

    +

    But what if I just need to analyze single file?

    + +

    This FAQ +answer +has all the details.

    + scan-build