I want to use clang-tidy to find out all uncaught exceptions by its direct or indirect caller, up to main, but this demo has no effect. Generally, I want to clang-tidy to report that the function cc is throwing an exception that not being caught by main, but it reports nothing, I want to know why & how can I achieve my goal? Thks
main.cpp
#include <iostream>
int m = 0;
extern int cc() throw();
int ff() {
if (m > 0) {
throw "H";
}
return 1;
}
int gg() {
if (m > 0) {
return ff();
} else {
return 1;
}
}
int main() {
return cc();
}
cc.cpp
extern int m;
int cc() {
if (m > 0) {
return 1;
}
throw "D";
}
.clang-tidy
Checks: '-*,bugprone-exception-escape'
CheckOptions:
- key: FunctionsThatShouldNotThrow
value: main
HeaderFilterRegex: '.*'
command
clang-tidy main.cpp cc.cpp