Skip to content

Commit 73ae74e

Browse files
committed
Match macros in rules
1 parent a4d794d commit 73ae74e

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

cpp2rust/cpp_rule_preprocessor.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ class Callback : public clang::ast_matchers::MatchFinder::MatchCallback {
172172
add(Mapper::ToString(decl));
173173
return;
174174
}
175+
if (const auto *lit =
176+
R.Nodes.getNodeAs<clang::IntegerLiteral>("macro_int")) {
177+
if (lit->getBeginLoc().isMacroID()) {
178+
add(Mapper::ToString(lit));
179+
}
180+
return;
181+
}
175182
}
176183
}
177184

@@ -670,7 +677,8 @@ class ActionFactory : public clang::tooling::FrontendActionFactory {
670677
declRefExpr(to(decl(unless(parmVarDecl()))))))
671678
.bind("udeclref"),
672679
cxxDependentScopeMemberExpr().bind("dsme"),
673-
cxxUnresolvedConstructExpr().bind("uctor"))))),
680+
cxxUnresolvedConstructExpr().bind("uctor"),
681+
integerLiteral().bind("macro_int"))))),
674682
hasAncestor(functionDecl(isDefinition(),
675683
matchesName("(^|::)f[0-9]+$"),
676684
isExpansionInMainFile())

0 commit comments

Comments
 (0)