Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:25

0001 //== BodyFarm.h - Factory for conjuring up fake bodies -------------*- C++ -*-//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // BodyFarm is a factory for creating faux implementations for functions/methods
0010 // for analysis purposes.
0011 //
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_CLANG_ANALYSIS_BODYFARM_H
0015 #define LLVM_CLANG_ANALYSIS_BODYFARM_H
0016 
0017 #include "clang/AST/DeclBase.h"
0018 #include "clang/Basic/LLVM.h"
0019 #include "llvm/ADT/DenseMap.h"
0020 #include <optional>
0021 
0022 namespace clang {
0023 
0024 class ASTContext;
0025 class FunctionDecl;
0026 class ObjCMethodDecl;
0027 class Stmt;
0028 class CodeInjector;
0029 
0030 class BodyFarm {
0031 public:
0032   BodyFarm(ASTContext &C, CodeInjector *injector) : C(C), Injector(injector) {}
0033 
0034   /// Factory method for creating bodies for ordinary functions.
0035   Stmt *getBody(const FunctionDecl *D);
0036 
0037   /// Factory method for creating bodies for Objective-C properties.
0038   Stmt *getBody(const ObjCMethodDecl *D);
0039 
0040   /// Remove copy constructor to avoid accidental copying.
0041   BodyFarm(const BodyFarm &other) = delete;
0042 
0043   /// Delete copy assignment operator.
0044   BodyFarm &operator=(const BodyFarm &other) = delete;
0045 
0046 private:
0047   typedef llvm::DenseMap<const Decl *, std::optional<Stmt *>> BodyMap;
0048 
0049   ASTContext &C;
0050   BodyMap Bodies;
0051   CodeInjector *Injector;
0052 };
0053 } // namespace clang
0054 
0055 #endif