Skip to content

Commit 1155844

Browse files
committed
[Summary] move the ast matcher callback out of the attribute declaration
1 parent 016dcdb commit 1155844

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

clang/include/clang/Sema/SummaryAttribute.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,6 @@ class SummaryAttr {
3737
};
3838

3939
class NoWriteGlobalAttr : public SummaryAttr {
40-
class Callback : public ast_matchers::MatchFinder::MatchCallback {
41-
public:
42-
bool WriteGlobal = false;
43-
44-
void
45-
run(const ast_matchers::MatchFinder::MatchResult &Result) override final;
46-
};
47-
4840
NoWriteGlobalAttr() : SummaryAttr(NO_WRITE_GLOBAL, "no_write_global") {}
4941

5042
public:

clang/lib/Sema/SummaryAttribute.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,24 @@
22
#include "clang/Sema/SummaryContext.h"
33

44
namespace clang {
5-
void NoWriteGlobalAttr::Callback::run(
6-
const ast_matchers::MatchFinder::MatchResult &Result) {
7-
const auto *Assignment = Result.Nodes.getNodeAs<BinaryOperator>("assignment");
8-
if (!Assignment)
9-
return;
10-
11-
WriteGlobal = true;
12-
}
13-
145
bool NoWriteGlobalAttr::infer(const FunctionDecl *FD) const {
156
using namespace ast_matchers;
167
MatchFinder Finder;
17-
Callback CB;
8+
9+
class Callback : public ast_matchers::MatchFinder::MatchCallback {
10+
public:
11+
bool WriteGlobal = false;
12+
13+
void
14+
run(const ast_matchers::MatchFinder::MatchResult &Result) override final {
15+
const auto *Assignment =
16+
Result.Nodes.getNodeAs<BinaryOperator>("assignment");
17+
if (!Assignment)
18+
return;
19+
20+
WriteGlobal = true;
21+
}
22+
} CB;
1823

1924
Finder.addMatcher(
2025
functionDecl(forEachDescendant(

0 commit comments

Comments
 (0)