2008-10-31 06:54:29 +03:00
|
|
|
//===--- CGDebugInfo.h - DebugInfo for LLVM CodeGen -------------*- C++ -*-===//
|
2008-05-08 12:54:20 +04:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2009-09-09 19:08:12 +04:00
|
|
|
// This is the source level debug info generator for llvm translation.
|
2008-05-08 12:54:20 +04:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef CLANG_CODEGEN_CGDEBUGINFO_H
|
|
|
|
#define CLANG_CODEGEN_CGDEBUGINFO_H
|
|
|
|
|
2008-05-25 09:15:42 +04:00
|
|
|
#include "clang/AST/Type.h"
|
2009-09-30 06:43:10 +04:00
|
|
|
#include "clang/AST/Expr.h"
|
2008-05-08 12:54:20 +04:00
|
|
|
#include "clang/Basic/SourceLocation.h"
|
2008-11-10 09:08:34 +03:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
|
|
|
#include "llvm/Analysis/DebugInfo.h"
|
2009-09-19 23:27:24 +04:00
|
|
|
#include "llvm/Support/ValueHandle.h"
|
2010-01-14 03:36:21 +03:00
|
|
|
#include "llvm/Support/Allocator.h"
|
2008-05-08 12:54:20 +04:00
|
|
|
#include <map>
|
|
|
|
|
2008-11-01 04:53:16 +03:00
|
|
|
#include "CGBuilder.h"
|
2008-05-08 12:54:20 +04:00
|
|
|
|
2009-09-19 23:27:24 +04:00
|
|
|
namespace llvm {
|
|
|
|
class MDNode;
|
|
|
|
}
|
|
|
|
|
2008-05-08 12:54:20 +04:00
|
|
|
namespace clang {
|
2008-05-30 14:30:31 +04:00
|
|
|
class VarDecl;
|
2009-02-27 00:10:26 +03:00
|
|
|
class ObjCInterfaceDecl;
|
2008-11-01 04:53:16 +03:00
|
|
|
|
2008-05-08 12:54:20 +04:00
|
|
|
namespace CodeGen {
|
|
|
|
class CodeGenModule;
|
2009-09-30 06:43:10 +04:00
|
|
|
class CodeGenFunction;
|
2010-01-14 03:36:21 +03:00
|
|
|
class GlobalDecl;
|
2008-05-08 12:54:20 +04:00
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
/// CGDebugInfo - This class gathers all debug information during compilation
|
|
|
|
/// and is responsible for emitting to llvm globals or pass directly to
|
2008-05-25 09:15:42 +04:00
|
|
|
/// the backend.
|
2008-05-08 12:54:20 +04:00
|
|
|
class CGDebugInfo {
|
2009-12-06 21:00:51 +03:00
|
|
|
CodeGenModule &CGM;
|
2009-04-23 22:09:16 +04:00
|
|
|
bool isMainCompileUnitCreated;
|
2008-11-10 09:08:34 +03:00
|
|
|
llvm::DIFactory DebugFactory;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2008-11-10 09:08:34 +03:00
|
|
|
SourceLocation CurLoc, PrevLoc;
|
2008-05-08 12:54:20 +04:00
|
|
|
|
|
|
|
/// CompileUnitCache - Cache of previously constructed CompileUnits.
|
2009-04-18 01:06:59 +04:00
|
|
|
llvm::DenseMap<unsigned, llvm::DICompileUnit> CompileUnitCache;
|
2008-05-25 09:15:42 +04:00
|
|
|
|
|
|
|
/// TypeCache - Cache of previously constructed Types.
|
2008-11-10 09:08:34 +03:00
|
|
|
// FIXME: Eliminate this map. Be careful of iterator invalidation.
|
2009-09-20 00:17:48 +04:00
|
|
|
std::map<void *, llvm::WeakVH> TypeCache;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-05-14 06:03:51 +04:00
|
|
|
bool BlockLiteralGenericSet;
|
|
|
|
llvm::DIType BlockLiteralGeneric;
|
|
|
|
|
2009-11-13 22:10:24 +03:00
|
|
|
std::vector<llvm::TrackingVH<llvm::MDNode> > RegionStack;
|
2008-05-22 05:40:10 +04:00
|
|
|
|
2010-01-14 03:36:21 +03:00
|
|
|
/// FunctionNames - This is a storage for function names that are
|
|
|
|
/// constructed on demand. For example, C++ destructors, C++ operators etc..
|
|
|
|
llvm::BumpPtrAllocator FunctionNames;
|
|
|
|
|
2008-05-25 09:15:42 +04:00
|
|
|
/// Helper functions for getOrCreateType.
|
2008-11-10 09:08:34 +03:00
|
|
|
llvm::DIType CreateType(const BuiltinType *Ty, llvm::DICompileUnit U);
|
2009-04-23 10:13:01 +04:00
|
|
|
llvm::DIType CreateType(const ComplexType *Ty, llvm::DICompileUnit U);
|
2009-09-25 05:40:47 +04:00
|
|
|
llvm::DIType CreateQualifiedType(QualType Ty, llvm::DICompileUnit U);
|
2008-11-10 09:08:34 +03:00
|
|
|
llvm::DIType CreateType(const TypedefType *Ty, llvm::DICompileUnit U);
|
2009-09-09 19:08:12 +04:00
|
|
|
llvm::DIType CreateType(const ObjCObjectPointerType *Ty,
|
2009-07-14 05:20:56 +04:00
|
|
|
llvm::DICompileUnit Unit);
|
2008-11-10 09:08:34 +03:00
|
|
|
llvm::DIType CreateType(const PointerType *Ty, llvm::DICompileUnit U);
|
2009-05-14 06:03:51 +04:00
|
|
|
llvm::DIType CreateType(const BlockPointerType *Ty, llvm::DICompileUnit U);
|
2008-11-10 09:08:34 +03:00
|
|
|
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);
|
2009-02-27 00:10:26 +03:00
|
|
|
llvm::DIType CreateType(const ObjCInterfaceType *Ty, llvm::DICompileUnit U);
|
2008-11-10 09:08:34 +03:00
|
|
|
llvm::DIType CreateType(const EnumType *Ty, llvm::DICompileUnit U);
|
|
|
|
llvm::DIType CreateType(const ArrayType *Ty, llvm::DICompileUnit U);
|
2009-11-06 22:19:55 +03:00
|
|
|
llvm::DIType CreateType(const LValueReferenceType *Ty, llvm::DICompileUnit U);
|
2009-12-06 21:00:51 +03:00
|
|
|
llvm::DIType CreateType(const MemberPointerType *Ty, llvm::DICompileUnit U);
|
|
|
|
|
2009-11-06 22:19:55 +03:00
|
|
|
llvm::DIType CreatePointerLikeType(unsigned Tag,
|
|
|
|
const Type *Ty, QualType PointeeTy,
|
|
|
|
llvm::DICompileUnit U);
|
2010-01-19 03:00:59 +03:00
|
|
|
void CollectRecordFields(const RecordDecl *Decl, llvm::DICompileUnit U,
|
|
|
|
llvm::SmallVectorImpl<llvm::DIDescriptor> &E);
|
2008-05-08 12:54:20 +04:00
|
|
|
public:
|
2009-12-06 21:00:51 +03:00
|
|
|
CGDebugInfo(CodeGenModule &CGM);
|
2008-05-08 12:54:20 +04:00
|
|
|
~CGDebugInfo();
|
|
|
|
|
2008-10-17 20:15:48 +04:00
|
|
|
/// setLocation - Update the current source location. If \arg loc is
|
|
|
|
/// invalid it is ignored.
|
2008-11-10 09:08:34 +03:00
|
|
|
void setLocation(SourceLocation Loc);
|
2008-05-08 12:54:20 +04:00
|
|
|
|
|
|
|
/// EmitStopPoint - Emit a call to llvm.dbg.stoppoint to indicate a change of
|
|
|
|
/// source line.
|
2008-11-01 04:53:16 +03:00
|
|
|
void EmitStopPoint(llvm::Function *Fn, CGBuilderTy &Builder);
|
2008-05-25 09:15:42 +04:00
|
|
|
|
|
|
|
/// EmitFunctionStart - Emit a call to llvm.dbg.function.start to indicate
|
2008-10-18 22:22:23 +04:00
|
|
|
/// start of a new function.
|
2010-01-14 03:36:21 +03:00
|
|
|
void EmitFunctionStart(GlobalDecl GD, QualType FnType,
|
2008-11-01 04:53:16 +03:00
|
|
|
llvm::Function *Fn, CGBuilderTy &Builder);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2008-05-25 09:15:42 +04:00
|
|
|
/// EmitRegionStart - Emit a call to llvm.dbg.region.start to indicate start
|
2009-09-09 19:08:12 +04:00
|
|
|
/// of a new block.
|
2008-11-01 04:53:16 +03:00
|
|
|
void EmitRegionStart(llvm::Function *Fn, CGBuilderTy &Builder);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
/// EmitRegionEnd - Emit call to llvm.dbg.region.end to indicate end of a
|
2008-05-08 12:54:20 +04:00
|
|
|
/// block.
|
2008-11-01 04:53:16 +03:00
|
|
|
void EmitRegionEnd(llvm::Function *Fn, CGBuilderTy &Builder);
|
2008-05-30 14:30:31 +04:00
|
|
|
|
2008-11-10 09:08:34 +03:00
|
|
|
/// EmitDeclareOfAutoVariable - Emit call to llvm.dbg.declare for an automatic
|
|
|
|
/// variable declaration.
|
|
|
|
void EmitDeclareOfAutoVariable(const VarDecl *Decl, llvm::Value *AI,
|
|
|
|
CGBuilderTy &Builder);
|
2008-06-05 12:59:10 +04:00
|
|
|
|
2009-09-30 06:43:10 +04: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);
|
|
|
|
|
2008-11-10 09:08:34 +03:00
|
|
|
/// EmitDeclareOfArgVariable - Emit call to llvm.dbg.declare for an argument
|
|
|
|
/// variable declaration.
|
|
|
|
void EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI,
|
|
|
|
CGBuilderTy &Builder);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2008-06-05 12:59:10 +04:00
|
|
|
/// EmitGlobalVariable - Emit information about a global variable.
|
2008-11-10 09:08:34 +03:00
|
|
|
void EmitGlobalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
|
2009-02-27 00:10:26 +03:00
|
|
|
|
|
|
|
/// EmitGlobalVariable - Emit information about an objective-c interface.
|
|
|
|
void EmitGlobalVariable(llvm::GlobalVariable *GV, ObjCInterfaceDecl *Decl);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2008-11-03 12:11:11 +03:00
|
|
|
private:
|
2008-11-10 09:08:34 +03:00
|
|
|
/// EmitDeclare - Emit call to llvm.dbg.declare for a variable declaration.
|
|
|
|
void EmitDeclare(const VarDecl *decl, unsigned Tag, llvm::Value *AI,
|
|
|
|
CGBuilderTy &Builder);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-09-30 06:43:10 +04: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);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-06 04:35:31 +04:00
|
|
|
/// getContext - Get context info for the decl.
|
|
|
|
llvm::DIDescriptor getContext(const VarDecl *Decl,llvm::DIDescriptor &CU);
|
|
|
|
|
2008-05-25 09:15:42 +04:00
|
|
|
/// getOrCreateCompileUnit - Get the compile unit from the cache or create a
|
|
|
|
/// new one if necessary.
|
2008-11-10 09:08:34 +03:00
|
|
|
llvm::DICompileUnit getOrCreateCompileUnit(SourceLocation Loc);
|
2008-05-25 09:15:42 +04:00
|
|
|
|
|
|
|
/// getOrCreateType - Get the type from the cache or create a new type if
|
|
|
|
/// necessary.
|
2008-11-10 09:08:34 +03:00
|
|
|
llvm::DIType getOrCreateType(QualType Ty, llvm::DICompileUnit Unit);
|
2009-09-19 23:27:14 +04:00
|
|
|
|
|
|
|
/// CreateTypeNode - Create type metadata for a source language type.
|
|
|
|
llvm::DIType CreateTypeNode(QualType Ty, llvm::DICompileUnit Unit);
|
2010-01-14 03:36:21 +03: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);
|
2008-05-08 12:54:20 +04:00
|
|
|
};
|
|
|
|
} // namespace CodeGen
|
|
|
|
} // namespace clang
|
|
|
|
|
2009-10-06 22:36:08 +04:00
|
|
|
|
2008-05-08 12:54:20 +04:00
|
|
|
#endif
|