#ifndef CLANG_CODEGEN_CGDEBUGINFO_H
#define CLANG_CODEGEN_CGDEBUGINFO_H
#include "clang/AST/Type.h"
#include "clang/Basic/SourceLocation.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/Analysis/DebugInfo.h"
#include <map>
#include "CGBuilder.h"
namespace clang {
class VarDecl;
class ObjCInterfaceDecl;
namespace CodeGen {
class CodeGenModule;
class CGDebugInfo {
CodeGenModule *M;
bool isMainCompileUnitCreated;
llvm::DIFactory DebugFactory;
SourceLocation CurLoc, PrevLoc;
llvm::DenseMap<unsigned, llvm::DICompileUnit> CompileUnitCache;
std::map<void *, llvm::DIType> TypeCache;
std::vector<llvm::DIDescriptor> RegionStack;
llvm::DIType CreateType(const BuiltinType *Ty, llvm::DICompileUnit U);
llvm::DIType CreateType(const ComplexType *Ty, llvm::DICompileUnit U);
llvm::DIType CreateCVRType(QualType Ty, llvm::DICompileUnit U);
llvm::DIType CreateType(const TypedefType *Ty, llvm::DICompileUnit U);
llvm::DIType CreateType(const PointerType *Ty, llvm::DICompileUnit U);
llvm::DIType CreateType(const FunctionType *Ty, llvm::DICompileUnit U);
llvm::DIType CreateType(const TagType *Ty, llvm::DICompileUnit U);
llvm::DIType CreateType(const RecordType *Ty, llvm::DICompileUnit U);
llvm::DIType CreateType(const ObjCInterfaceType *Ty, llvm::DICompileUnit U);
llvm::DIType CreateType(const EnumType *Ty, llvm::DICompileUnit U);
llvm::DIType CreateType(const ArrayType *Ty, llvm::DICompileUnit U);
public:
CGDebugInfo(CodeGenModule *m);
~CGDebugInfo();
void setLocation(SourceLocation Loc);
void EmitStopPoint(llvm::Function *Fn, CGBuilderTy &Builder);
void EmitFunctionStart(const char *Name, QualType ReturnType,
llvm::Function *Fn, CGBuilderTy &Builder);
void EmitRegionStart(llvm::Function *Fn, CGBuilderTy &Builder);
void EmitRegionEnd(llvm::Function *Fn, CGBuilderTy &Builder);
void EmitDeclareOfAutoVariable(const VarDecl *Decl, llvm::Value *AI,
CGBuilderTy &Builder);
void EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI,
CGBuilderTy &Builder);
void EmitGlobalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
void EmitGlobalVariable(llvm::GlobalVariable *GV, ObjCInterfaceDecl *Decl);
private:
void EmitDeclare(const VarDecl *decl, unsigned Tag, llvm::Value *AI,
CGBuilderTy &Builder);
llvm::DICompileUnit getOrCreateCompileUnit(SourceLocation Loc);
llvm::DIType getOrCreateType(QualType Ty, llvm::DICompileUnit Unit);
};
} }
#endif