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

Ben Langmuir via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 7 10:53:26 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:

What's your opinion on the use of nullable `PP`? This seems like the same issue as `Context` where it's not obvious where it's mandatory and where it's not.

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


More information about the cfe-commits mailing list