[clang] [WIP] Implement `print-deserialized-declarations` flag to dump source… (PR #133910)

Viktoriia Bakalova via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 3 04:49:03 PDT 2025


================
@@ -121,6 +252,19 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI,
   if (!Consumer)
     return nullptr;
 
+  std::vector<std::unique_ptr<ASTConsumer>> Consumers;
+  llvm::StringRef PrintDeserializedDeclarationsPath = CI.getFrontendOpts().PrintDeserializedDeclarationsPath;
+  if (!PrintDeserializedDeclarationsPath.empty()) {
+    std::error_code ErrorCode;
+    auto* FileStream = new llvm::raw_fd_ostream(PrintDeserializedDeclarationsPath, ErrorCode, llvm::sys::fs::OF_None);
+    if (!ErrorCode) {
+      DeserializedDeclsLineRangePrinter* Printer = new DeserializedDeclsLineRangePrinter(CI.getSourceManager(), std::unique_ptr<llvm::raw_fd_ostream>(FileStream));
+      Consumers.push_back(std::unique_ptr<ASTConsumer>(Printer));
+    } else {
+      llvm::errs() << "Could not open file with path: " << PrintDeserializedDeclarationsPath << ", error: " << ErrorCode.message() << "\n";
----------------
VitaNuo wrote:

Sure.

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


More information about the cfe-commits mailing list