[cfe-users] Calling match in a clang-tidy check's check method

Lewis, Cannada via cfe-users cfe-users at lists.llvm.org
Wed Jan 15 14:57:45 PST 2020

Is there a way to get a non const reference to the ASTContext inside of a clang tidy check?  I have two reasons I want this.  

1. To do matches on specific nodes like below. 

void MyCheck::check(const MatchFinder::MatchResult &Result) {
	auto const *Lambda = Result.Nodes.getNodeAs<CXXRecordDecl>("Lambda");

	// Doesn’t work because Context is a const* and match has no const overloads
	auto BN = match(<more matchers here>, Lambda, *Result.Context);

2. To use the ExprMutationAnalyzer in my check function, which requires a non const ASTContext reference for its constructor. 

-Cannada Lewis 

More information about the cfe-users mailing list