Skip to content

Commit 49d039b

Browse files
committed
Add helper for handling mapping phase errors
1 parent 2657c20 commit 49d039b

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

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

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -247,21 +247,17 @@ sortUsrToInfo(llvm::StringMap<std::unique_ptr<doc::Info>> &USRToInfo) {
247247
}
248248
}
249249

250-
llvm::Error runMappingPhase(tooling::ToolExecutor *Executor,
251-
clang::doc::ClangDocContext &CDCtx,
252-
tooling::ArgumentsAdjuster &ArgAdjuster,
253-
bool IgnoreMappingFailures) {
254-
auto Err = Executor->execute(doc::newMapperActionFactory(CDCtx), ArgAdjuster);
255-
if (Err) {
256-
if (IgnoreMappingFailures) {
257-
llvm::errs() << "Error mapping decls in files. Clang-doc will ignore "
258-
"these files and continue:\n"
259-
<< toString(std::move(Err)) << "\n";
260-
return llvm::Error::success();
261-
}
262-
return Err;
250+
llvm::Error handleMappingPhaseErrors(llvm::Error Err,
251+
bool IgnoreMappingFailures) {
252+
if (!Err)
253+
return llvm::Error::success();
254+
if (IgnoreMappingFailures) {
255+
llvm::errs() << "Error mapping decls in files. Clang-doc will ignore these "
256+
"files and continue:\n"
257+
<< toString(std::move(Err)) << "\n";
258+
return llvm::Error::success();
263259
}
264-
return llvm::Error::success();
260+
return Err;
265261
}
266262

267263
int main(int argc, const char **argv) {
@@ -318,8 +314,9 @@ Example usage for a project using a compile commands database:
318314

319315
// Mapping phase
320316
llvm::outs() << "Mapping decls...\n";
321-
ExitOnErr(runMappingPhase(Executor.get(), CDCtx, ArgAdjuster,
322-
IgnoreMappingFailures));
317+
ExitOnErr(handleMappingPhaseErrors(
318+
Executor->execute(doc::newMapperActionFactory(CDCtx), ArgAdjuster),
319+
IgnoreMappingFailures));
323320

324321
// Collect values into output by key.
325322
// In ToolResults, the Key is the hashed USR and the value is the

0 commit comments

Comments
 (0)