Skip to content

[clang][deps] Avoid unchecked error assertion #134284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2025

Conversation

jansvoboda11
Copy link
Contributor

No description provided.

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Apr 3, 2025
@jansvoboda11 jansvoboda11 requested a review from Copilot April 3, 2025 17:38
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modifies the error reporting when opening an output file in clang-scan-deps to avoid using unchecked error assertions.

  • Replace conversion of errno with llvm::errorCodeToError(EC) to using EC.message() for error output.
Comments suppressed due to low confidence (1)

clang/tools/clang-scan-deps/ClangScanDeps.cpp:931

  • Consider verifying that EC.message() provides sufficient context compared to llvm::errorCodeToError(EC) to ensure that users receive clear diagnostic information if the output file fails to open.
llvm::errs() << "Failed to open output file '" << OutputFileName << "': " << EC.message() << '\n';

@llvmbot
Copy link
Member

llvmbot commented Apr 3, 2025

@llvm/pr-subscribers-clang

Author: Jan Svoboda (jansvoboda11)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/134284.diff

1 Files Affected:

  • (modified) clang/tools/clang-scan-deps/ClangScanDeps.cpp (+1-1)
diff --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index fa63649bb9028..13dab6e445733 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -929,7 +929,7 @@ int clang_scan_deps_main(int argc, char **argv, const llvm::ToolContext &) {
     FileOS.emplace(OutputFileName, EC, llvm::sys::fs::OF_Text);
     if (EC) {
       llvm::errs() << "Failed to open output file '" << OutputFileName
-                   << "': " << llvm::errorCodeToError(EC) << '\n';
+                   << "': " << EC.message() << '\n';
       std::exit(1);
     }
     return *FileOS;

@jansvoboda11 jansvoboda11 merged commit 506630d into llvm:main Apr 3, 2025
13 checks passed
@jansvoboda11 jansvoboda11 deleted the clang-scan-deps-output-error branch April 3, 2025 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants