Skip to content

Commit 2e14a63

Browse files
committed
added types of throw exception and more tests
1 parent 8afa030 commit 2e14a63

File tree

5 files changed

+201
-107
lines changed

5 files changed

+201
-107
lines changed

clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,26 +81,24 @@ void ExceptionEscapeCheck::check(const MatchFinder::MatchResult &Result) {
8181
const utils::ExceptionAnalyzer::ExceptionInfo Info =
8282
Tracer.analyze(MatchedDecl);
8383

84-
if (Info.getBehaviour() != utils::ExceptionAnalyzer::State::Throwing) {
84+
if (Info.getBehaviour() != utils::ExceptionAnalyzer::State::Throwing)
8585
return;
86-
}
8786

8887
diag(MatchedDecl->getLocation(), "an exception may be thrown in function "
8988
"%0 which should not throw exceptions")
9089
<< MatchedDecl;
9190

92-
const utils::ExceptionAnalyzer::ExceptionInfo::ThrowInfo ThrowInfo =
93-
Info.getExceptions().begin()->getSecond();
91+
const auto &[ThrowType, ThrowInfo] = *Info.getExceptions().begin();
9492

95-
if (ThrowInfo.Loc.isInvalid()) {
93+
if (ThrowInfo.Loc.isInvalid())
9694
return;
97-
}
9895

9996
const utils::ExceptionAnalyzer::CallStack &Stack = ThrowInfo.Stack;
10097
diag(ThrowInfo.Loc,
101-
"frame #0: unhandled exception may be thrown in function %0 here",
98+
"frame #0: unhandled exception of type %0 may be thrown in function %1 "
99+
"here",
102100
DiagnosticIDs::Note)
103-
<< Stack.back().first;
101+
<< QualType(ThrowType, 0U) << Stack.back().first;
104102

105103
size_t FrameNo = 1;
106104
for (auto CurrIt = ++Stack.rbegin(), PrevIt = Stack.rbegin();

0 commit comments

Comments
 (0)