[PATCH] D53427: [clangd] Replace StringRef in SymbolLocation with a char pointer.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 13 07:56:33 PST 2018


sammccall added inline comments.


================
Comment at: clangd/index/Index.h:306
+    llvm::StringRef S(P);
+    CB(S);
+    P = S.data();
----------------
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*`)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53427





More information about the cfe-commits mailing list