llvm-project/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
Artem Dergachev ff267df0de [CFG] [analyzer] Add construction contexts that explain pre-C++17 copy elision.
Before C++17 copy elision was optional, even if the elidable copy/move
constructor had arbitrary side effects. The elidable constructor is present
in the AST, but marked as elidable.

In these cases CFG now contains additional information that allows its clients
to figure out if a temporary object is only being constructed so that to pass
it to an elidable constructor. If so, it includes a reference to the elidable
constructor's construction context, so that the client could elide the
elidable constructor and construct the object directly at its final destination.

Differential Revision: https://reviews.llvm.org/D47616

llvm-svn: 335795
2018-06-28 00:04:54 +00:00

58 lines
2.2 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 LangOptions &lang,
const PathDiagnosticConsumers &PDC, StoreManagerCreator storemgr,
ConstraintManagerCreator constraintmgr, CheckerManager *checkerMgr,
AnalyzerOptions &Options, CodeInjector *injector)
: AnaCtxMgr(ASTCtx, Options.UnoptimizedCFG,
Options.includeImplicitDtorsInCFG(),
/*AddInitializers=*/true, Options.includeTemporaryDtorsInCFG(),
Options.includeLifetimeInCFG(),
// Adding LoopExit elements to the CFG is a requirement for loop
// unrolling.
Options.includeLoopExitInCFG() || Options.shouldUnrollLoops(),
Options.includeScopesInCFG(),
Options.shouldSynthesizeBodies(),
Options.shouldConditionalizeStaticInitializers(),
/*addCXXNewAllocator=*/true,
Options.includeRichConstructorsInCFG(),
Options.shouldElideConstructors(),
injector),
Ctx(ASTCtx), Diags(diags), LangOpts(lang), 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);
}
}