================ @@ -2382,14 +2382,20 @@ size_t SourceManager::getDataStructureSizes() const { SourceManagerForFile::SourceManagerForFile(StringRef FileName, StringRef Content) { + // We copy to `std::string` for Context instead of StringRef because the + // SourceManager::getBufferData() works only with null-terminated buffers. + // And we still want to keep the API convenient. + ContentBuffer = Content.str(); ---------------- HazardyKnusperkeks wrote:
My IDE (QtCreator) does uses libformat regularly while typing. I would also prefer not to perform copies all over the place. How about storing a StringRef and assign `Content` if it ends with a zero, and only perform the copy if it doesn't? https://github.com/llvm/llvm-project/pull/131299 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits