Skip to content

Commit daab868

Browse files
committed
Addressing PR feedback
1 parent f0b3184 commit daab868

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
using namespace clang::ast_matchers;
4444
using namespace clang::tooling;
4545
using namespace clang;
46-
static llvm::ExitOnError ExitOnErr;
4746

4847
static llvm::cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
4948
static llvm::cl::OptionCategory ClangDocCategory("clang-doc options");
@@ -119,6 +118,8 @@ static llvm::cl::opt<OutputFormatTy> FormatEnum(
119118
"Documentation in mustache HTML format")),
120119
llvm::cl::init(OutputFormatTy::yaml), llvm::cl::cat(ClangDocCategory));
121120

121+
static llvm::ExitOnError ExitOnErr;
122+
122123
static std::string getFormatString() {
123124
switch (FormatEnum) {
124125
case OutputFormatTy::yaml:
@@ -387,8 +388,13 @@ Example usage for a project using a compile commands database:
387388
sortUsrToInfo(USRToInfo);
388389

389390
// Ensure the root output directory exists.
390-
ExitOnErr(
391-
llvm::errorCodeToError(llvm::sys::fs::create_directories(OutDirectory)));
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()));
396+
}
397+
392398

393399
// Run the generator.
394400
llvm::outs() << "Generating docs...\n";
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: not clang-doc %S/Inputs/basic-project/src/Circle.cpp -output=/root/docs 2>&1 | FileCheck %s
2+
3+
// CHECK: clang-doc error: Failed to create directory
4+

0 commit comments

Comments
 (0)