#ifndef CLANG_CODEGEN_CGDEBUGINFO_H
#define CLANG_CODEGEN_CGDEBUGINFO_H
#include "clang/AST/Type.h"
#include "clang/AST/Expr.h"
#include "clang/Basic/SourceLocation.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/Analysis/DebugInfo.h"
#include "llvm/Analysis/DIBuilder.h"
#include "llvm/Support/ValueHandle.h"
#include "llvm/Support/Allocator.h"
#include "CGBuilder.h"
namespace llvm {
class MDNode;
}
namespace clang {
class VarDecl;
class ObjCInterfaceDecl;
class ClassTemplateSpecializationDecl;
class GlobalDecl;
namespace CodeGen {
class CodeGenModule;
class CodeGenFunction;
class CGBlockInfo;
class CGDebugInfo {
CodeGenModule &CGM;
llvm::DIBuilder DBuilder;
llvm::DICompileUnit TheCU;
SourceLocation CurLoc, PrevLoc;
llvm::DIType VTablePtrType;
llvm::DenseMap<void *, llvm::WeakVH> TypeCache;
llvm::DenseMap<void *, llvm::WeakVH> CompletedTypeCache;
std::vector<std::pair<void *, llvm::WeakVH> >ReplaceMap;
bool BlockLiteralGenericSet;
llvm::DIType BlockLiteralGeneric;
std::vector<llvm::TrackingVH<llvm::MDNode> > LexicalBlockStack;
llvm::DenseMap<const Decl *, llvm::WeakVH> RegionMap;
std::vector<unsigned> FnBeginRegionCount;
llvm::BumpPtrAllocator DebugInfoNames;
StringRef CWDName;
llvm::DenseMap<const char *, llvm::WeakVH> DIFileCache;
llvm::DenseMap<const FunctionDecl *, llvm::WeakVH> SPCache;
llvm::DenseMap<const NamespaceDecl *, llvm::WeakVH> NameSpaceCache;
llvm::DIType CreateType(const BuiltinType *Ty);
llvm::DIType CreateType(const ComplexType *Ty);
llvm::DIType CreateQualifiedType(QualType Ty, llvm::DIFile F);
llvm::DIType CreateType(const TypedefType *Ty, llvm::DIFile F);
llvm::DIType CreateType(const ObjCObjectPointerType *Ty,
llvm::DIFile F);
llvm::DIType CreateType(const PointerType *Ty, llvm::DIFile F);
llvm::DIType CreateType(const BlockPointerType *Ty, llvm::DIFile F);
llvm::DIType CreateType(const FunctionType *Ty, llvm::DIFile F);
llvm::DIType CreateType(const RecordType *Ty);
llvm::DIType CreateLimitedType(const RecordType *Ty);
llvm::DIType CreateType(const ObjCInterfaceType *Ty, llvm::DIFile F);
llvm::DIType CreateType(const ObjCObjectType *Ty, llvm::DIFile F);
llvm::DIType CreateType(const VectorType *Ty, llvm::DIFile F);
llvm::DIType CreateType(const ArrayType *Ty, llvm::DIFile F);
llvm::DIType CreateType(const LValueReferenceType *Ty, llvm::DIFile F);
llvm::DIType CreateType(const RValueReferenceType *Ty, llvm::DIFile Unit);
llvm::DIType CreateType(const MemberPointerType *Ty, llvm::DIFile F);
llvm::DIType CreateType(const AtomicType *Ty, llvm::DIFile F);
llvm::DIType CreateEnumType(const EnumDecl *ED);
llvm::DIType getTypeOrNull(const QualType);
llvm::DIType getCompletedTypeOrNull(const QualType);
llvm::DIType getOrCreateMethodType(const CXXMethodDecl *Method,
llvm::DIFile F);
llvm::DIType getOrCreateFunctionType(const Decl *D, QualType FnType,
llvm::DIFile F);
llvm::DIType getOrCreateVTablePtrType(llvm::DIFile F);
llvm::DINameSpace getOrCreateNameSpace(const NamespaceDecl *N);
llvm::DIType CreatePointeeType(QualType PointeeTy, llvm::DIFile F);
llvm::DIType CreatePointerLikeType(unsigned Tag,
const Type *Ty, QualType PointeeTy,
llvm::DIFile F);
llvm::DISubprogram CreateCXXMemberFunction(const CXXMethodDecl *Method,
llvm::DIFile F,
llvm::DIType RecordTy);
void CollectCXXMemberFunctions(const CXXRecordDecl *Decl,
llvm::DIFile F,
SmallVectorImpl<llvm::Value *> &E,
llvm::DIType T);
void CollectCXXFriends(const CXXRecordDecl *Decl,
llvm::DIFile F,
SmallVectorImpl<llvm::Value *> &EltTys,
llvm::DIType RecordTy);
void CollectCXXBases(const CXXRecordDecl *Decl,
llvm::DIFile F,
SmallVectorImpl<llvm::Value *> &EltTys,
llvm::DIType RecordTy);
llvm::DIArray
CollectTemplateParams(const TemplateParameterList *TPList,
const TemplateArgumentList &TAList,
llvm::DIFile Unit);
llvm::DIArray
CollectFunctionTemplateParams(const FunctionDecl *FD, llvm::DIFile Unit);
llvm::DIArray
CollectCXXTemplateParams(const ClassTemplateSpecializationDecl *TS,
llvm::DIFile F);
llvm::DIType createFieldType(StringRef name, QualType type,
uint64_t sizeInBitsOverride, SourceLocation loc,
AccessSpecifier AS, uint64_t offsetInBits,
llvm::DIFile tunit,
llvm::DIDescriptor scope);
void CollectRecordStaticVars(const RecordDecl *, llvm::DIType);
void CollectRecordFields(const RecordDecl *Decl, llvm::DIFile F,
SmallVectorImpl<llvm::Value *> &E,
llvm::DIType RecordTy);
void CollectVTableInfo(const CXXRecordDecl *Decl,
llvm::DIFile F,
SmallVectorImpl<llvm::Value *> &EltTys);
void CreateLexicalBlock(SourceLocation Loc);
public:
CGDebugInfo(CodeGenModule &CGM);
~CGDebugInfo();
void finalize(void);
void setLocation(SourceLocation Loc);
void EmitLocation(CGBuilderTy &Builder, SourceLocation Loc);
void EmitFunctionStart(GlobalDecl GD, QualType FnType,
llvm::Function *Fn, CGBuilderTy &Builder);
void EmitFunctionEnd(CGBuilderTy &Builder);
void EmitLexicalBlockStart(CGBuilderTy &Builder, SourceLocation Loc);
void EmitLexicalBlockEnd(CGBuilderTy &Builder, SourceLocation Loc);
void EmitDeclareOfAutoVariable(const VarDecl *Decl, llvm::Value *AI,
CGBuilderTy &Builder);
void EmitDeclareOfBlockDeclRefVariable(const VarDecl *variable,
llvm::Value *storage,
CGBuilderTy &Builder,
const CGBlockInfo &blockInfo);
void EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI,
unsigned ArgNo, CGBuilderTy &Builder);
void EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block,
llvm::Value *addr,
CGBuilderTy &Builder);
void EmitGlobalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
void EmitGlobalVariable(llvm::GlobalVariable *GV, ObjCInterfaceDecl *Decl);
void EmitGlobalVariable(const ValueDecl *VD, llvm::Constant *Init);
llvm::DIType getOrCreateRecordType(QualType Ty, SourceLocation L);
private:
void EmitDeclare(const VarDecl *decl, unsigned Tag, llvm::Value *AI,
unsigned ArgNo, CGBuilderTy &Builder);
llvm::DIType EmitTypeForVarWithBlocksAttr(const ValueDecl *VD,
uint64_t *OffSet);
llvm::DIDescriptor getContextDescriptor(const Decl *Decl);
llvm::DIType createRecordFwdDecl(const RecordDecl *, llvm::DIDescriptor);
llvm::DIDescriptor createContextChain(const Decl *Decl);
StringRef getCurrentDirname();
void CreateCompileUnit();
llvm::DIFile getOrCreateFile(SourceLocation Loc);
llvm::DIFile getOrCreateMainFile();
llvm::DIType getOrCreateType(QualType Ty, llvm::DIFile F);
llvm::DIType getOrCreateLimitedType(QualType Ty, llvm::DIFile F);
llvm::DIType CreateTypeNode(QualType Ty, llvm::DIFile F);
llvm::DIType CreateLimitedTypeNode(QualType Ty, llvm::DIFile F);
llvm::DIType CreateMemberType(llvm::DIFile Unit, QualType FType,
StringRef Name, uint64_t *Offset);
llvm::DISubprogram getFunctionDeclaration(const Decl *D);
StringRef getFunctionName(const FunctionDecl *FD);
StringRef getObjCMethodName(const ObjCMethodDecl *FD);
StringRef getSelectorName(Selector S);
StringRef getClassName(const RecordDecl *RD);
StringRef getVTableName(const CXXRecordDecl *Decl);
unsigned getLineNumber(SourceLocation Loc);
unsigned getColumnNumber(SourceLocation Loc);
};
} }
#endif