[clang] [clang][serialization] Pass `ASTContext` explicitly (PR #115235)

Ben Langmuir via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 7 13:20:17 PST 2024


================
@@ -4753,15 +4755,12 @@ void ASTWriter::AddString(StringRef Str, RecordDataImpl &Record) {
 }
 
 bool ASTWriter::PreparePathForOutput(SmallVectorImpl<char> &Path) {
-  assert(Context && "should have context when outputting path");
-
   // Leave special file names as they are.
   StringRef PathStr(Path.data(), Path.size());
   if (PathStr == "<built-in>" || PathStr == "<command line>")
     return false;
 
-  bool Changed =
-      cleanPathForOutput(Context->getSourceManager().getFileManager(), Path);
+  bool Changed = cleanPathForOutput(PP->getFileManager(), Path);
----------------
benlangmuir wrote:

Okay, makes sense. I suggest we add an `assert` here just to help catch this; either assert on PP not being null, or maybe follow the example in `getLangOpts` and assert on `WritingAST`.

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


More information about the cfe-commits mailing list