#ifndef LLVM_DEBUGINFO_H
#define LLVM_DEBUGINFO_H
-#include "llvm/Support/Casting.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/Metadata.h"
+#include "llvm/Support/Casting.h"
#include "llvm/Support/Dwarf.h"
namespace llvm {
public:
enum {
- FlagPrivate = 1 << 0,
- FlagProtected = 1 << 1,
- FlagFwdDecl = 1 << 2,
- FlagAppleBlock = 1 << 3,
- FlagBlockByrefStruct = 1 << 4,
- FlagVirtual = 1 << 5,
- FlagArtificial = 1 << 6,
- FlagExplicit = 1 << 7,
- FlagPrototyped = 1 << 8,
+ FlagPrivate = 1 << 0,
+ FlagProtected = 1 << 1,
+ FlagFwdDecl = 1 << 2,
+ FlagAppleBlock = 1 << 3,
+ FlagBlockByrefStruct = 1 << 4,
+ FlagVirtual = 1 << 5,
+ FlagArtificial = 1 << 6,
+ FlagExplicit = 1 << 7,
+ FlagPrototyped = 1 << 8,
FlagObjcClassComplete = 1 << 9,
- FlagObjectPointer = 1 << 10,
- FlagVector = 1 << 11,
- FlagStaticMember = 1 << 12,
- FlagIndirectVariable = 1 << 13
+ FlagObjectPointer = 1 << 10,
+ FlagVector = 1 << 11,
+ FlagStaticMember = 1 << 12,
+ FlagIndirectVariable = 1 << 13,
+ FlagLValueReference = 1 << 14,
+ FlagRValueReference = 1 << 15
};
protected:
return T(Iter->second);
}
-template <typename T>
-StringRef DIRef<T>::getName() const {
+template <typename T> StringRef DIRef<T>::getName() const {
if (!Val)
return StringRef();
void printInternal(raw_ostream &OS) const;
public:
- DIType(const MDNode *N = 0) : DIScope(N) {}
+ explicit DIType(const MDNode *N = 0) : DIScope(N) {}
/// Verify - Verify that a type descriptor is well formed.
bool Verify() const;
}
bool isVector() const { return (getFlags() & FlagVector) != 0; }
bool isStaticMember() const { return (getFlags() & FlagStaticMember) != 0; }
+ bool isLValueReference() const {
+ return (getFlags() & FlagLValueReference) != 0;
+ }
+ bool isRValueReference() const {
+ return (getFlags() & FlagRValueReference) != 0;
+ }
bool isValid() const { return DbgNode && isType(); }
/// replaceAllUsesWith - Replace all uses of debug info referenced by
DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
void setTypeArray(DIArray Elements, DIArray TParams = DIArray());
- void addMember(DIDescriptor D);
unsigned getRunTimeLang() const { return getUnsignedField(11); }
DITypeRef getContainingType() const { return getFieldAs<DITypeRef>(12); }
void setContainingType(DICompositeType ContainingType);
DIArray getImportedEntities() const;
StringRef getSplitDebugFilename() const { return getStringField(12); }
+ unsigned getEmissionKind() const { return getUnsignedField(13); }
/// Verify - Verify that a compile unit is well formed.
bool Verify() const;
public:
explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {}
- DIScope getContext() const { return getFieldAs<DIScope>(2); }
+ DIScopeRef getContext() const { return getFieldAs<DIScopeRef>(2); }
StringRef getName() const { return getStringField(3); }
StringRef getDisplayName() const { return getStringField(4); }
StringRef getLinkageName() const { return getStringField(5); }
return (getUnsignedField(13) & FlagPrototyped) != 0;
}
+ /// Return true if this subprogram is a C++11 reference-qualified
+ /// non-static member function (void foo() &).
+ unsigned isLValueReference() const {
+ return (getUnsignedField(13) & FlagLValueReference) != 0;
+ }
+
+ /// Return true if this subprogram is a C++11
+ /// rvalue-reference-qualified non-static member function
+ /// (void foo() &&).
+ unsigned isRValueReference() const {
+ return (getUnsignedField(13) & FlagRValueReference) != 0;
+ }
+
unsigned isOptimized() const;
/// Verify - Verify that a subprogram descriptor is well formed.
DIScope getContext() const { return getFieldAs<DIScope>(2); }
unsigned getLineNumber() const { return getUnsignedField(3); }
unsigned getColumnNumber() const { return getUnsignedField(4); }
+ unsigned getDiscriminator() const { return getUnsignedField(5); }
bool Verify() const;
};
bool Verify() const;
};
+/// DIUnspecifiedParameter - This is a wrapper for unspecified parameters.
+class DIUnspecifiedParameter : public DIDescriptor {
+public:
+ explicit DIUnspecifiedParameter(const MDNode *N = 0) : DIDescriptor(N) {}
+ bool Verify() const;
+};
+
/// DITemplateTypeParameter - This is a wrapper for template type parameter.
class DITemplateTypeParameter : public DIDescriptor {
public:
explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {}
- DIScope getContext() const { return getFieldAs<DIScope>(1); }
+ DIScopeRef getContext() const { return getFieldAs<DIScopeRef>(1); }
StringRef getName() const { return getStringField(2); }
- DIType getType() const { return getFieldAs<DIType>(3); }
+ DITypeRef getType() const { return getFieldAs<DITypeRef>(3); }
StringRef getFilename() const { return getFieldAs<DIFile>(4).getFilename(); }
StringRef getDirectory() const {
return getFieldAs<DIFile>(4).getDirectory();
public:
explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {}
- DIScope getContext() const { return getFieldAs<DIScope>(1); }
+ DIScopeRef getContext() const { return getFieldAs<DIScopeRef>(1); }
StringRef getName() const { return getStringField(2); }
- DIType getType() const { return getFieldAs<DIType>(3); }
+ DITypeRef getType() const { return getFieldAs<DITypeRef>(3); }
Value *getValue() const;
StringRef getFilename() const { return getFieldAs<DIFile>(5).getFilename(); }
StringRef getDirectory() const {
StringRef getFilename() const { return getScope().getFilename(); }
StringRef getDirectory() const { return getScope().getDirectory(); }
bool Verify() const;
+ bool atSameLineAs(const DILocation &Other) const {
+ return (getLineNumber() == Other.getLineNumber() &&
+ getFilename() == Other.getFilename());
+ }
+ /// getDiscriminator - DWARF discriminators are used to distinguish
+ /// identical file locations for instructions that are on different
+ /// basic blocks. If two instructions are inside the same lexical block
+ /// and are in different basic blocks, we create a new lexical block
+ /// with identical location as the original but with a different
+ /// discriminator value (lib/Transforms/Util/AddDiscriminators.cpp
+ /// for details).
+ unsigned getDiscriminator() const {
+ // Since discriminators are associated with lexical blocks, make
+ // sure this location is a lexical block before retrieving its
+ // value.
+ return getScope().isLexicalBlock()
+ ? getFieldAs<DILexicalBlock>(2).getDiscriminator()
+ : 0;
+ }
+ unsigned computeNewDiscriminator(LLVMContext &Ctx);
+ DILocation copyWithNewScope(LLVMContext &Ctx, DILexicalBlock NewScope);
};
class DIObjCProperty : public DIDescriptor {
/// Construct DITypeIdentifierMap by going through retained types of each CU.
DITypeIdentifierMap generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes);
+/// Strip debug info in the module if it exists.
+/// To do this, we remove all calls to the debugger intrinsics and any named
+/// metadata for debugging. We also remove debug locations for instructions.
+/// Return true if module is modified.
+bool StripDebugInfo(Module &M);
+
+/// Return Debug Info Metadata Version by checking module flags.
+unsigned getDebugMetadataVersionFromModule(const Module &M);
+
/// DebugInfoFinder tries to list all debug info MDNodes used in a module. To
/// list debug info MDNodes used by an instruction, DebugInfoFinder uses
/// processDeclare, processValue and processLocation to handle DbgDeclareInst,
/// used by the CUs.
class DebugInfoFinder {
public:
+ DebugInfoFinder() : TypeMapInitialized(false) {}
+
/// processModule - Process entire module and collect debug info
/// anchors.
void processModule(const Module &M);
/// processDeclare - Process DbgDeclareInst.
- void processDeclare(const DbgDeclareInst *DDI);
+ void processDeclare(const Module &M, const DbgDeclareInst *DDI);
/// Process DbgValueInst.
- void processValue(const DbgValueInst *DVI);
+ void processValue(const Module &M, const DbgValueInst *DVI);
/// processLocation - Process DILocation.
- void processLocation(DILocation Loc);
+ void processLocation(const Module &M, DILocation Loc);
/// Clear all lists.
void reset();
private:
+ /// Initialize TypeIdentifierMap.
+ void InitializeTypeMap(const Module &M);
+
/// processType - Process DIType.
void processType(DIType DT);
SmallVector<MDNode *, 8> Scopes; // Scopes
SmallPtrSet<MDNode *, 64> NodesSeen;
DITypeIdentifierMap TypeIdentifierMap;
+ /// Specify if TypeIdentifierMap is initialized.
+ bool TypeMapInitialized;
};
} // end namespace llvm