DebugInfo: Move DILocation::getDiscriminator() to MDLocation
[oota-llvm.git] / include / llvm / IR / DebugInfoMetadata.h
index f7b092f4e6ecd572d4911c21b31d850e1bdcc0c0..9cb1ac2b8ad07aef629682d9718e0bbae7e57f73 100644 (file)
@@ -1203,6 +1203,12 @@ public:
     return getFilename() != RHS.getFilename() || getLine() != RHS.getLine();
   }
 
+  /// \brief Get the DWARF discriminator.
+  ///
+  /// DWARF discriminators distinguish identical file locations between
+  /// instructions that are on different basic blocks.
+  inline unsigned getDiscriminator() const;
+
   Metadata *getRawScope() const { return getOperand(0); }
   Metadata *getRawInlinedAt() const {
     if (getNumOperands() == 2)
@@ -1528,6 +1534,12 @@ public:
   }
 };
 
+unsigned MDLocation::getDiscriminator() const {
+  if (auto *F = dyn_cast<MDLexicalBlockFile>(getScope()))
+    return F->getDiscriminator();
+  return 0;
+}
+
 class MDNamespace : public MDScope {
   friend class LLVMContextImpl;
   friend class MDNode;