6
6
//
7
7
// ===----------------------------------------------------------------------===//
8
8
9
- #include " SetLongJmpCheck .h"
9
+ #include " AvoidSetjmpLongjmpCheck .h"
10
10
#include " clang/AST/ASTContext.h"
11
11
#include " clang/ASTMatchers/ASTMatchFinder.h"
12
12
#include " clang/Frontend/CompilerInstance.h"
15
15
16
16
using namespace clang ::ast_matchers;
17
17
18
- namespace clang ::tidy::cert {
18
+ namespace clang ::tidy::modernize {
19
19
20
20
namespace {
21
21
const char DiagWording[] =
22
22
" do not call %0; consider using exception handling instead" ;
23
23
24
24
class SetJmpMacroCallbacks : public PPCallbacks {
25
- SetLongJmpCheck &Check;
25
+ AvoidSetjmpLongjmpCheck &Check;
26
26
27
27
public:
28
- explicit SetJmpMacroCallbacks (SetLongJmpCheck &Check) : Check(Check) {}
28
+ explicit SetJmpMacroCallbacks (AvoidSetjmpLongjmpCheck &Check)
29
+ : Check(Check) {}
29
30
30
31
void MacroExpands (const Token &MacroNameTok, const MacroDefinition &MD,
31
32
SourceRange Range, const MacroArgs *Args) override {
@@ -39,15 +40,14 @@ class SetJmpMacroCallbacks : public PPCallbacks {
39
40
};
40
41
} // namespace
41
42
42
- void SetLongJmpCheck::registerPPCallbacks (const SourceManager &SM,
43
- Preprocessor *PP,
44
- Preprocessor *ModuleExpanderPP) {
43
+ void AvoidSetjmpLongjmpCheck::registerPPCallbacks (
44
+ const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
45
45
// Per [headers]p5, setjmp must be exposed as a macro instead of a function,
46
46
// despite the allowance in C for setjmp to also be an extern function.
47
47
PP->addPPCallbacks (std::make_unique<SetJmpMacroCallbacks>(*this ));
48
48
}
49
49
50
- void SetLongJmpCheck ::registerMatchers (MatchFinder *Finder) {
50
+ void AvoidSetjmpLongjmpCheck ::registerMatchers (MatchFinder *Finder) {
51
51
// In case there is an implementation that happens to define setjmp as a
52
52
// function instead of a macro, this will also catch use of it. However, we
53
53
// are primarily searching for uses of longjmp.
@@ -57,9 +57,9 @@ void SetLongJmpCheck::registerMatchers(MatchFinder *Finder) {
57
57
this );
58
58
}
59
59
60
- void SetLongJmpCheck ::check (const MatchFinder::MatchResult &Result) {
60
+ void AvoidSetjmpLongjmpCheck ::check (const MatchFinder::MatchResult &Result) {
61
61
const auto *E = Result.Nodes .getNodeAs <CallExpr>(" expr" );
62
62
diag (E->getExprLoc (), DiagWording) << cast<NamedDecl>(E->getCalleeDecl ());
63
63
}
64
64
65
- } // namespace clang::tidy::cert
65
+ } // namespace clang::tidy::modernize
0 commit comments