freebsd-nq/lib/CodeGen/CGDebugInfo.h

214 lines
8.5 KiB
C
Raw Normal View History

2009-06-02 17:58:47 +00:00
//===--- CGDebugInfo.h - DebugInfo for LLVM CodeGen -------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
2009-10-14 18:03:49 +00:00
// This is the source level debug info generator for llvm translation.
2009-06-02 17:58:47 +00:00
//
//===----------------------------------------------------------------------===//
#ifndef CLANG_CODEGEN_CGDEBUGINFO_H
#define CLANG_CODEGEN_CGDEBUGINFO_H
#include "clang/AST/Type.h"
2009-10-14 18:03:49 +00:00
#include "clang/AST/Expr.h"
2009-06-02 17:58:47 +00:00
#include "clang/Basic/SourceLocation.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/Analysis/DebugInfo.h"
2009-10-14 18:03:49 +00:00
#include "llvm/Support/ValueHandle.h"
2010-01-15 15:39:40 +00:00
#include "llvm/Support/Allocator.h"
2009-06-02 17:58:47 +00:00
#include <map>
#include "CGBuilder.h"
2009-10-14 18:03:49 +00:00
namespace llvm {
class MDNode;
}
2009-06-02 17:58:47 +00:00
namespace clang {
class VarDecl;
class ObjCInterfaceDecl;
namespace CodeGen {
class CodeGenModule;
2009-10-14 18:03:49 +00:00
class CodeGenFunction;
2010-01-15 15:39:40 +00:00
class GlobalDecl;
2009-06-02 17:58:47 +00:00
2009-10-14 18:03:49 +00:00
/// CGDebugInfo - This class gathers all debug information during compilation
/// and is responsible for emitting to llvm globals or pass directly to
2009-06-02 17:58:47 +00:00
/// the backend.
class CGDebugInfo {
2009-12-15 18:49:47 +00:00
CodeGenModule &CGM;
2009-06-02 17:58:47 +00:00
llvm::DIFactory DebugFactory;
2010-03-10 17:45:58 +00:00
llvm::DICompileUnit TheCU;
2009-06-02 17:58:47 +00:00
SourceLocation CurLoc, PrevLoc;
2010-02-16 09:31:36 +00:00
llvm::DIType VTablePtrType;
2010-03-10 17:45:58 +00:00
/// FwdDeclCount - This counter is used to ensure unique names for forward
/// record decls.
unsigned FwdDeclCount;
2009-06-02 17:58:47 +00:00
/// TypeCache - Cache of previously constructed Types.
// FIXME: Eliminate this map. Be careful of iterator invalidation.
2009-10-14 18:03:49 +00:00
std::map<void *, llvm::WeakVH> TypeCache;
2009-06-02 17:58:47 +00:00
bool BlockLiteralGenericSet;
llvm::DIType BlockLiteralGeneric;
2009-11-18 14:59:57 +00:00
std::vector<llvm::TrackingVH<llvm::MDNode> > RegionStack;
2010-02-16 09:31:36 +00:00
llvm::DenseMap<const Decl *, llvm::WeakVH> RegionMap;
2009-06-02 17:58:47 +00:00
2010-02-16 09:31:36 +00:00
/// DebugInfoNames - This is a storage for names that are
2010-01-15 15:39:40 +00:00
/// constructed on demand. For example, C++ destructors, C++ operators etc..
2010-02-16 09:31:36 +00:00
llvm::BumpPtrAllocator DebugInfoNames;
2010-01-15 15:39:40 +00:00
2010-01-23 11:10:26 +00:00
llvm::DenseMap<const FunctionDecl *, llvm::WeakVH> SPCache;
2010-02-16 09:31:36 +00:00
llvm::DenseMap<const NamespaceDecl *, llvm::WeakVH> NameSpaceCache;
2010-01-23 11:10:26 +00:00
2009-06-02 17:58:47 +00:00
/// Helper functions for getOrCreateType.
2010-03-10 17:45:58 +00:00
llvm::DIType CreateType(const BuiltinType *Ty, llvm::DIFile F);
llvm::DIType CreateType(const ComplexType *Ty, llvm::DIFile F);
llvm::DIType CreateQualifiedType(QualType Ty, llvm::DIFile F);
llvm::DIType CreateType(const TypedefType *Ty, llvm::DIFile F);
2009-10-14 18:03:49 +00:00
llvm::DIType CreateType(const ObjCObjectPointerType *Ty,
2010-03-10 17:45:58 +00:00
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 TagType *Ty, llvm::DIFile F);
llvm::DIType CreateType(const RecordType *Ty, llvm::DIFile F);
llvm::DIType CreateType(const ObjCInterfaceType *Ty, llvm::DIFile F);
llvm::DIType CreateType(const EnumType *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 MemberPointerType *Ty, llvm::DIFile F);
2010-02-16 09:31:36 +00:00
llvm::DIType getOrCreateMethodType(const CXXMethodDecl *Method,
2010-03-10 17:45:58 +00:00
llvm::DIFile F);
llvm::DIType getOrCreateVTablePtrType(llvm::DIFile F);
2010-02-16 09:31:36 +00:00
llvm::DINameSpace getOrCreateNameSpace(const NamespaceDecl *N,
llvm::DIDescriptor Unit);
2009-11-18 14:59:57 +00:00
llvm::DIType CreatePointerLikeType(unsigned Tag,
const Type *Ty, QualType PointeeTy,
2010-03-10 17:45:58 +00:00
llvm::DIFile F);
2010-02-16 09:31:36 +00:00
llvm::DISubprogram CreateCXXMemberFunction(const CXXMethodDecl *Method,
2010-03-10 17:45:58 +00:00
llvm::DIFile F,
2010-02-16 09:31:36 +00:00
llvm::DICompositeType &RecordTy);
2010-01-23 11:10:26 +00:00
void CollectCXXMemberFunctions(const CXXRecordDecl *Decl,
2010-03-10 17:45:58 +00:00
llvm::DIFile F,
2010-01-23 11:10:26 +00:00
llvm::SmallVectorImpl<llvm::DIDescriptor> &E,
llvm::DICompositeType &T);
2010-02-16 09:31:36 +00:00
void CollectCXXBases(const CXXRecordDecl *Decl,
2010-03-10 17:45:58 +00:00
llvm::DIFile F,
2010-02-16 09:31:36 +00:00
llvm::SmallVectorImpl<llvm::DIDescriptor> &EltTys,
llvm::DICompositeType &RecordTy);
2010-03-10 17:45:58 +00:00
void CollectRecordFields(const RecordDecl *Decl, llvm::DIFile F,
2010-01-23 11:10:26 +00:00
llvm::SmallVectorImpl<llvm::DIDescriptor> &E);
2010-02-16 09:31:36 +00:00
void CollectVtableInfo(const CXXRecordDecl *Decl,
2010-03-10 17:45:58 +00:00
llvm::DIFile F,
2010-02-16 09:31:36 +00:00
llvm::SmallVectorImpl<llvm::DIDescriptor> &EltTys);
2009-06-02 17:58:47 +00:00
public:
2009-12-15 18:49:47 +00:00
CGDebugInfo(CodeGenModule &CGM);
2009-06-02 17:58:47 +00:00
~CGDebugInfo();
/// setLocation - Update the current source location. If \arg loc is
/// invalid it is ignored.
void setLocation(SourceLocation Loc);
/// EmitStopPoint - Emit a call to llvm.dbg.stoppoint to indicate a change of
/// source line.
void EmitStopPoint(llvm::Function *Fn, CGBuilderTy &Builder);
/// EmitFunctionStart - Emit a call to llvm.dbg.function.start to indicate
/// start of a new function.
2010-01-15 15:39:40 +00:00
void EmitFunctionStart(GlobalDecl GD, QualType FnType,
2009-06-02 17:58:47 +00:00
llvm::Function *Fn, CGBuilderTy &Builder);
2009-10-14 18:03:49 +00:00
2009-06-02 17:58:47 +00:00
/// EmitRegionStart - Emit a call to llvm.dbg.region.start to indicate start
2009-10-14 18:03:49 +00:00
/// of a new block.
2009-06-02 17:58:47 +00:00
void EmitRegionStart(llvm::Function *Fn, CGBuilderTy &Builder);
2009-10-14 18:03:49 +00:00
/// EmitRegionEnd - Emit call to llvm.dbg.region.end to indicate end of a
2009-06-02 17:58:47 +00:00
/// block.
void EmitRegionEnd(llvm::Function *Fn, CGBuilderTy &Builder);
/// EmitDeclareOfAutoVariable - Emit call to llvm.dbg.declare for an automatic
/// variable declaration.
void EmitDeclareOfAutoVariable(const VarDecl *Decl, llvm::Value *AI,
CGBuilderTy &Builder);
2009-10-14 18:03:49 +00:00
/// EmitDeclareOfBlockDeclRefVariable - Emit call to llvm.dbg.declare for an
/// imported variable declaration in a block.
void EmitDeclareOfBlockDeclRefVariable(const BlockDeclRefExpr *BDRE,
llvm::Value *AI,
CGBuilderTy &Builder,
CodeGenFunction *CGF);
2009-06-02 17:58:47 +00:00
/// EmitDeclareOfArgVariable - Emit call to llvm.dbg.declare for an argument
/// variable declaration.
void EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI,
CGBuilderTy &Builder);
2009-10-14 18:03:49 +00:00
2009-06-02 17:58:47 +00:00
/// EmitGlobalVariable - Emit information about a global variable.
void EmitGlobalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
/// EmitGlobalVariable - Emit information about an objective-c interface.
void EmitGlobalVariable(llvm::GlobalVariable *GV, ObjCInterfaceDecl *Decl);
2009-10-14 18:03:49 +00:00
2009-06-02 17:58:47 +00:00
private:
/// EmitDeclare - Emit call to llvm.dbg.declare for a variable declaration.
void EmitDeclare(const VarDecl *decl, unsigned Tag, llvm::Value *AI,
CGBuilderTy &Builder);
2009-10-14 18:03:49 +00:00
/// EmitDeclare - Emit call to llvm.dbg.declare for a variable declaration.
void EmitDeclare(const BlockDeclRefExpr *BDRE, unsigned Tag, llvm::Value *AI,
CGBuilderTy &Builder, CodeGenFunction *CGF);
2010-02-16 09:31:36 +00:00
// EmitTypeForVarWithBlocksAttr - Build up structure info for the byref.
// See BuildByRefType.
llvm::DIType EmitTypeForVarWithBlocksAttr(const ValueDecl *VD,
uint64_t *OffSet);
/// getContextDescriptor - Get context info for the decl.
llvm::DIDescriptor getContextDescriptor(const Decl *Decl,
llvm::DIDescriptor &CU);
2009-10-14 18:03:49 +00:00
2010-03-10 17:45:58 +00:00
/// CreateCompileUnit - Create new compile unit.
void CreateCompileUnit();
/// getOrCreateFile - Get the file debug info descriptor for the input
/// location.
llvm::DIFile getOrCreateFile(SourceLocation Loc);
2009-06-02 17:58:47 +00:00
/// getOrCreateType - Get the type from the cache or create a new type if
/// necessary.
2010-03-10 17:45:58 +00:00
llvm::DIType getOrCreateType(QualType Ty, llvm::DIFile F);
2009-10-14 18:03:49 +00:00
/// CreateTypeNode - Create type metadata for a source language type.
2010-03-10 17:45:58 +00:00
llvm::DIType CreateTypeNode(QualType Ty, llvm::DIFile F);
2010-01-15 15:39:40 +00:00
/// getFunctionName - Get function name for the given FunctionDecl. If the
/// name is constructred on demand (e.g. C++ destructor) then the name
/// is stored on the side.
llvm::StringRef getFunctionName(const FunctionDecl *FD);
2010-02-16 09:31:36 +00:00
/// getVtableName - Get vtable name for the given Class.
llvm::StringRef getVtableName(const CXXRecordDecl *Decl);
2009-06-02 17:58:47 +00:00
};
} // namespace CodeGen
} // namespace clang
2009-10-14 18:03:49 +00:00
2009-06-02 17:58:47 +00:00
#endif