blob: edbe996246515c8d8e1496d0cbd448acd6ba40b0 [file] [log] [blame]
Ted Kremenek14f779c2012-09-21 00:09:11 +00001//== 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
Benjamin Kramer2f5db8b2014-08-13 16:25:19 +000015#ifndef LLVM_CLANG_LIB_ANALYSIS_BODYFARM_H
16#define LLVM_CLANG_LIB_ANALYSIS_BODYFARM_H
Ted Kremenek14f779c2012-09-21 00:09:11 +000017
Benjamin Kramerfa511382016-02-02 11:06:57 +000018#include "clang/AST/DeclBase.h"
David Blaikie05785d12013-02-20 22:23:23 +000019#include "clang/Basic/LLVM.h"
Ted Kremenek14f779c2012-09-21 00:09:11 +000020#include "llvm/ADT/DenseMap.h"
Chandler Carruth3a022472012-12-04 09:13:33 +000021#include "llvm/ADT/Optional.h"
Ted Kremenek14f779c2012-09-21 00:09:11 +000022
23namespace clang {
24
25class ASTContext;
Ted Kremenek14f779c2012-09-21 00:09:11 +000026class FunctionDecl;
Jordan Rose1a866cd2014-01-10 20:06:06 +000027class ObjCMethodDecl;
28class ObjCPropertyDecl;
Ted Kremenek14f779c2012-09-21 00:09:11 +000029class Stmt;
Ted Kremenekeeccb302014-08-27 15:14:15 +000030class CodeInjector;
Ted Kremenek14f779c2012-09-21 00:09:11 +000031
32class BodyFarm {
33public:
Ted Kremenekeeccb302014-08-27 15:14:15 +000034 BodyFarm(ASTContext &C, CodeInjector *injector) : C(C), Injector(injector) {}
Ted Kremenek14f779c2012-09-21 00:09:11 +000035
36 /// Factory method for creating bodies for ordinary functions.
37 Stmt *getBody(const FunctionDecl *D);
Jordan Rose1a866cd2014-01-10 20:06:06 +000038
39 /// Factory method for creating bodies for Objective-C properties.
Jordan Roseddf19662014-01-23 03:59:10 +000040 Stmt *getBody(const ObjCMethodDecl *D);
Jordan Rose1a866cd2014-01-10 20:06:06 +000041
Ted Kremenek14f779c2012-09-21 00:09:11 +000042private:
David Blaikie05785d12013-02-20 22:23:23 +000043 typedef llvm::DenseMap<const Decl *, Optional<Stmt *> > BodyMap;
Ted Kremenek14f779c2012-09-21 00:09:11 +000044
45 ASTContext &C;
46 BodyMap Bodies;
Ted Kremenekeeccb302014-08-27 15:14:15 +000047 CodeInjector *Injector;
Ted Kremenek14f779c2012-09-21 00:09:11 +000048};
Alexander Kornienkoab9db512015-06-22 23:07:51 +000049}
Ted Kremenek14f779c2012-09-21 00:09:11 +000050
51#endif