[PATCH] D53427: [clangd] Replace StringRef in SymbolLocation with a char pointer.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 13 08:27:27 PST 2018
hokein added inline comments.
================
Comment at: clangd/index/Index.h:306
+ llvm::StringRef S(P);
+ CB(S);
+ P = S.data();
----------------
sammccall wrote:
> hokein wrote:
> > sammccall wrote:
> > > ```assert (!S.data()[S.size()] && "Visited StringRef must be null-terminated")
> > Does this assert actually work? The `StringRef` is constructed from the `char *` (which using `strlen`). This assert will not get triggered I think, `S.data()[S.size()]` is always `\0`.
> The point is the callback takes a mutable reference, and can replace the stringref.
> We're asserting that the *new* stringref is nullterminated (so we can convert it safely to a `char*`)
Ah, that makes sense, I missed the fact that the `CB` mutates `S`.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D53427
More information about the cfe-commits
mailing list