MDTypeRefArray getTypeArray() const { return get()->getTypeArray(); }
};
-/// \brief This is a wrapper for a file.
-class DIFile : public DIScope {
-public:
- DIFile() = default;
- DIFile(const MDFile *N) : DIScope(N) {}
-
- MDFile *get() const { return cast_or_null<MDFile>(DIDescriptor::get()); }
- operator MDFile *() const { return get(); }
- MDFile *operator->() const { return get(); }
- MDFile &operator*() const { return *get(); }
-
- /// \brief Retrieve the MDNode for the directory/file pair.
- MDNode *getFileNode() const { return get(); }
-};
+class DIFile {
+ MDFile *N;
-/// \brief A wrapper for a compile unit.
-class DICompileUnit : public DIScope {
public:
- DICompileUnit() = default;
- DICompileUnit(const MDCompileUnit *N) : DIScope(N) {}
-
- MDCompileUnit *get() const {
- return cast_or_null<MDCompileUnit>(DIDescriptor::get());
- }
- operator MDCompileUnit *() const { return get(); }
- MDCompileUnit *operator->() const { return get(); }
- MDCompileUnit &operator*() const { return *get(); }
+ DIFile(const MDFile *N = nullptr) : N(const_cast<MDFile *>(N)) {}
- dwarf::SourceLanguage getLanguage() const {
- return static_cast<dwarf::SourceLanguage>(get()->getSourceLanguage());
- }
- StringRef getProducer() const { return get()->getProducer(); }
- bool isOptimized() const { return get()->isOptimized(); }
- StringRef getFlags() const { return get()->getFlags(); }
- unsigned getRunTimeVersion() const { return get()->getRuntimeVersion(); }
-
- DIArray getEnumTypes() const { return get()->getEnumTypes(); }
- DIArray getRetainedTypes() const { return get()->getRetainedTypes(); }
- DIArray getSubprograms() const { return get()->getSubprograms(); }
- DIArray getGlobalVariables() const { return get()->getGlobalVariables(); }
- DIArray getImportedEntities() const { return get()->getImportedEntities(); }
-
- void replaceSubprograms(DIArray Subprograms);
- void replaceGlobalVariables(DIArray GlobalVariables);
-
- StringRef getSplitDebugFilename() const {
- return get()->getSplitDebugFilename();
- }
- unsigned getEmissionKind() const { return get()->getEmissionKind(); }
+ operator DIDescriptor() const { return N; }
+ operator DIScope() const { return N; }
+ operator MDFile *() const { return N; }
+ MDFile *operator->() const { return N; }
+ MDFile &operator*() const { return *N; }
};
-/// \brief This is a wrapper for a subprogram (e.g. a function).
-class DISubprogram : public DIScope {
-public:
- DISubprogram() = default;
- DISubprogram(const MDSubprogram *N) : DIScope(N) {}
-
- MDSubprogram *get() const {
- return cast_or_null<MDSubprogram>(DIDescriptor::get());
- }
- operator MDSubprogram *() const { return get(); }
- MDSubprogram *operator->() const { return get(); }
- MDSubprogram &operator*() const { return *get(); }
-
- StringRef getName() const { return get()->getName(); }
- StringRef getDisplayName() const { return get()->getDisplayName(); }
- StringRef getLinkageName() const { return get()->getLinkageName(); }
- unsigned getLineNumber() const { return get()->getLine(); }
-
- /// \brief Check if this is local (like 'static' in C).
- unsigned isLocalToUnit() const { return get()->isLocalToUnit(); }
- unsigned isDefinition() const { return get()->isDefinition(); }
-
- unsigned getVirtuality() const { return get()->getVirtuality(); }
- unsigned getVirtualIndex() const { return get()->getVirtualIndex(); }
-
- unsigned getFlags() const { return get()->getFlags(); }
-
- unsigned isOptimized() const { return get()->isOptimized(); }
-
- /// \brief Get the beginning of the scope of the function (not the name).
- unsigned getScopeLineNumber() const { return get()->getScopeLine(); }
+class DICompileUnit {
+ MDCompileUnit *N;
- DIScopeRef getContext() const { return get()->getScope(); }
- DISubroutineType getType() const { return get()->getType(); }
-
- DITypeRef getContainingType() const { return get()->getContainingType(); }
-
- /// \brief Check if this provides debugging information for the function F.
- bool describes(const Function *F) const { return get()->describes(F); }
-
- Function *getFunction() const { return get()->getFunction(); }
-
- void replaceFunction(Function *F) { get()->replaceFunction(F); }
- DIArray getTemplateParams() const { return get()->getTemplateParams(); }
- DISubprogram getFunctionDeclaration() const {
- return get()->getDeclaration();
- }
- DIArray getVariables() const { return DIArray(get()->getVariables()); }
-
- unsigned isArtificial() const { return get()->isArtificial(); }
- bool isPrivate() const { return get()->isPrivate(); }
- bool isProtected() const { return get()->isProtected(); }
- bool isPublic() const { return get()->isPublic(); }
- bool isExplicit() const { return get()->isExplicit(); }
- bool isPrototyped() const { return get()->isPrototyped(); }
- unsigned isLValueReference() const { return get()->isLValueReference(); }
- unsigned isRValueReference() const { return get()->isRValueReference(); }
-};
-
-/// \brief This is a wrapper for a lexical block.
-class DILexicalBlock : public DIScope {
public:
- DILexicalBlock() = default;
- DILexicalBlock(const MDLexicalBlockBase *N) : DIScope(N) {}
+ DICompileUnit(const MDCompileUnit *N = nullptr)
+ : N(const_cast<MDCompileUnit *>(N)) {}
- MDLexicalBlockBase *get() const {
- return cast_or_null<MDLexicalBlockBase>(DIDescriptor::get());
- }
- operator MDLexicalBlockBase *() const { return get(); }
- MDLexicalBlockBase *operator->() const { return get(); }
- MDLexicalBlockBase &operator*() const { return *get(); }
-
- DIScope getContext() const { return DIScope(get()->getScope()); }
- unsigned getLineNumber() const {
- if (auto *N = dyn_cast<MDLexicalBlock>(get()))
- return N->getLine();
- return 0;
- }
- unsigned getColumnNumber() const {
- if (auto *N = dyn_cast<MDLexicalBlock>(get()))
- return N->getColumn();
- return 0;
- }
+ operator DIDescriptor() const { return N; }
+ operator DIScope() const { return N; }
+ operator MDCompileUnit *() const { return N; }
+ MDCompileUnit *operator->() const { return N; }
+ MDCompileUnit &operator*() const { return *N; }
};
-/// \brief This is a wrapper for a lexical block with a filename change.
-class DILexicalBlockFile : public DIScope {
-public:
- DILexicalBlockFile() = default;
- DILexicalBlockFile(const MDLexicalBlockFile *N) : DIScope(N) {}
+class DISubprogram {
+ MDSubprogram *N;
- MDLexicalBlockFile *get() const {
- return cast_or_null<MDLexicalBlockFile>(DIDescriptor::get());
- }
- operator MDLexicalBlockFile *() const { return get(); }
- MDLexicalBlockFile *operator->() const { return get(); }
- MDLexicalBlockFile &operator*() const { return *get(); }
+public:
+ DISubprogram(const MDSubprogram *N = nullptr)
+ : N(const_cast<MDSubprogram *>(N)) {}
- DIScope getContext() const { return get()->getScope(); }
- unsigned getDiscriminator() const { return get()->getDiscriminator(); }
+ operator DIDescriptor() const { return N; }
+ operator DIScope() const { return N; }
+ operator MDSubprogram *() const { return N; }
+ MDSubprogram *operator->() const { return N; }
+ MDSubprogram &operator*() const { return *N; }
};
-/// \brief A wrapper for a C++ style name space.
-class DINameSpace : public DIScope {
-public:
- DINameSpace() = default;
- DINameSpace(const MDNamespace *N) : DIScope(N) {}
+class DILexicalBlock {
+ MDLexicalBlockBase *N;
- MDNamespace *get() const {
- return cast_or_null<MDNamespace>(DIDescriptor::get());
- }
- operator MDNamespace *() const { return get(); }
- MDNamespace *operator->() const { return get(); }
- MDNamespace &operator*() const { return *get(); }
+public:
+ DILexicalBlock(const MDLexicalBlockBase *N = nullptr)
+ : N(const_cast<MDLexicalBlockBase *>(N)) {}
- StringRef getName() const { return get()->getName(); }
- unsigned getLineNumber() const { return get()->getLine(); }
- DIScope getContext() const { return DIScope(get()->getScope()); }
+ operator DIDescriptor() const { return N; }
+ operator MDLexicalBlockBase *() const { return N; }
+ MDLexicalBlockBase *operator->() const { return N; }
+ MDLexicalBlockBase &operator*() const { return *N; }
};
-/// \brief This is a wrapper for template type parameter.
-class DITemplateTypeParameter : public DIDescriptor {
-public:
- DITemplateTypeParameter() = default;
- DITemplateTypeParameter(const MDTemplateTypeParameter *N) : DIDescriptor(N) {}
+class DILexicalBlockFile {
+ MDLexicalBlockFile *N;
- MDTemplateTypeParameter *get() const {
- return cast_or_null<MDTemplateTypeParameter>(DIDescriptor::get());
- }
- operator MDTemplateTypeParameter *() const { return get(); }
- MDTemplateTypeParameter *operator->() const { return get(); }
- MDTemplateTypeParameter &operator*() const { return *get(); }
+public:
+ DILexicalBlockFile(const MDLexicalBlockFile *N = nullptr)
+ : N(const_cast<MDLexicalBlockFile *>(N)) {}
- StringRef getName() const { return get()->getName(); }
- DITypeRef getType() const { return get()->getType(); }
+ operator DIDescriptor() const { return N; }
+ operator MDLexicalBlockFile *() const { return N; }
+ MDLexicalBlockFile *operator->() const { return N; }
+ MDLexicalBlockFile &operator*() const { return *N; }
};
-/// \brief This is a wrapper for template value parameter.
-class DITemplateValueParameter : public DIDescriptor {
-public:
- DITemplateValueParameter() = default;
- DITemplateValueParameter(const MDTemplateValueParameter *N)
- : DIDescriptor(N) {}
+class DINameSpace {
+ MDNamespace *N;
- MDTemplateValueParameter *get() const {
- return cast_or_null<MDTemplateValueParameter>(DIDescriptor::get());
- }
- operator MDTemplateValueParameter *() const { return get(); }
- MDTemplateValueParameter *operator->() const { return get(); }
- MDTemplateValueParameter &operator*() const { return *get(); }
+public:
+ DINameSpace(const MDNamespace *N = nullptr)
+ : N(const_cast<MDNamespace *>(N)) {}
- StringRef getName() const { return get()->getName(); }
- DITypeRef getType() const { return get()->getType(); }
- Metadata *getValue() const { return get()->getValue(); }
+ operator DIDescriptor() const { return N; }
+ operator DIScope() const { return N; }
+ operator MDNamespace *() const { return N; }
+ MDNamespace *operator->() const { return N; }
+ MDNamespace &operator*() const { return *N; }
};
-/// \brief This is a wrapper for a global variable.
-class DIGlobalVariable : public DIDescriptor {
- DIFile getFile() const { return DIFile(get()->getFile()); }
+class DITemplateTypeParameter {
+ MDTemplateTypeParameter *N;
public:
- DIGlobalVariable() = default;
- DIGlobalVariable(const MDGlobalVariable *N) : DIDescriptor(N) {}
+ DITemplateTypeParameter(const MDTemplateTypeParameter *N = nullptr)
+ : N(const_cast<MDTemplateTypeParameter *>(N)) {}
- MDGlobalVariable *get() const {
- return cast_or_null<MDGlobalVariable>(DIDescriptor::get());
- }
- operator MDGlobalVariable *() const { return get(); }
- MDGlobalVariable *operator->() const { return get(); }
- MDGlobalVariable &operator*() const { return *get(); }
+ operator MDTemplateTypeParameter *() const { return N; }
+ MDTemplateTypeParameter *operator->() const { return N; }
+ MDTemplateTypeParameter &operator*() const { return *N; }
+};
- StringRef getName() const { return get()->getName(); }
- StringRef getDisplayName() const { return get()->getDisplayName(); }
- StringRef getLinkageName() const { return get()->getLinkageName(); }
- unsigned getLineNumber() const { return get()->getLine(); }
- unsigned isLocalToUnit() const { return get()->isLocalToUnit(); }
- unsigned isDefinition() const { return get()->isDefinition(); }
+class DITemplateValueParameter {
+ MDTemplateValueParameter *N;
- DIScope getContext() const { return get()->getScope(); }
- StringRef getFilename() const { return get()->getFilename(); }
- StringRef getDirectory() const { return get()->getDirectory(); }
- DITypeRef getType() const { return get()->getType(); }
+public:
+ DITemplateValueParameter(const MDTemplateValueParameter *N = nullptr)
+ : N(const_cast<MDTemplateValueParameter *>(N)) {}
- Constant *getConstant() const { return get()->getVariable(); }
- DIDerivedType getStaticDataMemberDeclaration() const {
- return get()->getStaticDataMemberDeclaration();
- }
+ operator MDTemplateValueParameter *() const { return N; }
+ MDTemplateValueParameter *operator->() const { return N; }
+ MDTemplateValueParameter &operator*() const { return *N; }
};
-/// \brief This is a wrapper for a variable (e.g. parameter, local, global etc).
-class DIVariable : public DIDescriptor {
- unsigned getFlags() const { return get()->getFlags(); }
+class DIGlobalVariable {
+ MDGlobalVariable *N;
public:
- DIVariable() = default;
- DIVariable(const MDLocalVariable *N) : DIDescriptor(N) {}
-
- MDLocalVariable *get() const {
- return cast_or_null<MDLocalVariable>(DIDescriptor::get());
- }
- operator MDLocalVariable *() const { return get(); }
- MDLocalVariable *operator->() const { return get(); }
- MDLocalVariable &operator*() const { return *get(); }
+ DIGlobalVariable(const MDGlobalVariable *N = nullptr)
+ : N(const_cast<MDGlobalVariable *>(N)) {}
- StringRef getName() const { return get()->getName(); }
- unsigned getLineNumber() const { return get()->getLine(); }
- unsigned getArgNumber() const { return get()->getArg(); }
+ operator DIDescriptor() const { return N; }
+ operator MDGlobalVariable *() const { return N; }
+ MDGlobalVariable *operator->() const { return N; }
+ MDGlobalVariable &operator*() const { return *N; }
+};
- DIScope getContext() const { return get()->getScope(); }
- DIFile getFile() const { return get()->getFile(); }
- DITypeRef getType() const { return get()->getType(); }
+class DIVariable {
+ MDLocalVariable *N;
- bool isArtificial() const { return get()->isArtificial(); }
- bool isObjectPointer() const { return get()->isObjectPointer(); }
+public:
+ DIVariable(const MDLocalVariable *N = nullptr)
+ : N(const_cast<MDLocalVariable *>(N)) {}
- /// \brief If this variable is inlined then return inline location.
- MDNode *getInlinedAt() const { return get()->getInlinedAt(); }
+ operator MDLocalVariable *() const { return N; }
+ MDLocalVariable *operator->() const { return N; }
+ MDLocalVariable &operator*() const { return *N; }
};
class DIExpression {
/// \brief Find underlying composite type.
DICompositeType getDICompositeType(DIType T);
-/// \brief Create a new inlined variable based on current variable.
-///
-/// @param DV Current Variable.
-/// @param InlinedScope Location at current variable is inlined.
-DIVariable createInlinedVariable(MDNode *DV, MDNode *InlinedScope,
- LLVMContext &VMContext);
-
-/// \brief Remove inlined scope from the variable.
-DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext);
-
/// \brief Generate map by visiting all retained types.
DITypeIdentifierMap generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes);