
In earlier patches regarding AnalyzerOptions, a lot of effort went into gathering all config options, and changing the interface so that potential misuse can be eliminited. Up until this point, AnalyzerOptions only evaluated an option when it was querried. For example, if we had a "-no-false-positives" flag, AnalyzerOptions would store an Optional field for it that would be None up until somewhere in the code until the flag's getter function is called. However, now that we're confident that we've gathered all configs, we can evaluate off of them before analysis, so we can emit a error on invalid input even if that prticular flag will not matter in that particular run of the analyzer. Another very big benefit of this is that debug.ConfigDumper will now show the value of all configs every single time. Also, almost all options related class have a similar interface, so uniformity is also a benefit. The implementation for errors on invalid input will be commited shorty. Differential Revision: https://reviews.llvm.org/D53692 llvm-svn: 348031
63 lines
2.3 KiB
C++
63 lines
2.3 KiB
C++
//===-- AnalysisManager.cpp -------------------------------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
|
|
|
|
using namespace clang;
|
|
using namespace ento;
|
|
|
|
void AnalysisManager::anchor() { }
|
|
|
|
AnalysisManager::AnalysisManager(ASTContext &ASTCtx, DiagnosticsEngine &diags,
|
|
const PathDiagnosticConsumers &PDC,
|
|
StoreManagerCreator storemgr,
|
|
ConstraintManagerCreator constraintmgr,
|
|
CheckerManager *checkerMgr,
|
|
AnalyzerOptions &Options,
|
|
CodeInjector *injector)
|
|
: AnaCtxMgr(
|
|
ASTCtx, Options.UnoptimizedCFG,
|
|
Options.ShouldIncludeImplicitDtorsInCFG,
|
|
/*AddInitializers=*/true,
|
|
Options.ShouldIncludeTemporaryDtorsInCFG,
|
|
Options.ShouldIncludeLifetimeInCFG,
|
|
// Adding LoopExit elements to the CFG is a requirement for loop
|
|
// unrolling.
|
|
Options.ShouldIncludeLoopExitInCFG ||
|
|
Options.ShouldUnrollLoops,
|
|
Options.ShouldIncludeScopesInCFG,
|
|
Options.ShouldSynthesizeBodies,
|
|
Options.ShouldConditionalizeStaticInitializers,
|
|
/*addCXXNewAllocator=*/true,
|
|
Options.ShouldIncludeRichConstructorsInCFG,
|
|
Options.ShouldElideConstructors, injector),
|
|
Ctx(ASTCtx), Diags(diags), LangOpts(ASTCtx.getLangOpts()),
|
|
PathConsumers(PDC), CreateStoreMgr(storemgr),
|
|
CreateConstraintMgr(constraintmgr), CheckerMgr(checkerMgr),
|
|
options(Options) {
|
|
AnaCtxMgr.getCFGBuildOptions().setAllAlwaysAdd();
|
|
}
|
|
|
|
AnalysisManager::~AnalysisManager() {
|
|
FlushDiagnostics();
|
|
for (PathDiagnosticConsumers::iterator I = PathConsumers.begin(),
|
|
E = PathConsumers.end(); I != E; ++I) {
|
|
delete *I;
|
|
}
|
|
}
|
|
|
|
void AnalysisManager::FlushDiagnostics() {
|
|
PathDiagnosticConsumer::FilesMade filesMade;
|
|
for (PathDiagnosticConsumers::iterator I = PathConsumers.begin(),
|
|
E = PathConsumers.end();
|
|
I != E; ++I) {
|
|
(*I)->FlushDiagnostics(&filesMade);
|
|
}
|
|
}
|