[C++] Use 'nullptr'.
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DIE.h
index 43dd6b2d23b8526edef503e3f6f84dba63c2ccbb..7d7fd743c4e649c58d79352c8f9b78c614dc5f92 100644 (file)
 
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/MC/MCExpr.h"
-#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Dwarf.h"
 #include <vector>
 
 namespace llvm {
 class AsmPrinter;
+class MCExpr;
 class MCSymbol;
-class MCSymbolRefExpr;
 class raw_ostream;
 class DwarfTypeUnit;
 
@@ -126,7 +124,7 @@ protected:
 
   /// Children DIEs.
   ///
-  std::vector<DIE *> Children;
+  std::vector<std::unique_ptr<DIE>> Children;
 
   DIE *Parent;
 
@@ -134,11 +132,15 @@ protected:
   ///
   SmallVector<DIEValue *, 12> Values;
 
+protected:
+  DIE()
+      : Offset(0), Size(0), Abbrev((dwarf::Tag)0, dwarf::DW_CHILDREN_no),
+        Parent(nullptr) {}
+
 public:
-  explicit DIE(unsigned Tag)
+  explicit DIE(dwarf::Tag Tag)
       : Offset(0), Size(0), Abbrev((dwarf::Tag)Tag, dwarf::DW_CHILDREN_no),
-        Parent(0) {}
-  ~DIE();
+        Parent(nullptr) {}
 
   // Accessors.
   DIEAbbrev &getAbbrev() { return Abbrev; }
@@ -147,7 +149,9 @@ public:
   dwarf::Tag getTag() const { return Abbrev.getTag(); }
   unsigned getOffset() const { return Offset; }
   unsigned getSize() const { return Size; }
-  const std::vector<DIE *> &getChildren() const { return Children; }
+  const std::vector<std::unique_ptr<DIE>> &getChildren() const {
+    return Children;
+  }
   const SmallVectorImpl<DIEValue *> &getValues() const { return Values; }
   DIE *getParent() const { return Parent; }
   /// Climb up the parent chain to get the compile or type unit DIE this DIE
@@ -171,7 +175,7 @@ public:
   void addChild(DIE *Child) {
     assert(!Child->getParent());
     Abbrev.setChildrenFlag(dwarf::DW_CHILDREN_yes);
-    Children.push_back(Child);
+    Children.push_back(std::unique_ptr<DIE>(Child));
     Child->Parent = this;
   }
 
@@ -265,19 +269,19 @@ public:
 
   /// EmitValue - Emit integer of appropriate size.
   ///
-  virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
+  void EmitValue(AsmPrinter *AP, dwarf::Form Form) const override;
 
   uint64_t getValue() const { return Integer; }
 
   /// SizeOf - Determine size of integer value in bytes.
   ///
-  virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const;
+  unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const override;
 
   // Implement isa/cast/dyncast.
   static bool classof(const DIEValue *I) { return I->getType() == isInteger; }
 
 #ifndef NDEBUG
-  virtual void print(raw_ostream &O) const;
+  void print(raw_ostream &O) const override;
 #endif
 };
 
@@ -292,7 +296,7 @@ public:
 
   /// EmitValue - Emit expression value.
   ///
-  virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
+  void EmitValue(AsmPrinter *AP, dwarf::Form Form) const override;
 
   /// getValue - Get MCExpr.
   ///
@@ -300,13 +304,13 @@ public:
 
   /// SizeOf - Determine size of expression value in bytes.
   ///
-  virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const;
+  unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const override;
 
   // Implement isa/cast/dyncast.
   static bool classof(const DIEValue *E) { return E->getType() == isExpr; }
 
 #ifndef NDEBUG
-  virtual void print(raw_ostream &O) const;
+  void print(raw_ostream &O) const override;
 #endif
 };
 
@@ -321,7 +325,7 @@ public:
 
   /// EmitValue - Emit label value.
   ///
-  virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
+  void EmitValue(AsmPrinter *AP, dwarf::Form Form) const override;
 
   /// getValue - Get MCSymbol.
   ///
@@ -329,13 +333,13 @@ public:
 
   /// SizeOf - Determine size of label value in bytes.
   ///
-  virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const;
+  unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const override;
 
   // Implement isa/cast/dyncast.
   static bool classof(const DIEValue *L) { return L->getType() == isLabel; }
 
 #ifndef NDEBUG
-  virtual void print(raw_ostream &O) const;
+  void print(raw_ostream &O) const override;
 #endif
 };
 
@@ -352,17 +356,17 @@ public:
 
   /// EmitValue - Emit delta value.
   ///
-  virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
+  void EmitValue(AsmPrinter *AP, dwarf::Form Form) const override;
 
   /// SizeOf - Determine size of delta value in bytes.
   ///
-  virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const;
+  unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const override;
 
   // Implement isa/cast/dyncast.
   static bool classof(const DIEValue *D) { return D->getType() == isDelta; }
 
 #ifndef NDEBUG
