[lld] r210074 - Reference::target() doesn't and shouldn't return a nullptr.

Rui Ueyama ruiu at google.com
Mon Jun 2 22:04:07 PDT 2014


Author: ruiu
Date: Tue Jun  3 00:04:07 2014
New Revision: 210074

URL: http://llvm.org/viewvc/llvm-project?rev=210074&view=rev
Log:
Reference::target() doesn't and shouldn't return a nullptr.

Modified:
    lld/trunk/include/lld/Core/Reference.h
    lld/trunk/include/lld/ReaderWriter/Simple.h

Modified: lld/trunk/include/lld/Core/Reference.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Reference.h?rev=210074&r1=210073&r2=210074&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Reference.h (original)
+++ lld/trunk/include/lld/Core/Reference.h Tue Jun  3 00:04:07 2014
@@ -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

Modified: lld/trunk/include/lld/ReaderWriter/Simple.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/Simple.h?rev=210074&r1=210073&r2=210074&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/Simple.h (original)
+++ lld/trunk/include/lld/ReaderWriter/Simple.h Tue Jun  3 00:04:07 2014
@@ -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;





More information about the llvm-commits mailing list