Reference::target() doesn't and shouldn't return a nullptr.
authorRui Ueyama <ruiu@google.com>
Tue, 3 Jun 2014 05:04:07 +0000 (05:04 +0000)
committerRui Ueyama <ruiu@google.com>
Tue, 3 Jun 2014 05:04:07 +0000 (05:04 +0000)
llvm-svn: 210074

lld/include/lld/Core/Reference.h
lld/include/lld/ReaderWriter/Simple.h

index 70aba25..c5580ef 100644 (file)
@@ -100,8 +100,7 @@ public:
   /// byte offset into the Atom's content to do the fix up.
   virtual uint64_t offsetInAtom() const = 0;
 
-  /// If the reference is an edge to another Atom, then this returns the
-  /// other Atom.  Otherwise, it returns nullptr.
+  /// Returns the atom this reference refers to.
   virtual const Atom *target() const = 0;
 
   /// During linking, the linker may merge graphs which coalesces some nodes
index 4f32fb8..b118f86 100644 (file)
@@ -93,13 +93,15 @@ public:
 
   uint64_t offsetInAtom() const override { return _offsetInAtom; }
 
-  const Atom *target() const override { return _target; }
+  const Atom *target() const override {
+    assert(_target);
+    return _target;
+  }
 
   Addend addend() const override { return _addend; }
-
   void setAddend(Addend a) override { _addend = a; }
-
   void setTarget(const Atom *newAtom) override { _target = newAtom; }
+
 private:
   const Atom *_target;
   uint64_t _offsetInAtom;