[clang] [Format] Do not crash on non-null terminated strings (PR #131299)

Ilya Biryukov via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 17 03:18:34 PDT 2025


================
@@ -2031,6 +2031,7 @@ class SourceManagerForFile {
   // The order of these fields are important - they should be in the same order
   // as they are created in `createSourceManagerForFile` so that they can be
   // deleted in the reverse order as they are created.
+  std::string ContentBuffer;
----------------
ilya-biryukov wrote:

FileManager and SourceManager will be referencing the contents of this buffer, so I think it's best to destroy them before this `string`.

Hence, the order is important, but maybe I should clarify the comment and mention the `Buffer` explicitly?

https://github.com/llvm/llvm-project/pull/131299


More information about the cfe-commits mailing list