Change how replacements are filtered (#541)

This replaces the use of `isExpansionInMainFile` with instead taking the list of input files, and only touching them. This doesn't keep `isExpansionInMainFile` because it should be redundant, and as such it'd be easy to forget. Unless it starts being a performance issue, it's probably better to omit.
This commit is contained in:
Jon Meow
2021-06-03 16:35:55 -07:00
committed by GitHub
parent c836ae78bb
commit f180c64454
4 changed files with 36 additions and 21 deletions
+2 -7
View File
@@ -13,13 +13,8 @@ namespace Carbon {
FnInserter::FnInserter(std::map<std::string, Replacements>& in_replacements,
cam::MatchFinder* finder)
: Matcher(in_replacements) {
// TODO: Switch from isExpansionInMainFile to isDefinition. That should then
// include `for (const auto* redecl : func->redecls())` to generate
// replacements.
finder->addMatcher(
cam::functionDecl(cam::isExpansionInMainFile(), cam::hasTrailingReturn())
.bind(Label),
this);
finder->addMatcher(cam::functionDecl(cam::hasTrailingReturn()).bind(Label),
this);
}
void FnInserter::run(const cam::MatchFinder::MatchResult& result) {