-  virtual void print(raw_ostream &O) const;
+  void print(raw_ostream &O) const override;
 #endif
 };
 
@@ -382,17 +386,17 @@ public:
 
   /// EmitValue - Emit delta value.
   ///
-  virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
+  void EmitValue(AsmPrinter *AP, dwarf::Form Form) const override;
 
   /// SizeOf - Determine size of delta value in bytes.
   ///
-  virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const;
+  unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const override;
 
   // Implement isa/cast/dyncast.
   static bool classof(const DIEValue *D) { return D->getType() == isString; }
 
 #ifndef NDEBUG
-  virtual void print(raw_ostream &O) const;
+  void print(raw_ostream &O) const override;
 #endif
 };
 
@@ -412,11 +416,11 @@ public:
 
   /// EmitValue - Emit debug information entry offset.
   ///
-  virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
+  void EmitValue(AsmPrinter *AP, dwarf::Form Form) const override;
 
   /// SizeOf - Determine size of debug information entry in bytes.
   ///
-  virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const {
+   unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const override {
     return Form == dwarf::DW_FORM_ref_addr ? getRefAddrSize(AP)
                                            : sizeof(int32_t);
   }
@@ -428,7 +432,7 @@ public:
   static bool classof(const DIEValue *E) { return E->getType() == isEntry; }
 
 #ifndef NDEBUG
-  virtual void print(raw_ostream &O) const;
+  void print(raw_ostream &O) const override;
 #endif
 };
 
@@ -442,10 +446,10 @@ public:
       : DIEValue(isTypeSignature), Unit(Unit) {}
 
   /// \brief Emit type unit signature.
-  virtual void EmitValue(AsmPrinter *Asm, dwarf::Form Form) const;
+  void EmitValue(AsmPrinter *Asm, dwarf::Form Form) const override;
 
   /// Returns size of a ref_sig8 entry.
-  virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const {
+  unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const override {
     assert(Form == dwarf::DW_FORM_ref_sig8);
     return 8;
   }
@@ -455,7 +459,7 @@ public:
     return E->getType() == isTypeSignature;
   }
 #ifndef NDEBUG
-  virtual void print(raw_ostream &O) const;
+  void print(raw_ostream &O) const override;
   void dump() const;
 #endif
 };
@@ -466,7 +470,7 @@ public:
 class DIELoc : public DIEValue, public DIE {
   mutable unsigned Size; // Size in bytes excluding size header.
 public:
-  DIELoc() : DIEValue(isLoc), DIE(0), Size(0) {}
+  DIELoc() : DIEValue(isLoc), Size(0) {}
 
   /// ComputeSize - Calculate the size of the location expression.
   ///
@@ -489,17 +493,17 @@ public:
 
   /// EmitValue - Emit location data.
   ///
-  virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
+  void EmitValue(AsmPrinter *AP, dwarf::Form Form) const override;
 
   /// SizeOf - Determine size of location data in bytes.
   ///
-  virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const;
+  unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const override;
 
   // Implement isa/cast/dyncast.
   static bool classof(const DIEValue *E) { return E->getType() == isLoc; }
 
 #ifndef NDEBUG
-  virtual void print(raw_ostream &O) const;
+  void print(raw_ostream &O) const override;
 #endif
 };
 
@@ -509,7 +513,7 @@ public:
 class DIEBlock : public DIEValue, public DIE {
   mutable unsigned Size; // Size in bytes excluding size header.
 public:
-  DIEBlock() : DIEValue(isBlock), DIE(0), Size(0) {}
+  DIEBlock() : DIEValue(isBlock), Size(0) {}
 
   /// ComputeSize - Calculate the size of the location expression.
   ///
@@ -529,17 +533,17 @@ public:
 
   /// EmitValue - Emit location data.
   ///
-  virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
+  void EmitValue(AsmPrinter *AP, dwarf::Form Form) const override;
 
   /// SizeOf - Determine size of location data in bytes.
   ///
-  virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const;
+  unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const override;
 
   // Implement isa/cast/dyncast.
   static bool classof(const DIEValue *E) { return E->getType() == isBlock; }
 
 #ifndef NDEBUG
-  virtual void print(raw_ostream &O) const;
+  void print(raw_ostream &O) const override;
 #endif
 };
 
@@ -559,17 +563,17 @@ public:
 
   /// EmitValue - Emit location data.
   ///
-  virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
+  void EmitValue(AsmPrinter *AP, dwarf::Form Form) const override;
 
   /// SizeOf - Determine size of location data in bytes.
   ///
-  virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const;
+  unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const override;
 
   // Implement isa/cast/dyncast.
   static bool classof(const DIEValue *E) { return E->getType() == isLocList; }
 
 #ifndef NDEBUG
-  virtual void print(raw_ostream &O) const;
+  void print(raw_ostream &O) const override;
 #endif
 };