[cfe-dev] Suspicious discards of a StringRef in RawCommentList.cpp

Richard Smith via cfe-dev cfe-dev at lists.llvm.org
Fri Oct 14 18:33:15 PDT 2016


On Fri, Oct 14, 2016 at 5:52 PM, Justin Bogner via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> There are a couple of calls to getRawText in RawCommentList.cpp that
> have the comment "Make sure that RawText is valid" but don't actually
> use the result of getRawText, like this one:
>
>
>
> As far as I can tell this doesn't make sure anything is valid. It
> *might* hit the assert in getRawTextSlow:
>

I don't think even that can happen -- we already called it once in the
RawComment constructor.

but it's probably more likely to hit the case that says "if (Invalid)"
> and returns an empty string.
>
> Should this be an assert? Is the comment just wrong and this is
> pre-populating a cache or something? Should this just be deleted?


It looks like it should just be deleted, along with the RawTextValid flag
(which stores the same value as Kind != RCK_Invalid) and the lazy on-demand
RawText computation in getRawText (it's always called on construction).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161014/5306b475/attachment.html>


More information about the cfe-dev mailing list