Using GHC as a library: why does `nameSrcSpan` for all my `Name`s return a `UnhelpfulSpan`?

My goal is to be able to, for a Haskell module, enumerate the exports that are defined in the module in question (ie. the exports that are not re-exports from some other module). I want to modify the GHC utility dump-decls to do this.

In dump-decls, there is thing (of type TyThing) defined here: utils/dump-decls/Main.hs · 74132c2b0992849f83ef87c8a56ac3975738e767 · Glasgow Haskell Compiler / GHC · GitLab. If I pattern match this thing on the AnId constructor to get a value of type Id, and then apply nameSrcSpan . varName to this value, I always get a UnhelpfulSpan.
How can I get a RealSrcSpan instead?

My plan is to use the RealSrcSpan to tell which exports are re-exports by seeing if the thing that’s exported is defined in the same module that exports it.