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



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to