mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-30 10:35:03 +01:00
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:
@@ -29,7 +29,14 @@ void Matcher::AddReplacement(const clang::SourceManager& sm,
|
||||
}
|
||||
|
||||
auto rep = ct::Replacement(sm, sm.getExpansionRange(range), replacement_text);
|
||||
auto err = (*replacements)[std::string(rep.getFilePath())].add(rep);
|
||||
auto entry = replacements->find(std::string(rep.getFilePath()));
|
||||
if (entry == replacements->end()) {
|
||||
// The replacement was in a file which isn't being updated, such as a system
|
||||
// header.
|
||||
return;
|
||||
}
|
||||
|
||||
auto err = entry->second.add(rep);
|
||||
if (err) {
|
||||
llvm::report_fatal_error("Error with replacement `" + rep.toString() +
|
||||
"`: " + llvm::toString(std::move(err)) + "\n");
|
||||
|
||||
Reference in New Issue
Block a user