https://github.com/kovan created https://github.com/llvm/llvm-project/pull/186589
## Summary - Use `toString()` to wrap `ExpectedParser.takeError()` so the `Error` is properly consumed before destruction - Without this, the `Error` destructor fires an assertion/abort (core dump) because LLVM's `Error` type enforces that errors must be explicitly handled - Fixes both occurrences in the file (lines 78 and 145) Fixes #97983 Continues the work from #98129 (approved by @nickhuang99 and @Sirraide but never merged) >From b92c2796dee7bc7c3c331d58e7545131b709a195 Mon Sep 17 00:00:00 2001 From: kovan <[email protected]> Date: Sat, 14 Mar 2026 13:05:32 +0100 Subject: [PATCH] [clang][docs] Fix unhandled Error in LibTooling examples Use toString() to wrap ExpectedParser.takeError() so the Error is properly consumed. Without this, the Error destructor fires an assertion because LLVM's Error type enforces explicit handling. Fixes #97983 Continues the work from PR #98129 --- clang/docs/LibTooling.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/docs/LibTooling.rst b/clang/docs/LibTooling.rst index 87d84321ab283..c6687fb9642f9 100644 --- a/clang/docs/LibTooling.rst +++ b/clang/docs/LibTooling.rst @@ -75,7 +75,7 @@ and automatic location of the compilation database using source files paths. auto ExpectedParser = CommonOptionsParser::create(argc, argv, MyToolCategory); if (!ExpectedParser) { // Fail gracefully for unsupported options. - llvm::errs() << ExpectedParser.takeError(); + llvm::errs() << toString(ExpectedParser.takeError()); return 1; } CommonOptionsParser& OptionsParser = ExpectedParser.get(); @@ -142,7 +142,7 @@ version of this example tool is also checked into the clang tree at int main(int argc, const char **argv) { auto ExpectedParser = CommonOptionsParser::create(argc, argv, MyToolCategory); if (!ExpectedParser) { - llvm::errs() << ExpectedParser.takeError(); + llvm::errs() << toString(ExpectedParser.takeError()); return 1; } CommonOptionsParser& OptionsParser = ExpectedParser.get(); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
