[llvm] r226048 - IR: Move MDLocation into place

Duncan P. N. Exon Smith dexonsmith at apple.com
Wed Jan 14 15:06:48 PST 2015


> On 2015-Jan-14, at 14:41, David Blaikie <dblaikie at gmail.com> wrote:
> 
> 
> 
> On Wed, Jan 14, 2015 at 2:39 PM, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:
> 
> > On 2015-Jan-14, at 14:35, David Blaikie <dblaikie at gmail.com> wrote:
> >
> >
> > Modified: llvm/trunk/include/llvm/IR/DebugInfo.h
> > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfo.h?rev=226048&r1=226047&r2=226048&view=diff
> > ==============================================================================
> > --- llvm/trunk/include/llvm/IR/DebugInfo.h (original)
> > +++ llvm/trunk/include/llvm/IR/DebugInfo.h Wed Jan 14 16:27:36 2015
> > @@ -877,10 +877,26 @@ class DILocation : public DIDescriptor {
> >  public:
> >    explicit DILocation(const MDNode *N) : DIDescriptor(N) {}
> >
> > -  unsigned getLineNumber() const { return getUnsignedField(0); }
> > -  unsigned getColumnNumber() const { return getUnsignedField(1); }
> > -  DIScope getScope() const { return getFieldAs<DIScope>(2); }
> > -  DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
> > +  unsigned getLineNumber() const {
> > +    if (auto *L = dyn_cast_or_null<MDLocation>(DbgNode))
> >
> > What else can this be other than an MDLocation? Should it just be cast_or_null?
> 
> *I* think it should be.  I'd actually go further and make this
> `cast<MDLocation>` (if `DbgNode` is `nullptr`, this shouldn't be
> called at all), but that's obviously a major semantic change.
> 
> However, the `DIDescriptor` stuff is very permissive right now
> about what's going on underneath.  It never asserts, it just returns
> things like `0` and `nullptr`.  `dyn_cast_or_null<>` kept this
> initial commit NFC.
> 
> I've been pretty aggressive about making things less vague/permissive as I've been making progress, adding assertions for things being of certain types, etc (subprograms in the subprogram list only, etc).
> 
> Welcome to do the same, though I realize it's not necessarily your fight to fight right now.

I'll pick away at it :).



More information about the llvm-commits mailing list