Skip to content

Commit 2197e88

Browse files
committed
[clang-doc] remove useless try catch
1 parent d88c1e7 commit 2197e88

File tree

2 files changed

+27
-49
lines changed

2 files changed

+27
-49
lines changed

clang-tools-extra/clang-doc/HTMLGenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ static llvm::Error serializeIndex(ClangDocContext &CDCtx) {
983983
llvm::json::OStream J(OS, 2);
984984
std::function<void(Index)> IndexToJSON = [&](const Index &I) {
985985
J.object([&] {
986-
//J.attribute("USR", toHex(llvm::toStringRef(I.USR)));
986+
J.attribute("USR", toHex(llvm::toStringRef(I.USR)));
987987
J.attribute("Name", I.Name);
988988
J.attribute("RefType", getRefType(I.RefType));
989989
J.attribute("Path", I.getRelativeFilePath(""));

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

Lines changed: 26 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@
4545
#include <atomic>
4646
#include <mutex>
4747
#include <string>
48-
#include <exception>
49-
#include <typeinfo>
50-
#include <stdexcept>
51-
5248

5349
using namespace clang::ast_matchers;
5450
using namespace clang::tooling;
@@ -209,19 +205,6 @@ llvm::Error getHtmlAssetFiles(const char *Argv0,
209205
return getDefaultAssetFiles(Argv0, CDCtx);
210206
}
211207

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-
225208
int main(int argc, const char **argv) {
226209
llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
227210
std::error_code OK;
@@ -320,41 +303,36 @@ Example usage for a project using a compile commands database:
320303
llvm::DefaultThreadPool Pool(llvm::hardware_concurrency(ExecutorConcurrency));
321304
for (auto &Group : USRToBitcode) {
322305
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;
341314
return;
342315
}
316+
std::move(ReadInfos->begin(), ReadInfos->end(),
317+
std::back_inserter(Infos));
318+
}
343319

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+
}
349325

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());
358336
}
359337
});
360338
}

0 commit comments

Comments
 (0)