DebugInfo: Remove unnecessary API from DIDerivedType and DIType
[oota-llvm.git] / include / llvm / IR / DebugInfo.h
index 462695b6c501503a62f98c41c279cb0b916f3be7..6d90d038e0206d43e10382dcaa40791fd7127074 100644 (file)
@@ -275,8 +275,6 @@ public:
   bool isStaticMember() const { return get()->isStaticMember(); }
   bool isLValueReference() const { return get()->isLValueReference(); }
   bool isRValueReference() const { return get()->isRValueReference(); }
-
-  bool isValid() const { return DbgNode && isa<MDType>(*this); }
 };
 
 /// \brief A basic type, like 'int' or 'float'.
@@ -312,19 +310,6 @@ public:
   MDDerivedTypeBase &operator*() const { return *get(); }
 
   DITypeRef getTypeDerivedFrom() const { return get()->getBaseType(); }
-
-  /// \brief Return property node, if this ivar is associated with one.
-  MDObjCProperty *getObjCProperty() const {
-    return cast<MDDerivedType>(get())->getObjCProperty();
-  }
-
-  DITypeRef getClassType() const {
-    return cast<MDDerivedType>(get())->getClassType();
-  }
-
-  Constant *getConstant() const {
-    return cast<MDDerivedType>(get())->getConstant();
-  }
 };
 
 /// \brief Types that refer to multiple other types.
@@ -374,281 +359,134 @@ public:
   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(); }
+class DIFile {
+  MDFile *N;
 
-  /// \brief Retrieve the MDNode for the directory/file pair.
-  MDNode *getFileNode() const { return get(); }
-};
-
-/// \brief A wrapper for a compile unit.
-class DICompileUnit : public DIScope {
 public:
-  DICompileUnit() = default;
-  DICompileUnit(const MDCompileUnit *N) : DIScope(N) {}
+  DIFile(const MDFile *N = nullptr) : N(const_cast<MDFile *>(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(); }
-
-  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(); }
+class DICompileUnit {
+  MDCompileUnit *N;
 
-  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(); }
-
-  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) {}
-
-  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(); }
-
-  DIScope getContext() const { return get()->getScope(); }
-  unsigned getDiscriminator() const { return get()->getDiscriminator(); }
-};
+class DISubprogram {
+  MDSubprogram *N;
 
-/// \brief A wrapper for a C++ style name space.
-class DINameSpace : public DIScope {
 public:
-  DINameSpace() = default;
-  DINameSpace(const MDNamespace *N) : DIScope(N) {}
+  DISubprogram(const MDSubprogram *N = nullptr)
+      : N(const_cast<MDSubprogram *>(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(); }
-
-  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 DIScope() const { return N; }
+  operator MDSubprogram *() const { return N; }
+  MDSubprogram *operator->() const { return N; }
+  MDSubprogram &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 DILexicalBlock {
+  MDLexicalBlockBase *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:
+  DILexicalBlock(const MDLexicalBlockBase *N = nullptr)
+      : N(const_cast<MDLexicalBlockBase *>(N)) {}
 
-  StringRef getName() const { return get()->getName(); }
-  DITypeRef getType() const { return get()->getType(); }
+  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 value parameter.
-class DITemplateValueParameter : public DIDescriptor {
-public:
-  DITemplateValueParameter() = default;
-  DITemplateValueParameter(const MDTemplateValueParameter *N)
-      : DIDescriptor(N) {}
+class DILexicalBlockFile {
+  MDLexicalBlockFile *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:
+  DILexicalBlockFile(const MDLexicalBlockFile *N = nullptr)
+      : N(const_cast<MDLexicalBlockFile *>(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 MDLexicalBlockFile *() const { return N; }
+  MDLexicalBlockFile *operator->() const { return N; }
+  MDLexicalBlockFile &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 DINameSpace {
+  MDNamespace *N;
 
 public:
-  DIGlobalVariable() = default;
-  DIGlobalVariable(const MDGlobalVariable *N) : DIDescriptor(N) {}
+  DINameSpace(const MDNamespace *N = nullptr)
+      : N(const_cast<MDNamespace *>(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 DIDescriptor() const { return N; }
+  operator DIScope() const { return N; }
+  operator MDNamespace *() const { return N; }
+  MDNamespace *operator->() const { return N; }
+  MDNamespace &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 DITemplateTypeParameter {
+  MDTemplateTypeParameter *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:
+  DITemplateTypeParameter(const MDTemplateTypeParameter *N = nullptr)
+      : N(const_cast<MDTemplateTypeParameter *>(N)) {}
 
-  Constant *getConstant() const { return get()->getVariable(); }
-  DIDerivedType getStaticDataMemberDeclaration() const {
-    return get()->getStaticDataMemberDeclaration();
-  }
+  operator MDTemplateTypeParameter *() const { return N; }
+  MDTemplateTypeParameter *operator->() const { return N; }
+  MDTemplateTypeParameter &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 DITemplateValueParameter {
+  MDTemplateValueParameter *N;
 
 public:
-  DIVariable() = default;
-  DIVariable(const MDLocalVariable *N) : DIDescriptor(N) {}
+  DITemplateValueParameter(const MDTemplateValueParameter *N = nullptr)
+      : N(const_cast<MDTemplateValueParameter *>(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(); }
+  operator MDTemplateValueParameter *() const { return N; }
+  MDTemplateValueParameter *operator->() const { return N; }
+  MDTemplateValueParameter &operator*() const { return *N; }
+};
 
-  StringRef getName() const { return get()->getName(); }
-  unsigned getLineNumber() const { return get()->getLine(); }
-  unsigned getArgNumber() const { return get()->getArg(); }
+class DIGlobalVariable {
+  MDGlobalVariable *N;
 
-  DIScope getContext() const { return get()->getScope(); }
-  DIFile getFile() const { return get()->getFile(); }
-  DITypeRef getType() const { return get()->getType(); }
+public:
+  DIGlobalVariable(const MDGlobalVariable *N = nullptr)
+      : N(const_cast<MDGlobalVariable *>(N)) {}
 
-  bool isArtificial() const { return get()->isArtificial(); }
-  bool isObjectPointer() const { return get()->isObjectPointer(); }
+  operator DIDescriptor() const { return N; }
+  operator MDGlobalVariable *() const { return N; }
+  MDGlobalVariable *operator->() const { return N; }
+  MDGlobalVariable &operator*() const { return *N; }
+};
 
-  /// \brief If this variable is inlined then return inline location.
-  MDNode *getInlinedAt() const { return get()->getInlinedAt(); }
+class DIVariable {
+  MDLocalVariable *N;
 
-  /// \brief Check if this is a "__block" variable (Apple Blocks).
-  bool isBlockByrefVariable(const DITypeIdentifierMap &Map) const {
-    return (getType().resolve(Map)).isBlockByrefStruct();
-  }
+public:
+  DIVariable(const MDLocalVariable *N = nullptr)
+      : N(const_cast<MDLocalVariable *>(N)) {}
 
-  void printExtendedName(raw_ostream &OS) const;
+  operator MDLocalVariable *() const { return N; }
+  MDLocalVariable *operator->() const { return N; }
+  MDLocalVariable &operator*() const { return *N; }
 };
 
 class DIExpression {
@@ -741,16 +579,6 @@ DISubprogram getDISubprogram(const Function *F);
 /// \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);