#ifndef LLVM_IR_DEBUGINFO_H
#define LLVM_IR_DEBUGINFO_H
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Dwarf.h"
#include "llvm/Support/ErrorHandling.h"
#include <iterator>
namespace llvm {
class Module;
class DbgDeclareInst;
class DbgValueInst;
DISubprogram *getDISubprogram(const MDNode *Scope);
bool StripDebugInfo(Module &M);
bool stripDebugInfo(Function &F);
bool convertDebugInfoToLineTables(Module &M);
unsigned getDebugMetadataVersionFromModule(const Module &M);
class DebugInfoFinder {
public:
void processModule(const Module &M);
void processDeclare(const Module &M, const DbgDeclareInst *DDI);
void processValue(const Module &M, const DbgValueInst *DVI);
void processLocation(const Module &M, const DILocation *Loc);
void reset();
private:
void InitializeTypeMap(const Module &M);
void processType(DIType *DT);
void processSubprogram(DISubprogram *SP);
void processScope(DIScope *Scope);
bool addCompileUnit(DICompileUnit *CU);
bool addGlobalVariable(DIGlobalVariable *DIG);
bool addSubprogram(DISubprogram *SP);
bool addType(DIType *DT);
bool addScope(DIScope *Scope);
public:
typedef SmallVectorImpl<DICompileUnit *>::const_iterator
compile_unit_iterator;
typedef SmallVectorImpl<DISubprogram *>::const_iterator subprogram_iterator;
typedef SmallVectorImpl<DIGlobalVariable *>::const_iterator
global_variable_iterator;
typedef SmallVectorImpl<DIType *>::const_iterator type_iterator;
typedef SmallVectorImpl<DIScope *>::const_iterator scope_iterator;
iterator_range<compile_unit_iterator> compile_units() const {
return make_range(CUs.begin(), CUs.end());
}
iterator_range<subprogram_iterator> subprograms() const {
return make_range(SPs.begin(), SPs.end());
}
iterator_range<global_variable_iterator> global_variables() const {
return make_range(GVs.begin(), GVs.end());
}
iterator_range<type_iterator> types() const {
return make_range(TYs.begin(), TYs.end());
}
iterator_range<scope_iterator> scopes() const {
return make_range(Scopes.begin(), Scopes.end());
}
unsigned compile_unit_count() const { return CUs.size(); }
unsigned global_variable_count() const { return GVs.size(); }
unsigned subprogram_count() const { return SPs.size(); }
unsigned type_count() const { return TYs.size(); }
unsigned scope_count() const { return Scopes.size(); }
private:
SmallVector<DICompileUnit *, 8> CUs;
SmallVector<DISubprogram *, 8> SPs;
SmallVector<DIGlobalVariable *, 8> GVs;
SmallVector<DIType *, 8> TYs;
SmallVector<DIScope *, 8> Scopes;
SmallPtrSet<const MDNode *, 32> NodesSeen;
};
}
#endif