/// declarations from external source.
std::unique_ptr<CodeInjector> Injector;
- /// Pointer to a factory for creating and caching implementations for common
+ /// A factory for creating and caching implementations for common
/// methods during the analysis.
- std::unique_ptr<BodyFarm> FunctionBodyFarm;
+ BodyFarm FunctionBodyFarm;
/// Flag to indicate whether or not bodies should be synthesized
/// for well-known functions.
return LocContexts.getStackFrame(getContext(D), Parent, S, Blk, Idx);
}
- /// Get and lazily create a {@code BodyFarm} instance.
- BodyFarm *getBodyFarm();
+ /// Get a reference to {@code BodyFarm} instance.
+ BodyFarm &getBodyFarm();
/// Discard all previously created AnalysisDeclContexts.
void clear();
bool addInitializers, bool addTemporaryDtors, bool addLifetime,
bool addLoopExit, bool synthesizeBodies, bool addStaticInitBranch,
bool addCXXNewAllocator, CodeInjector *injector)
- : ASTCtx(ASTCtx), Injector(injector), SynthesizeBodies(synthesizeBodies) {
+ : ASTCtx(ASTCtx), Injector(injector), FunctionBodyFarm(ASTCtx, injector),
+ SynthesizeBodies(synthesizeBodies) {
cfgBuildOptions.PruneTriviallyFalseEdges = !useUnoptimizedCFG;
cfgBuildOptions.AddImplicitDtors = addImplicitDtors;
cfgBuildOptions.AddInitializers = addInitializers;
if (auto *CoroBody = dyn_cast_or_null<CoroutineBodyStmt>(Body))
Body = CoroBody->getBody();
if (Manager && Manager->synthesizeBodies()) {
- Stmt *SynthesizedBody = Manager->getBodyFarm()->getBody(FD);
+ Stmt *SynthesizedBody = Manager->getBodyFarm().getBody(FD);
if (SynthesizedBody) {
Body = SynthesizedBody;
IsAutosynthesized = true;
else if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) {
Stmt *Body = MD->getBody();
if (Manager && Manager->synthesizeBodies()) {
- Stmt *SynthesizedBody = Manager->getBodyFarm()->getBody(MD);
+ Stmt *SynthesizedBody = Manager->getBodyFarm().getBody(MD);
if (SynthesizedBody) {
Body = SynthesizedBody;
IsAutosynthesized = true;
return AC.get();
}
-BodyFarm *AnalysisDeclContextManager::getBodyFarm() {
- if (!FunctionBodyFarm)
- FunctionBodyFarm = llvm::make_unique<BodyFarm>(ASTCtx, Injector.get());
- return FunctionBodyFarm.get();
-}
+BodyFarm &AnalysisDeclContextManager::getBodyFarm() { return FunctionBodyFarm; }
const StackFrameContext *
AnalysisDeclContext::getStackFrame(LocationContext const *Parent, const Stmt *S,