|
45 | 45 | #include <atomic>
|
46 | 46 | #include <mutex>
|
47 | 47 | #include <string>
|
48 |
| -#include <exception> |
49 |
| -#include <typeinfo> |
50 |
| -#include <stdexcept> |
51 |
| - |
52 | 48 |
|
53 | 49 | using namespace clang::ast_matchers;
|
54 | 50 | using namespace clang::tooling;
|
@@ -209,19 +205,6 @@ llvm::Error getHtmlAssetFiles(const char *Argv0,
|
209 | 205 | return getDefaultAssetFiles(Argv0, CDCtx);
|
210 | 206 | }
|
211 | 207 |
|
212 |
| -void handle_eptr(std::exception_ptr eptr) // passing by value is OK |
213 |
| -{ |
214 |
| - try |
215 |
| - { |
216 |
| - if (eptr) |
217 |
| - std::rethrow_exception(eptr); |
218 |
| - } |
219 |
| - catch(const std::exception& e) |
220 |
| - { |
221 |
| - llvm::outs() << "Caught exception: '" << e.what() << "'\n"; |
222 |
| - } |
223 |
| -} |
224 |
| - |
225 | 208 | int main(int argc, const char **argv) {
|
226 | 209 | llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
|
227 | 210 | std::error_code OK;
|
@@ -320,41 +303,36 @@ Example usage for a project using a compile commands database:
|
320 | 303 | llvm::DefaultThreadPool Pool(llvm::hardware_concurrency(ExecutorConcurrency));
|
321 | 304 | for (auto &Group : USRToBitcode) {
|
322 | 305 | Pool.async([&]() {
|
323 |
| - try { |
324 |
| - std::vector<std::unique_ptr<doc::Info>> Infos; |
325 |
| - for (auto &Bitcode : Group.getValue()) { |
326 |
| - llvm::BitstreamCursor Stream(Bitcode); |
327 |
| - doc::ClangDocBitcodeReader Reader(Stream); |
328 |
| - auto ReadInfos = Reader.readBitcode(); |
329 |
| - if (!ReadInfos) { |
330 |
| - llvm::errs() << toString(ReadInfos.takeError()) << "\n"; |
331 |
| - Error = true; |
332 |
| - return; |
333 |
| - } |
334 |
| - std::move(ReadInfos->begin(), ReadInfos->end(), |
335 |
| - std::back_inserter(Infos)); |
336 |
| - } |
337 |
| - |
338 |
| - auto Reduced = doc::mergeInfos(Infos); |
339 |
| - if (!Reduced) { |
340 |
| - llvm::errs() << llvm::toString(Reduced.takeError()); |
| 306 | + std::vector<std::unique_ptr<doc::Info>> Infos; |
| 307 | + for (auto &Bitcode : Group.getValue()) { |
| 308 | + llvm::BitstreamCursor Stream(Bitcode); |
| 309 | + doc::ClangDocBitcodeReader Reader(Stream); |
| 310 | + auto ReadInfos = Reader.readBitcode(); |
| 311 | + if (!ReadInfos) { |
| 312 | + llvm::errs() << toString(ReadInfos.takeError()) << "\n"; |
| 313 | + Error = true; |
341 | 314 | return;
|
342 | 315 | }
|
| 316 | + std::move(ReadInfos->begin(), ReadInfos->end(), |
| 317 | + std::back_inserter(Infos)); |
| 318 | + } |
343 | 319 |
|
344 |
| - // Add a reference to this Info in the Index |
345 |
| - { |
346 |
| - std::lock_guard<llvm::sys::Mutex> Guard(IndexMutex); |
347 |
| - clang::doc::Generator::addInfoToIndex(CDCtx.Idx, Reduced.get().get()); |
348 |
| - } |
| 320 | + auto Reduced = doc::mergeInfos(Infos); |
| 321 | + if (!Reduced) { |
| 322 | + llvm::errs() << llvm::toString(Reduced.takeError()); |
| 323 | + return; |
| 324 | + } |
349 | 325 |
|
350 |
| - // Save in the result map (needs a lock due to threaded access). |
351 |
| - { |
352 |
| - std::lock_guard<llvm::sys::Mutex> Guard(USRToInfoMutex); |
353 |
| - USRToInfo[Group.getKey()] = std::move(Reduced.get()); |
354 |
| - } |
355 |
| - } catch (...) { |
356 |
| - std::exception_ptr P = std::current_exception(); |
357 |
| - handle_eptr(P); |
| 326 | + // Add a reference to this Info in the Index |
| 327 | + { |
| 328 | + std::lock_guard<llvm::sys::Mutex> Guard(IndexMutex); |
| 329 | + clang::doc::Generator::addInfoToIndex(CDCtx.Idx, Reduced.get().get()); |
| 330 | + } |
| 331 | + |
| 332 | + // Save in the result map (needs a lock due to threaded access). |
| 333 | + { |
| 334 | + std::lock_guard<llvm::sys::Mutex> Guard(USRToInfoMutex); |
| 335 | + USRToInfo[Group.getKey()] = std::move(Reduced.get()); |
358 | 336 | }
|
359 | 337 | });
|
360 | 338 | }
|
|
0 commit comments