Skip to content

Commit f66f5df

Browse files
committed
Match macros in rules
1 parent 2a23bcc commit f66f5df

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
@@ -170,6 +170,13 @@ class Callback : public clang::ast_matchers::MatchFinder::MatchCallback {
170170
add(Mapper::ToString(decl));
171171
return;
172172
}
173+
if (const auto *lit =
174+
R.Nodes.getNodeAs<clang::IntegerLiteral>("macro_int")) {
175+
if (lit->getBeginLoc().isMacroID()) {
176+
add(Mapper::ToString(lit));
177+
}
178+
return;
179+
}
173180
}
174181
}
175182

@@ -668,7 +675,8 @@ class ActionFactory : public clang::tooling::FrontendActionFactory {
668675
declRefExpr(to(decl(unless(parmVarDecl()))))))
669676
.bind("udeclref"),
670677
cxxDependentScopeMemberExpr().bind("dsme"),
671-
cxxUnresolvedConstructExpr().bind("uctor"))))),
678+
cxxUnresolvedConstructExpr().bind("uctor"),
679+
integerLiteral().bind("macro_int"))))),
672680
hasAncestor(functionDecl(isDefinition(),
673681
matchesName("(^|::)f[0-9]+$"),
674682
isExpansionInMainFile())

0 commit comments

Comments
 (0)