[PATCH] D50211: [analyzer] Fix displayed checker name for InnerPointerChecker
Umann Kristóf via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 7 05:31:09 PST 2018
Szelethus added a comment.
Herald added a subscriber: donat.nagy.
Bad news, this approach doesn't work too well, and here's why: https://github.com/llvm-mirror/clang/blob/master/lib/StaticAnalyzer/Core/CheckerRegistry.cpp#L115
void CheckerRegistry::initializeManager(CheckerManager &checkerMgr,
SmallVectorImpl<CheckerOptInfo> &opts) const {
// Sort checkers for efficient collection.
llvm::sort(Checkers, checkerNameLT);
// Collect checkers enabled by the options.
CheckerInfoSet enabledCheckers;
for (auto &i : opts)
collectCheckers(Checkers, Packages, i, enabledCheckers);
// Initialize the CheckerManager with all enabled checkers.
for (const auto *i :enabledCheckers) {
checkerMgr.setCurrentCheckName(CheckName(i->FullName));
i->Initialize(checkerMgr);
}
}
Note that `Initialize` is a function pointer that points to `register##CHECKERNAME`, so a single registry function should only register one checker, because `setCurrentCheckName` is only called once, resulting in `MallocChecker`'s checker object receiving the `cpluscplus.InnetPointer` name. It's very not-obvious how to fix this gracefully :/ You could call `CheckerManager::setCurrentCheckName` within the registry function, but you have to supply a full name, which adds unnecessary maintenance cost (for example, if someone moves a checker out of alpha, or puts one back).
I found this bug while trying to fix checker options, and noticed that the `Optimistic` flag of `MallocChecker` is acquired as `cplusplus.InnerPointer:Optimistic`, instead of `unix.Malloc:Optimistic`. Let's keep this in for now, and I'll try to look for ways to express dependencies while avoiding this issue.
https://reviews.llvm.org/D50211
More information about the cfe-commits
mailing list