Skip to content

Commit ad41891

Browse files
committed
added handling of unknown exceptions and renamed diagnostics
1 parent df22889 commit ad41891

File tree

6 files changed

+107
-102
lines changed

6 files changed

+107
-102
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void ExceptionEscapeCheck::check(const MatchFinder::MatchResult &Result) {
102102
// stack of thrown exception.
103103
const utils::ExceptionAnalyzer::CallStack &Stack = ThrowInfo.Stack;
104104
diag(Stack.front()->getLocation(),
105-
"example of unhandled exception throw stack, starting from function %0",
105+
"throw stack of unhandled exception, starting from function %0",
106106
DiagnosticIDs::Note)
107107
<< Stack.front();
108108

clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,9 +491,13 @@ ExceptionAnalyzer::throwsException(const FunctionDecl *Func,
491491

492492
auto Result = ExceptionInfo::createUnknown();
493493
if (const auto *FPT = Func->getType()->getAs<FunctionProtoType>()) {
494-
for (const QualType &Ex : FPT->exceptions())
495-
// Nothing in ThrowInfo because there is no location of 'throw'
496-
Result.registerException(Ex.getTypePtr(), {});
494+
for (const QualType &Ex : FPT->exceptions()) {
495+
CallStack.insert(Func);
496+
Result.registerException(
497+
Ex.getTypePtr(),
498+
{Func->getExceptionSpecSourceRange().getBegin(), CallStack});
499+
CallStack.remove(Func);
500+
}
497501
}
498502
return Result;
499503
}

0 commit comments

Comments
 (0)