[clang] [WIP] Implement `print-deserialized-declarations` flag to dump source… (PR #133910)
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 2 04:54:26 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";
----------------
ilya-biryukov wrote:
NIT: maybe add a more descriptive error message, e.g. `Failed to create output file for -<flag>`?
https://github.com/llvm/llvm-project/pull/133910
More information about the cfe-commits
mailing list