Skip to content

Commit fb8ca57

Browse files
committed
Use more relevant file system API for error handling
Address issue with the lit tests
1 parent 05328e9 commit fb8ca57

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

clang-tools-extra/clang-doc/tool/ClangDocMain.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,11 +388,8 @@ Example usage for a project using a compile commands database:
388388
sortUsrToInfo(USRToInfo);
389389

390390
// Ensure the root output directory exists.
391-
if (std::error_code Err = llvm::sys::fs::create_directories(OutDirectory);
392-
Err != std::error_code()) {
393-
ExitOnErr(llvm::createStringError(
394-
llvm::inconvertibleErrorCode(), "Failed to create directory '%s': %s",
395-
OutDirectory.c_str(), Err.message().c_str()));
391+
if (std::error_code Err = llvm::sys::fs::create_directories(OutDirectory)) {
392+
ExitOnErr(llvm::createFileError(OutDirectory, Err));
396393
}
397394

398395
// Run the generator.
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
// RUN: not clang-doc %S/Inputs/basic-project/src/Circle.cpp -output=/root/docs 2>&1 | FileCheck %s
1+
// Test: Invalid output path (%t is a file, not a directory)
2+
// RUN: rm -rf %t && echo "not a dir" > %t
3+
// RUN: not clang-doc %s -output=%t/subdir 2>&1 | FileCheck --check-prefix=BAD-OUTPUT %s
24

3-
// CHECK: clang-doc error: Failed to create directory
5+
// BAD-OUTPUT: clang-doc error:
6+
// BAD-OUTPUT: Not a directory
47

8+
//
9+
// Test: Invalid format option
10+
// RUN: not clang-doc %s -format=badformat 2>&1 | FileCheck --check-prefix=BAD-FORMAT %s
11+
12+
// BAD-FORMAT: clang-doc: for the --format option: Cannot find option named 'badformat'!

0 commit comments

Comments
 (0)