BodyFarm.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //== BodyFarm.h - Factory for conjuring up fake bodies -------------*- C++ -*-//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // BodyFarm is a factory for creating faux implementations for functions/methods
  15. // for analysis purposes.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_CLANG_ANALYSIS_BODYFARM_H
  19. #define LLVM_CLANG_ANALYSIS_BODYFARM_H
  20. #include "clang/AST/DeclBase.h"
  21. #include "clang/Basic/LLVM.h"
  22. #include "llvm/ADT/DenseMap.h"
  23. #include "llvm/ADT/Optional.h"
  24. namespace clang {
  25. class ASTContext;
  26. class FunctionDecl;
  27. class ObjCMethodDecl;
  28. class Stmt;
  29. class CodeInjector;
  30. class BodyFarm {
  31. public:
  32. BodyFarm(ASTContext &C, CodeInjector *injector) : C(C), Injector(injector) {}
  33. /// Factory method for creating bodies for ordinary functions.
  34. Stmt *getBody(const FunctionDecl *D);
  35. /// Factory method for creating bodies for Objective-C properties.
  36. Stmt *getBody(const ObjCMethodDecl *D);
  37. /// Remove copy constructor to avoid accidental copying.
  38. BodyFarm(const BodyFarm &other) = delete;
  39. private:
  40. typedef llvm::DenseMap<const Decl *, Optional<Stmt *>> BodyMap;
  41. ASTContext &C;
  42. BodyMap Bodies;
  43. CodeInjector *Injector;
  44. };
  45. } // namespace clang
  46. #endif
  47. #ifdef __GNUC__
  48. #pragma GCC diagnostic pop
  49. #endif