2012-12-18 22:30:41 +08: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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2014-07-09 22:06:35 +08:00
|
|
|
// This is the source-level debug info generator for llvm translation.
|
2012-12-18 22:30:41 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef CLANG_CODEGEN_CGDEBUGINFO_H
|
|
|
|
#define CLANG_CODEGEN_CGDEBUGINFO_H
|
|
|
|
|
|
|
|
#include "CGBuilder.h"
|
|
|
|
#include "clang/AST/Expr.h"
|
|
|
|
#include "clang/AST/Type.h"
|
|
|
|
#include "clang/Basic/SourceLocation.h"
|
2013-05-16 08:45:23 +08:00
|
|
|
#include "clang/Frontend/CodeGenOptions.h"
|
2012-12-18 22:30:41 +08:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2014-03-06 08:22:29 +08:00
|
|
|
#include "llvm/IR/DIBuilder.h"
|
2014-03-06 08:46:56 +08:00
|
|
|
#include "llvm/IR/DebugInfo.h"
|
2014-03-04 19:18:19 +08:00
|
|
|
#include "llvm/IR/ValueHandle.h"
|
2012-12-18 22:30:41 +08:00
|
|
|
#include "llvm/Support/Allocator.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class MDNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
class CXXMethodDecl;
|
|
|
|
class VarDecl;
|
|
|
|
class ObjCInterfaceDecl;
|
2013-03-07 06:03:30 +08:00
|
|
|
class ObjCIvarDecl;
|
2012-12-18 22:30:41 +08:00
|
|
|
class ClassTemplateSpecializationDecl;
|
|
|
|
class GlobalDecl;
|
2013-05-20 12:58:53 +08:00
|
|
|
class UsingDecl;
|
2012-12-18 22:30:41 +08:00
|
|
|
|
|
|
|
namespace CodeGen {
|
|
|
|
class CodeGenModule;
|
|
|
|
class CodeGenFunction;
|
|
|
|
class CGBlockInfo;
|
|
|
|
|
|
|
|
/// CGDebugInfo - This class gathers all debug information during compilation
|
|
|
|
/// and is responsible for emitting to llvm globals or pass directly to
|
|
|
|
/// the backend.
|
|
|
|
class CGDebugInfo {
|
2013-07-18 09:36:04 +08:00
|
|
|
friend class ArtificialLocation;
|
2014-01-17 08:15:10 +08:00
|
|
|
friend class SaveAndRestoreLocation;
|
2012-12-18 22:30:41 +08:00
|
|
|
CodeGenModule &CGM;
|
2013-05-21 03:59:06 +08:00
|
|
|
const CodeGenOptions::DebugInfoKind DebugKind;
|
2012-12-18 22:30:41 +08:00
|
|
|
llvm::DIBuilder DBuilder;
|
|
|
|
llvm::DICompileUnit TheCU;
|
|
|
|
SourceLocation CurLoc, PrevLoc;
|
|
|
|
llvm::DIType VTablePtrType;
|
|
|
|
llvm::DIType ClassTy;
|
2013-04-03 06:59:11 +08:00
|
|
|
llvm::DICompositeType ObjTy;
|
2012-12-18 22:30:41 +08:00
|
|
|
llvm::DIType SelTy;
|
2012-12-18 22:38:23 +08:00
|
|
|
llvm::DIType OCLImage1dDITy, OCLImage1dArrayDITy, OCLImage1dBufferDITy;
|
|
|
|
llvm::DIType OCLImage2dDITy, OCLImage2dArrayDITy;
|
|
|
|
llvm::DIType OCLImage3dDITy;
|
2013-01-20 20:31:11 +08:00
|
|
|
llvm::DIType OCLEventDITy;
|
2013-07-15 05:12:44 +08:00
|
|
|
llvm::DIType BlockLiteralGeneric;
|
2013-05-16 08:52:23 +08:00
|
|
|
|
2012-12-18 22:30:41 +08:00
|
|
|
/// TypeCache - Cache of previously constructed Types.
|
2014-05-06 11:42:01 +08:00
|
|
|
llvm::DenseMap<const void *, llvm::WeakVH> TypeCache;
|
2012-12-18 22:30:41 +08:00
|
|
|
|
2014-05-06 07:23:53 +08:00
|
|
|
struct ObjCInterfaceCacheEntry {
|
|
|
|
const ObjCInterfaceType *Type;
|
|
|
|
llvm::DIType Decl;
|
|
|
|
llvm::DIFile Unit;
|
|
|
|
ObjCInterfaceCacheEntry(const ObjCInterfaceType *Type, llvm::DIType Decl,
|
|
|
|
llvm::DIFile Unit)
|
|
|
|
: Type(Type), Decl(Decl), Unit(Unit) {}
|
|
|
|
};
|
|
|
|
|
2013-03-07 06:03:30 +08:00
|
|
|
/// ObjCInterfaceCache - Cache of previously constructed interfaces
|
2014-05-06 07:23:53 +08:00
|
|
|
/// which may change.
|
|
|
|
llvm::SmallVector<ObjCInterfaceCacheEntry, 32> ObjCInterfaceCache;
|
2013-03-07 06:03:30 +08:00
|
|
|
|
2013-03-12 02:33:46 +08:00
|
|
|
/// RetainedTypes - list of interfaces we want to keep even if orphaned.
|
|
|
|
std::vector<void *> RetainedTypes;
|
|
|
|
|
2012-12-18 22:30:41 +08:00
|
|
|
/// ReplaceMap - Cache of forward declared types to RAUW at the end of
|
|
|
|
/// compilation.
|
2014-05-06 11:42:01 +08:00
|
|
|
std::vector<std::pair<const TagType *, llvm::WeakVH>> ReplaceMap;
|
2012-12-18 22:30:41 +08:00
|
|
|
|
|
|
|
// LexicalBlockStack - Keep track of our current nested lexical block.
|
|
|
|
std::vector<llvm::TrackingVH<llvm::MDNode> > LexicalBlockStack;
|
|
|
|
llvm::DenseMap<const Decl *, llvm::WeakVH> RegionMap;
|
|
|
|
// FnBeginRegionCount - Keep track of LexicalBlockStack counter at the
|
|
|
|
// beginning of a function. This is used to pop unbalanced regions at
|
|
|
|
// the end of a function.
|
|
|
|
std::vector<unsigned> FnBeginRegionCount;
|
|
|
|
|
|
|
|
/// DebugInfoNames - This is a storage for names that are
|
|
|
|
/// constructed on demand. For example, C++ destructors, C++ operators etc..
|
|
|
|
llvm::BumpPtrAllocator DebugInfoNames;
|
|
|
|
StringRef CWDName;
|
|
|
|
|
|
|
|
llvm::DenseMap<const char *, llvm::WeakVH> DIFileCache;
|
|
|
|
llvm::DenseMap<const FunctionDecl *, llvm::WeakVH> SPCache;
|
2013-05-20 12:58:53 +08:00
|
|
|
/// \brief Cache declarations relevant to DW_TAG_imported_declarations (C++
|
|
|
|
/// using declarations) that aren't covered by other more specific caches.
|
|
|
|
llvm::DenseMap<const Decl *, llvm::WeakVH> DeclCache;
|
2012-12-18 22:30:41 +08:00
|
|
|
llvm::DenseMap<const NamespaceDecl *, llvm::WeakVH> NameSpaceCache;
|
2013-05-21 06:50:41 +08:00
|
|
|
llvm::DenseMap<const NamespaceAliasDecl *, llvm::WeakVH> NamespaceAliasCache;
|
2013-01-16 09:22:32 +08:00
|
|
|
llvm::DenseMap<const Decl *, llvm::WeakVH> StaticDataMemberCache;
|
2012-12-18 22:30:41 +08:00
|
|
|
|
|
|
|
/// Helper functions for getOrCreateType.
|
2013-03-07 06:03:30 +08:00
|
|
|
unsigned Checksum(const ObjCInterfaceDecl *InterfaceDecl);
|
2012-12-18 22:30:41 +08:00
|
|
|
llvm::DIType CreateType(const BuiltinType *Ty);
|
|
|
|
llvm::DIType CreateType(const ComplexType *Ty);
|
2013-09-05 06:03:57 +08:00
|
|
|
llvm::DIType CreateQualifiedType(QualType Ty, llvm::DIFile Fg);
|
|
|
|
llvm::DIType CreateType(const TypedefType *Ty, llvm::DIFile Fg);
|
2014-04-07 01:14:06 +08:00
|
|
|
llvm::DIType CreateType(const TemplateSpecializationType *Ty, llvm::DIFile Fg);
|
2012-12-18 22:30:41 +08:00
|
|
|
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);
|
2013-09-05 06:03:57 +08:00
|
|
|
llvm::DIType CreateType(const RecordType *Tyg);
|
2013-08-16 04:49:17 +08:00
|
|
|
llvm::DIType CreateTypeDefinition(const RecordType *Ty);
|
2013-08-21 05:03:29 +08:00
|
|
|
llvm::DICompositeType CreateLimitedType(const RecordType *Ty);
|
2013-08-19 00:55:33 +08:00
|
|
|
void CollectContainingType(const CXXRecordDecl *RD, llvm::DICompositeType CT);
|
2012-12-18 22:30:41 +08:00
|
|
|
llvm::DIType CreateType(const ObjCInterfaceType *Ty, llvm::DIFile F);
|
2014-05-06 07:23:53 +08:00
|
|
|
llvm::DIType CreateTypeDefinition(const ObjCInterfaceType *Ty, llvm::DIFile F);
|
2012-12-18 22:30:41 +08:00
|
|
|
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);
|
2013-08-29 05:20:28 +08:00
|
|
|
llvm::DIType CreateEnumType(const EnumType *Ty);
|
2014-05-07 02:35:21 +08:00
|
|
|
llvm::DIType CreateTypeDefinition(const EnumType *Ty);
|
2013-03-30 03:20:29 +08:00
|
|
|
llvm::DIType CreateSelfType(const QualType &QualTy, llvm::DIType Ty);
|
2012-12-18 22:30:41 +08:00
|
|
|
llvm::DIType getTypeOrNull(const QualType);
|
2013-05-23 07:22:42 +08:00
|
|
|
llvm::DICompositeType getOrCreateMethodType(const CXXMethodDecl *Method,
|
|
|
|
llvm::DIFile F);
|
|
|
|
llvm::DICompositeType getOrCreateInstanceMethodType(
|
2013-01-08 07:06:35 +08:00
|
|
|
QualType ThisPtr, const FunctionProtoType *Func, llvm::DIFile Unit);
|
2013-05-23 07:22:42 +08:00
|
|
|
llvm::DICompositeType getOrCreateFunctionType(const Decl *D, QualType FnType,
|
|
|
|
llvm::DIFile F);
|
2012-12-18 22:30:41 +08:00
|
|
|
llvm::DIType getOrCreateVTablePtrType(llvm::DIFile F);
|
|
|
|
llvm::DINameSpace getOrCreateNameSpace(const NamespaceDecl *N);
|
2013-05-25 05:33:22 +08:00
|
|
|
llvm::DIType getOrCreateTypeDeclaration(QualType PointeeTy, llvm::DIFile F);
|
2014-05-07 20:49:30 +08:00
|
|
|
llvm::DIType CreatePointerLikeType(llvm::dwarf::Tag Tag,
|
2012-12-18 22:30:41 +08:00
|
|
|
const Type *Ty, QualType PointeeTy,
|
|
|
|
llvm::DIFile F);
|
2012-12-18 22:38:23 +08:00
|
|
|
|
2013-03-12 02:33:46 +08:00
|
|
|
llvm::Value *getCachedInterfaceTypeOrNull(const QualType Ty);
|
2012-12-18 22:38:23 +08:00
|
|
|
llvm::DIType getOrCreateStructPtrType(StringRef Name, llvm::DIType &Cache);
|
|
|
|
|
2012-12-18 22:30:41 +08:00
|
|
|
llvm::DISubprogram CreateCXXMemberFunction(const CXXMethodDecl *Method,
|
|
|
|
llvm::DIFile F,
|
|
|
|
llvm::DIType RecordTy);
|
2013-05-16 08:52:23 +08:00
|
|
|
|
2012-12-18 22:30:41 +08:00
|
|
|
void CollectCXXMemberFunctions(const CXXRecordDecl *Decl,
|
|
|
|
llvm::DIFile F,
|
|
|
|
SmallVectorImpl<llvm::Value *> &E,
|
|
|
|
llvm::DIType T);
|
|
|
|
|
|
|
|
void CollectCXXBases(const CXXRecordDecl *Decl,
|
|
|
|
llvm::DIFile F,
|
|
|
|
SmallVectorImpl<llvm::Value *> &EltTys,
|
|
|
|
llvm::DIType RecordTy);
|
2013-05-16 08:52:23 +08:00
|
|
|
|
2012-12-18 22:30:41 +08:00
|
|
|
llvm::DIArray
|
|
|
|
CollectTemplateParams(const TemplateParameterList *TPList,
|
2013-06-23 02:59:18 +08:00
|
|
|
ArrayRef<TemplateArgument> TAList,
|
2012-12-18 22:30:41 +08:00
|
|
|
llvm::DIFile Unit);
|
|
|
|
llvm::DIArray
|
|
|
|
CollectFunctionTemplateParams(const FunctionDecl *FD, llvm::DIFile Unit);
|
2013-05-16 08:52:23 +08:00
|
|
|
llvm::DIArray
|
2012-12-18 22:30:41 +08:00
|
|
|
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,
|
2013-09-08 11:45:05 +08:00
|
|
|
llvm::DIScope scope);
|
2013-01-16 09:22:32 +08:00
|
|
|
|
|
|
|
// Helpers for collecting fields of a record.
|
|
|
|
void CollectRecordLambdaFields(const CXXRecordDecl *CXXDecl,
|
|
|
|
SmallVectorImpl<llvm::Value *> &E,
|
|
|
|
llvm::DIType RecordTy);
|
2013-08-16 06:50:29 +08:00
|
|
|
llvm::DIDerivedType CreateRecordStaticField(const VarDecl *Var,
|
|
|
|
llvm::DIType RecordTy);
|
2013-01-16 09:22:32 +08:00
|
|
|
void CollectRecordNormalField(const FieldDecl *Field, uint64_t OffsetInBits,
|
|
|
|
llvm::DIFile F,
|
|
|
|
SmallVectorImpl<llvm::Value *> &E,
|
|
|
|
llvm::DIType RecordTy);
|
2012-12-18 22:30:41 +08:00
|
|
|
void CollectRecordFields(const RecordDecl *Decl, llvm::DIFile F,
|
|
|
|
SmallVectorImpl<llvm::Value *> &E,
|
2013-08-17 04:40:25 +08:00
|
|
|
llvm::DICompositeType RecordTy);
|
2012-12-18 22:30:41 +08:00
|
|
|
|
|
|
|
void CollectVTableInfo(const CXXRecordDecl *Decl,
|
|
|
|
llvm::DIFile F,
|
|
|
|
SmallVectorImpl<llvm::Value *> &EltTys);
|
|
|
|
|
|
|
|
// CreateLexicalBlock - Create a new lexical block node and push it on
|
|
|
|
// the stack.
|
|
|
|
void CreateLexicalBlock(SourceLocation Loc);
|
2013-05-16 08:52:23 +08:00
|
|
|
|
2012-12-18 22:30:41 +08:00
|
|
|
public:
|
|
|
|
CGDebugInfo(CodeGenModule &CGM);
|
|
|
|
~CGDebugInfo();
|
|
|
|
|
|
|
|
void finalize();
|
|
|
|
|
|
|
|
/// setLocation - Update the current source location. If \arg loc is
|
|
|
|
/// invalid it is ignored.
|
|
|
|
void setLocation(SourceLocation Loc);
|
|
|
|
|
2013-05-16 08:41:29 +08:00
|
|
|
/// getLocation - Return the current source location.
|
|
|
|
SourceLocation getLocation() const { return CurLoc; }
|
|
|
|
|
2012-12-18 22:30:41 +08:00
|
|
|
/// EmitLocation - Emit metadata to indicate a change in line/column
|
|
|
|
/// information in the source file.
|
2013-03-13 04:43:25 +08:00
|
|
|
/// \param ForceColumnInfo Assume DebugColumnInfo option is true.
|
|
|
|
void EmitLocation(CGBuilderTy &Builder, SourceLocation Loc,
|
2014-01-08 06:05:52 +08:00
|
|
|
bool ForceColumnInfo = false);
|
2012-12-18 22:30:41 +08:00
|
|
|
|
|
|
|
/// EmitFunctionStart - Emit a call to llvm.dbg.function.start to indicate
|
|
|
|
/// start of a new function.
|
2014-04-11 07:21:53 +08:00
|
|
|
/// \param Loc The location of the function header.
|
|
|
|
/// \param ScopeLoc The location of the function body.
|
|
|
|
void EmitFunctionStart(GlobalDecl GD,
|
|
|
|
SourceLocation Loc, SourceLocation ScopeLoc,
|
|
|
|
QualType FnType, llvm::Function *Fn,
|
|
|
|
CGBuilderTy &Builder);
|
2012-12-18 22:30:41 +08:00
|
|
|
|
|
|
|
/// EmitFunctionEnd - Constructs the debug code for exiting a function.
|
|
|
|
void EmitFunctionEnd(CGBuilderTy &Builder);
|
|
|
|
|
|
|
|
/// EmitLexicalBlockStart - Emit metadata to indicate the beginning of a
|
|
|
|
/// new lexical block and push the block onto the stack.
|
|
|
|
void EmitLexicalBlockStart(CGBuilderTy &Builder, SourceLocation Loc);
|
|
|
|
|
|
|
|
/// EmitLexicalBlockEnd - Emit metadata to indicate the end of a new lexical
|
|
|
|
/// block and pop the current block.
|
|
|
|
void EmitLexicalBlockEnd(CGBuilderTy &Builder, SourceLocation Loc);
|
|
|
|
|
|
|
|
/// EmitDeclareOfAutoVariable - Emit call to llvm.dbg.declare for an automatic
|
|
|
|
/// variable declaration.
|
|
|
|
void EmitDeclareOfAutoVariable(const VarDecl *Decl, llvm::Value *AI,
|
|
|
|
CGBuilderTy &Builder);
|
|
|
|
|
|
|
|
/// EmitDeclareOfBlockDeclRefVariable - Emit call to llvm.dbg.declare for an
|
|
|
|
/// imported variable declaration in a block.
|
|
|
|
void EmitDeclareOfBlockDeclRefVariable(const VarDecl *variable,
|
|
|
|
llvm::Value *storage,
|
|
|
|
CGBuilderTy &Builder,
|
|
|
|
const CGBlockInfo &blockInfo);
|
|
|
|
|
|
|
|
/// EmitDeclareOfArgVariable - Emit call to llvm.dbg.declare for an argument
|
|
|
|
/// variable declaration.
|
|
|
|
void EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI,
|
|
|
|
unsigned ArgNo, CGBuilderTy &Builder);
|
|
|
|
|
|
|
|
/// EmitDeclareOfBlockLiteralArgVariable - Emit call to
|
|
|
|
/// llvm.dbg.declare for the block-literal argument to a block
|
|
|
|
/// invocation function.
|
|
|
|
void EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block,
|
2013-03-15 01:53:33 +08:00
|
|
|
llvm::Value *Arg,
|
|
|
|
llvm::Value *LocalAddr,
|
2012-12-18 22:30:41 +08:00
|
|
|
CGBuilderTy &Builder);
|
|
|
|
|
|
|
|
/// EmitGlobalVariable - Emit information about a global variable.
|
2013-08-30 16:53:09 +08:00
|
|
|
void EmitGlobalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
|
2012-12-18 22:30:41 +08:00
|
|
|
|
2013-08-30 16:53:09 +08:00
|
|
|
/// EmitGlobalVariable - Emit global variable's debug info.
|
|
|
|
void EmitGlobalVariable(const ValueDecl *VD, llvm::Constant *Init);
|
2012-12-18 22:30:41 +08:00
|
|
|
|
2013-04-22 14:13:21 +08:00
|
|
|
/// \brief - Emit C++ using directive.
|
|
|
|
void EmitUsingDirective(const UsingDirectiveDecl &UD);
|
|
|
|
|
2013-05-20 12:58:53 +08:00
|
|
|
/// \brief - Emit C++ using declaration.
|
|
|
|
void EmitUsingDecl(const UsingDecl &UD);
|
|
|
|
|
2013-05-21 06:50:41 +08:00
|
|
|
/// \brief - Emit C++ namespace alias.
|
|
|
|
llvm::DIImportedEntity EmitNamespaceAlias(const NamespaceAliasDecl &NA);
|
|
|
|
|
2013-05-16 08:52:23 +08:00
|
|
|
/// getOrCreateRecordType - Emit record type's standalone debug info.
|
2012-12-18 22:30:41 +08:00
|
|
|
llvm::DIType getOrCreateRecordType(QualType Ty, SourceLocation L);
|
|
|
|
|
|
|
|
/// getOrCreateInterfaceType - Emit an objective c interface type standalone
|
|
|
|
/// debug info.
|
|
|
|
llvm::DIType getOrCreateInterfaceType(QualType Ty,
|
2013-05-16 08:45:23 +08:00
|
|
|
SourceLocation Loc);
|
2012-12-18 22:30:41 +08:00
|
|
|
|
2014-05-07 02:35:21 +08:00
|
|
|
void completeType(const EnumDecl *ED);
|
2013-08-16 04:49:17 +08:00
|
|
|
void completeType(const RecordDecl *RD);
|
|
|
|
void completeRequiredType(const RecordDecl *RD);
|
2013-08-20 09:28:15 +08:00
|
|
|
void completeClassData(const RecordDecl *RD);
|
2013-06-21 08:40:50 +08:00
|
|
|
|
2014-03-04 07:48:23 +08:00
|
|
|
void completeTemplateDefinition(const ClassTemplateSpecializationDecl &SD);
|
|
|
|
|
2012-12-18 22:30:41 +08:00
|
|
|
private:
|
|
|
|
/// EmitDeclare - Emit call to llvm.dbg.declare for a variable declaration.
|
2014-05-07 20:49:30 +08:00
|
|
|
/// Tag accepts custom types DW_TAG_arg_variable and DW_TAG_auto_variable,
|
|
|
|
/// otherwise would be of type llvm::dwarf::Tag.
|
|
|
|
void EmitDeclare(const VarDecl *decl, llvm::dwarf::LLVMConstants Tag,
|
|
|
|
llvm::Value *AI, unsigned ArgNo, CGBuilderTy &Builder);
|
2012-12-18 22:30:41 +08:00
|
|
|
|
2013-05-16 08:52:23 +08:00
|
|
|
// EmitTypeForVarWithBlocksAttr - Build up structure info for the byref.
|
2012-12-18 22:30:41 +08:00
|
|
|
// See BuildByRefType.
|
|
|
|
llvm::DIType EmitTypeForVarWithBlocksAttr(const VarDecl *VD,
|
|
|
|
uint64_t *OffSet);
|
|
|
|
|
|
|
|
/// getContextDescriptor - Get context info for the decl.
|
2013-04-19 14:56:38 +08:00
|
|
|
llvm::DIScope getContextDescriptor(const Decl *Decl);
|
2012-12-18 22:30:41 +08:00
|
|
|
|
2013-05-20 12:58:53 +08:00
|
|
|
llvm::DIScope getCurrentContextDescriptor(const Decl *Decl);
|
|
|
|
|
2013-08-16 02:59:40 +08:00
|
|
|
/// \brief Create a forward decl for a RecordType in a given context.
|
2013-08-29 05:20:28 +08:00
|
|
|
llvm::DICompositeType getOrCreateRecordFwdDecl(const RecordType *,
|
2013-08-21 05:03:29 +08:00
|
|
|
llvm::DIDescriptor);
|
2013-05-16 08:52:23 +08:00
|
|
|
|
2012-12-18 22:30:41 +08:00
|
|
|
/// createContextChain - Create a set of decls for the context chain.
|
|
|
|
llvm::DIDescriptor createContextChain(const Decl *Decl);
|
|
|
|
|
|
|
|
/// getCurrentDirname - Return current directory name.
|
|
|
|
StringRef getCurrentDirname();
|
|
|
|
|
|
|
|
/// CreateCompileUnit - Create new compile unit.
|
|
|
|
void CreateCompileUnit();
|
|
|
|
|
2013-05-16 08:52:23 +08:00
|
|
|
/// getOrCreateFile - Get the file debug info descriptor for the input
|
2012-12-18 22:30:41 +08:00
|
|
|
/// location.
|
|
|
|
llvm::DIFile getOrCreateFile(SourceLocation Loc);
|
|
|
|
|
|
|
|
/// getOrCreateMainFile - Get the file info for main compile unit.
|
|
|
|
llvm::DIFile getOrCreateMainFile();
|
|
|
|
|
|
|
|
/// getOrCreateType - Get the type from the cache or create a new type if
|
|
|
|
/// necessary.
|
2013-09-05 06:03:57 +08:00
|
|
|
llvm::DIType getOrCreateType(QualType Ty, llvm::DIFile Fg);
|
2012-12-18 22:30:41 +08:00
|
|
|
|
|
|
|
/// getOrCreateLimitedType - Get the type from the cache or create a new
|
|
|
|
/// partial type if necessary.
|
2013-08-13 06:24:20 +08:00
|
|
|
llvm::DIType getOrCreateLimitedType(const RecordType *Ty, llvm::DIFile F);
|
2012-12-18 22:30:41 +08:00
|
|
|
|
|
|
|
/// CreateTypeNode - Create type metadata for a source language type.
|
2013-09-05 06:03:57 +08:00
|
|
|
llvm::DIType CreateTypeNode(QualType Ty, llvm::DIFile Fg);
|
2012-12-18 22:30:41 +08:00
|
|
|
|
2013-03-07 06:03:30 +08:00
|
|
|
/// getObjCInterfaceDecl - return the underlying ObjCInterfaceDecl
|
|
|
|
/// if Ty is an ObjCInterface or a pointer to one.
|
|
|
|
ObjCInterfaceDecl* getObjCInterfaceDecl(QualType Ty);
|
|
|
|
|
2012-12-18 22:30:41 +08:00
|
|
|
/// CreateMemberType - Create new member and increase Offset by FType's size.
|
|
|
|
llvm::DIType CreateMemberType(llvm::DIFile Unit, QualType FType,
|
|
|
|
StringRef Name, uint64_t *Offset);
|
|
|
|
|
2014-04-01 11:41:01 +08:00
|
|
|
/// \brief Retrieve the DIScope, if any, for the canonical form of this
|
2013-05-20 12:58:53 +08:00
|
|
|
/// declaration.
|
2014-04-01 11:41:01 +08:00
|
|
|
llvm::DIScope getDeclarationOrDefinition(const Decl *D);
|
2013-05-20 12:58:53 +08:00
|
|
|
|
2012-12-18 22:30:41 +08:00
|
|
|
/// getFunctionDeclaration - Return debug info descriptor to describe method
|
|
|
|
/// declaration for the given method definition.
|
|
|
|
llvm::DISubprogram getFunctionDeclaration(const Decl *D);
|
|
|
|
|
2013-08-20 09:28:15 +08:00
|
|
|
/// Return debug info descriptor to describe in-class static data member
|
|
|
|
/// declaration for the given out-of-class definition.
|
|
|
|
llvm::DIDerivedType
|
|
|
|
getOrCreateStaticDataMemberDeclarationOrNull(const VarDecl *D);
|
2013-01-16 09:22:32 +08:00
|
|
|
|
2014-04-10 13:20:00 +08:00
|
|
|
/// Return a global variable that represents one of the collection of
|
|
|
|
/// global variables created for an anonmyous union.
|
|
|
|
llvm::DIGlobalVariable
|
|
|
|
CollectAnonRecordDecls(const RecordDecl *RD, llvm::DIFile Unit, unsigned LineNo,
|
|
|
|
StringRef LinkageName, llvm::GlobalVariable *Var,
|
|
|
|
llvm::DIDescriptor DContext);
|
|
|
|
|
2012-12-18 22:30:41 +08:00
|
|
|
/// getFunctionName - Get function name for the given FunctionDecl. If the
|
2013-09-09 22:48:42 +08:00
|
|
|
/// name is constructed on demand (e.g. C++ destructor) then the name
|
2012-12-18 22:30:41 +08:00
|
|
|
/// is stored on the side.
|
|
|
|
StringRef getFunctionName(const FunctionDecl *FD);
|
|
|
|
|
|
|
|
/// getObjCMethodName - Returns the unmangled name of an Objective-C method.
|
2013-05-16 08:52:23 +08:00
|
|
|
/// This is the display name for the debugging info.
|
2012-12-18 22:30:41 +08:00
|
|
|
StringRef getObjCMethodName(const ObjCMethodDecl *FD);
|
|
|
|
|
|
|
|
/// getSelectorName - Return selector name. This is used for debugging
|
|
|
|
/// info.
|
|
|
|
StringRef getSelectorName(Selector S);
|
|
|
|
|
|
|
|
/// getClassName - Get class name including template argument list.
|
|
|
|
StringRef getClassName(const RecordDecl *RD);
|
|
|
|
|
|
|
|
/// getVTableName - Get vtable name for the given Class.
|
|
|
|
StringRef getVTableName(const CXXRecordDecl *Decl);
|
|
|
|
|
|
|
|
/// getLineNumber - Get line number for the location. If location is invalid
|
|
|
|
/// then use current location.
|
|
|
|
unsigned getLineNumber(SourceLocation Loc);
|
|
|
|
|
2013-05-16 08:52:23 +08:00
|
|
|
/// getColumnNumber - Get column number for the location. If location is
|
2012-12-18 22:30:41 +08:00
|
|
|
/// invalid then use current location.
|
2013-03-13 04:43:25 +08:00
|
|
|
/// \param Force Assume DebugColumnInfo option is true.
|
|
|
|
unsigned getColumnNumber(SourceLocation Loc, bool Force=false);
|
2013-09-10 00:39:06 +08:00
|
|
|
|
|
|
|
/// internString - Allocate a copy of \p A using the DebugInfoNames allocator
|
|
|
|
/// and return a reference to it. If multiple arguments are given the strings
|
|
|
|
/// are concatenated.
|
|
|
|
StringRef internString(StringRef A, StringRef B = StringRef()) {
|
|
|
|
char *Data = DebugInfoNames.Allocate<char>(A.size() + B.size());
|
|
|
|
std::memcpy(Data, A.data(), A.size());
|
|
|
|
std::memcpy(Data + A.size(), B.data(), B.size());
|
|
|
|
return StringRef(Data, A.size() + B.size());
|
|
|
|
}
|
2012-12-18 22:30:41 +08:00
|
|
|
};
|
2013-07-18 08:28:02 +08:00
|
|
|
|
2014-01-17 08:15:10 +08:00
|
|
|
/// SaveAndRestoreLocation - An RAII object saves the current location
|
|
|
|
/// and automatically restores it to the original value.
|
|
|
|
class SaveAndRestoreLocation {
|
|
|
|
protected:
|
2013-07-18 08:28:02 +08:00
|
|
|
SourceLocation SavedLoc;
|
|
|
|
CGDebugInfo *DI;
|
|
|
|
CGBuilderTy &Builder;
|
2014-01-17 08:15:10 +08:00
|
|
|
public:
|
|
|
|
SaveAndRestoreLocation(CodeGenFunction &CGF, CGBuilderTy &B);
|
|
|
|
/// Autorestore everything back to normal.
|
|
|
|
~SaveAndRestoreLocation();
|
|
|
|
};
|
|
|
|
|
|
|
|
/// NoLocation - An RAII object that temporarily disables debug
|
|
|
|
/// locations. This is useful for emitting instructions that should be
|
|
|
|
/// counted towards the function prologue.
|
|
|
|
class NoLocation : public SaveAndRestoreLocation {
|
2013-07-18 08:28:02 +08:00
|
|
|
public:
|
|
|
|
NoLocation(CodeGenFunction &CGF, CGBuilderTy &B);
|
2014-01-17 08:15:10 +08:00
|
|
|
/// Autorestore everything back to normal.
|
2013-07-18 08:28:02 +08:00
|
|
|
~NoLocation();
|
|
|
|
};
|
|
|
|
|
2013-07-18 09:36:04 +08:00
|
|
|
/// ArtificialLocation - An RAII object that temporarily switches to
|
|
|
|
/// an artificial debug location that has a valid scope, but no line
|
2013-07-18 08:28:02 +08:00
|
|
|
/// information. This is useful when emitting compiler-generated
|
|
|
|
/// helper functions that have no source location associated with
|
2013-07-25 04:34:39 +08:00
|
|
|
/// them. The DWARF specification allows the compiler to use the
|
|
|
|
/// special line number 0 to indicate code that can not be attributed
|
|
|
|
/// to any source location.
|
2013-07-18 08:28:02 +08:00
|
|
|
///
|
2013-07-25 04:34:39 +08:00
|
|
|
/// This is necessary because passing an empty SourceLocation to
|
2013-07-18 08:28:02 +08:00
|
|
|
/// CGDebugInfo::setLocation() will result in the last valid location
|
|
|
|
/// being reused.
|
2014-01-17 08:15:10 +08:00
|
|
|
class ArtificialLocation : public SaveAndRestoreLocation {
|
2013-07-18 08:28:02 +08:00
|
|
|
public:
|
2013-07-18 09:36:04 +08:00
|
|
|
ArtificialLocation(CodeGenFunction &CGF, CGBuilderTy &B);
|
2013-07-25 04:34:39 +08:00
|
|
|
|
|
|
|
/// Set the current location to line 0, but within the current scope
|
2013-07-25 08:23:37 +08:00
|
|
|
/// (= the top of the LexicalBlockStack).
|
2013-07-25 04:34:39 +08:00
|
|
|
void Emit();
|
|
|
|
|
2014-01-17 08:15:10 +08:00
|
|
|
/// Autorestore everything back to normal.
|
2013-07-18 09:36:04 +08:00
|
|
|
~ArtificialLocation();
|
2013-07-18 08:28:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-12-18 22:30:41 +08:00
|
|
|
} // namespace CodeGen
|
|
|
|
} // namespace clang
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|