Skip to content

Commit cfbe47f

Browse files
committed
Use SourceManager from MatchFinder::MatchResult
1 parent f096fcf commit cfbe47f

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

reporting/InterfaceLister.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void InterfaceLister::check(const MatchFinder::MatchResult &Result) {
3434
return;
3535

3636
std::string sourceInfo(MatchedCallExpr->getExprLoc().printToString(
37-
MyContext->getSourceManager()));
37+
*Result.SourceManager));
3838
std::cerr << sourceInfo << " ; " << ClassName << " : "
3939
<< MatchedCallExpr->getMethodDecl()->getQualifiedNameAsString()
4040
<< "\n";

reporting/InterfaceLister.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ class InterfaceLister : public ClangTidyCheck {
2323
private:
2424
const std::string ClassName; // the class name for which we want to find
2525
// used interfaces
26-
ClangTidyContext * MyContext;
2726
public:
2827
InterfaceLister(StringRef Name, ClangTidyContext *Context)
29-
: ClangTidyCheck(Name, Context), ClassName(Options.get("ClassName", "")), MyContext(Context) {}
28+
: ClangTidyCheck(Name, Context), ClassName(Options.get("ClassName", "")) {}
3029

3130
void storeOptions(ClangTidyOptions::OptionMap &Opts) override {
3231
Options.store(Opts, "ClassName", ClassName);

reporting/VirtFuncLister.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ void VirtFuncLister::registerMatchers(MatchFinder *Finder) {
2323
}
2424

2525
void VirtFuncLister::check(const MatchFinder::MatchResult &Result) {
26+
const auto &SM = *Result.SourceManager;
2627
const auto *MatchedDecl =
2728
Result.Nodes.getNodeAs<CXXMethodDecl>("method");
2829
if (MatchedDecl) {
@@ -47,7 +48,7 @@ void VirtFuncLister::check(const MatchFinder::MatchResult &Result) {
4748

4849
if (iter == enditer) {
4950
SourceLocation loc = MatchedDecl->getLocStart();//getLocation();
50-
loc.dump(MyContext->getSourceManager());
51+
loc.dump(SM);
5152
llvm::errs() << "VIRTUAL-START-DECLARATION \n";
5253
} else {
5354
// otherwise find the base this is referring to
@@ -69,10 +70,10 @@ void VirtFuncLister::check(const MatchFinder::MatchResult &Result) {
6970
iter = (*iter)->begin_overridden_methods();
7071
}
7172
SourceLocation loc = (*lastiter)->getLocStart();//getLocation();
72-
loc.dump(MyContext->getSourceManager());
73+
loc.dump(SM);
7374
llvm::errs() << " OVERRIDEN-AT ";
7475
loc = MatchedDecl->getLocStart();//getLocation();
75-
loc.dump(MyContext->getSourceManager());
76+
loc.dump(SM);
7677
llvm::errs() << "\n";
7778
}
7879
}

reporting/VirtFuncLister.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ namespace reporting {
2020
/// used in the code base
2121
///
2222
class VirtFuncLister : public ClangTidyCheck {
23-
private:
24-
ClangTidyContext * MyContext;
2523
public:
2624
VirtFuncLister(StringRef Name, ClangTidyContext *Context)
27-
: ClangTidyCheck(Name, Context), MyContext(Context) {}
25+
: ClangTidyCheck(Name, Context) {}
2826

2927
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
3028
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;

0 commit comments

Comments
 (0)