Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does `clang-check` do without `-analyze` option?

Tags:

c++

llvm

clang

clang-check, Clang's built-in static analysis tool, has an -analyze option, for which the help string just says "Run static analysis engine." With this flag, I see very little output from running clang-check on several of my files; without it, I see a lot of warnings.

Isn't running the static analysis engine the main purpose of running clang-check, which is a static analysis tool? Why do I see less output when running the engine, and what does the tool do without the flag?

like image 910
Kyle Strand Avatar asked Jun 30 '15 20:06

Kyle Strand


People also ask

What is clang check?

ClangCheck is a small wrapper around LibTooling which can be used to do basic error checking and AST dumping.

How do I disable clang tidy checks?

If you must enable or disable particular checks, use the clang-tidy command-line format in your . clang-tidy files. The command-line format specifies a comma-separated list of positive and negative globs: positive globs add subsets of checks, and negative globs (prefixed with - ) remove subsets of checks.

What are clang tidy warnings?

Clang-tidy is a standalone linter tool for checking C and C++ source code files. It provides an additional set of compiler warnings—called checks—that go above and beyond what is typically included in a C or C++ compiler.


1 Answers

Running clang-check without any options runs the -fsyntax-only mode (checking for correct syntax). Only if you specify -analyze, the static analysis tool is executed, see http://clang-analyzer.llvm.org/available_checks.html for a full list of executed checks.

  • Note 1: you can do various other stuff with clang-check, e.g. AST dumping.
  • Note 2: you cannot specify -fsyntax-only and -analyze at the same time.
like image 117
D.R. Avatar answered Oct 20 '22 00:10

D.R.