The current version does not deduplicate equivalent file paths correctly.
For example, a relative path and an absolute path are considered inequivalent.
Comparing FileEnry addresses these issues.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Tooling/Core/Replacement.cpp | ||
---|---|---|
578 ↗ | (On Diff #76881) | (saves 2 lines of code) (although not particularly important) if (ProcessedFileEntries.insert(FE).second) Result[Entry.first] = std::move(Entry.second); |
- Kill a few lines.
lib/Tooling/Core/Replacement.cpp | ||
---|---|---|
578 ↗ | (On Diff #76881) | Always nice to save a few lines :) Thanks! |
If the files do not exist, how does this work? Won't that potentially give different results if the files exist locally vs if they don't?
We're not really handling them now though? We're just printing an error?
My point is that we might run the replacement generation on a distributed system, and then group/deduplicate/apply them somewhere where the files might not actually exist (think the reduce stage of a mapreduce). If possible, I'd like to not rely on the existence of the file when we deal with Replacements. I'd find it especially problematic if the existence or non-existence of files changes the semantics of those operations.
This function is only used in replacements application phase, and I think this is the most easiest if not the best way to ensure that two sets of replacements for the same file are applied without needing to handle dots and relative/absolute paths.
For distributed replacements generation, I think it makes more sense to duplications on the replacements application phase since this needs to be done when combining all replacements anyway.
It might make more sense to make this function local in tooling/Refactoring.cpp. But in that case, I can't unit test it :(
Ok, makes sense. Can you add a comment to the function that explains what happens with replacements for files that do not exist (we ignore them, unless I'm mistaken). Otherwise LG.
Since Manuel's comment has been addressed, I'd like to land this if there is no objection.