BodyFarm.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //== BodyFarm.h - Factory for conjuring up fake bodies -------------*- C++ -*-//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // BodyFarm is a factory for creating faux implementations for functions/methods
  11. // for analysis purposes.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. #ifndef LLVM_CLANG_LIB_ANALYSIS_BODYFARM_H
  15. #define LLVM_CLANG_LIB_ANALYSIS_BODYFARM_H
  16. #include "clang/Basic/LLVM.h"
  17. #include "llvm/ADT/DenseMap.h"
  18. #include "llvm/ADT/Optional.h"
  19. namespace clang {
  20. class ASTContext;
  21. class Decl;
  22. class FunctionDecl;
  23. class ObjCMethodDecl;
  24. class ObjCPropertyDecl;
  25. class Stmt;
  26. class CodeInjector;
  27. class BodyFarm {
  28. public:
  29. BodyFarm(ASTContext &C, CodeInjector *injector) : C(C), Injector(injector) {}
  30. /// Factory method for creating bodies for ordinary functions.
  31. Stmt *getBody(const FunctionDecl *D);
  32. /// Factory method for creating bodies for Objective-C properties.
  33. Stmt *getBody(const ObjCMethodDecl *D);
  34. private:
  35. typedef llvm::DenseMap<const Decl *, Optional<Stmt *> > BodyMap;
  36. ASTContext &C;
  37. BodyMap Bodies;
  38. CodeInjector *Injector;
  39. };
  40. }
  41. #endif