[clang] [clang] Canonicalizing `-include-pch` input in the Frontend (PR #180065)

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 5 15:53:52 PST 2026


================
@@ -1018,13 +1018,22 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
     return true;
   }
 
-  // If the implicit PCH include is actually a directory, rather than
-  // a single file, search for a suitable PCH file in that directory.
   if (!CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
     FileManager &FileMgr = CI.getFileManager();
     PreprocessorOptions &PPOpts = CI.getPreprocessorOpts();
+
+    // Canonicalize ImplicitPCHInclude. This way, all the downstream code,
+    // including the ASTWriter, will receive the absolute path to the included
+    // PCH. This way we can avoid reasoning about absolute path or relative
+    // paths later on during serialization.
+    SmallString<128> PCHIncludePath(PPOpts.ImplicitPCHInclude);
+    FileMgr.makeAbsolutePath(PCHIncludePath);
----------------
jansvoboda11 wrote:

IIRC there's some logic in `ASTWriter` to relativize paths. How does this interact with that?

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


More information about the cfe-commits mailing list