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

Justin Bogner via cfe-dev cfe-dev at lists.llvm.org
Fri Oct 14 17:52:57 PDT 2016


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:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/x-c++
Size: 167 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161014/d18959a6/attachment.bin>
-------------- next part --------------

As far as I can tell this doesn't make sure anything is valid. It
*might* hit the assert in getRawTextSlow:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/x-c++
Size: 785 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161014/d18959a6/attachment-0001.bin>
-------------- next part --------------

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?


More information about the cfe-dev mailing list