[all-commits] [llvm/llvm-project] 57b8a4: [analyzer][NFC] Tie CheckerRegistry to CheckerMana...
Kristóf Umann via All-commits
all-commits at lists.llvm.org
Mon Mar 23 09:09:56 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 57b8a407493c34c3680e7e1e4cb82e097f43744a
https://github.com/llvm/llvm-project/commit/57b8a407493c34c3680e7e1e4cb82e097f43744a
Author: Kristóf Umann <dkszelethus at gmail.com>
Date: 2020-03-23 (Mon, 23 Mar 2020)
Changed paths:
M clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
M clang/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h
A clang/include/clang/StaticAnalyzer/Frontend/AnalyzerHelpFlags.h
R clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h
M clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
M clang/include/clang/StaticAnalyzer/Frontend/FrontendActions.h
M clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
M clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
M clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
A clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp
M clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt
R clang/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
M clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
Log Message:
-----------
[analyzer][NFC] Tie CheckerRegistry to CheckerManager, allow CheckerManager to be constructed for non-analysis purposes
Its been a while since my CheckerRegistry related patches landed, allow me to
refresh your memory:
During compilation, TblGen turns
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td into
(build directory)/tools/clang/include/clang/StaticAnalyzer/Checkers/Checkers.inc.
This is a file that contains the full name of the checkers, their options, etc.
The class that is responsible for parsing this file is CheckerRegistry. The job
of this class is to establish what checkers are available for the analyzer (even
from plugins and statically linked but non-tblgen generated files!), and
calculate which ones should be turned on according to the analyzer's invocation.
CheckerManager is the class that is responsible for the construction and storage
of checkers. This process works by first creating a CheckerRegistry object, and
passing itself to CheckerRegistry::initializeManager(CheckerManager&), which
will call the checker registry functions (for example registerMallocChecker) on
it.
The big problem here is that these two classes lie in two different libraries,
so their interaction is pretty awkward. This used to be far worse, but I
refactored much of it, which made things better but nowhere near perfect.
---
This patch changes how the above mentioned two classes interact. CheckerRegistry
is mainly used by CheckerManager, and they are so intertwined, it makes a lot of
sense to turn in into a field, instead of a one-time local variable. This has
additional benefits: much of the information that CheckerRegistry conveniently
holds is no longer thrown away right after the analyzer's initialization, and
opens the possibility to pass CheckerManager in the shouldRegister* function
rather then LangOptions (D75271).
There are a few problems with this. CheckerManager isn't the only user, when we
honor help flags like -analyzer-checker-help, we only have access to a
CompilerInstance class, that is before the point of parsing the AST.
CheckerManager makes little sense without ASTContext, so I made some changes and
added new constructors to make it constructible for the use of help flags.
Differential Revision: https://reviews.llvm.org/D75360
More information about the All-commits
mailing list