From 04ade04e981cfe7377a1f61483af88a272719140 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Tue, 3 Jun 2014 05:04:07 +0000 Subject: [PATCH] Reference::target() doesn't and shouldn't return a nullptr. llvm-svn: 210074 --- lld/include/lld/Core/Reference.h | 3 +-- lld/include/lld/ReaderWriter/Simple.h | 8 +++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lld/include/lld/Core/Reference.h b/lld/include/lld/Core/Reference.h index 70aba25..c5580ef 100644 --- a/lld/include/lld/Core/Reference.h +++ b/lld/include/lld/Core/Reference.h @@ -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 diff --git a/lld/include/lld/ReaderWriter/Simple.h b/lld/include/lld/ReaderWriter/Simple.h index 4f32fb8..b118f86 100644 --- a/lld/include/lld/ReaderWriter/Simple.h +++ b/lld/include/lld/ReaderWriter/Simple.h @@ -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; -- 2.7.4