RFC: FileEdit utility

I’ve put up D34764 for review. I’ll paste the review summary message below for the purposes of having this message be self-contained. Comments welcome, either here or on the review thread.

There were some back and forth comments on the review. To summarize, I’m strongly in favor of having a tool in-tree that splits files on some delimiter inside a comment. Chandler is strongly opposed to having test files that aren’t completely valid standalone files as part of the test suite. For example, a smart editor or IDE would put red squigglies on this code because it’s ill-formed as is:

// RUN: FileEdit %s --res_dir %t
// RUN: clang %t/a.cpp %t/b.cpp -o %t.exe
// FILESPLIT: a.cpp
static int x = 1;
int main() {}
// FILESPLIT: b.cpp

static int x = 2; // error about redefining x

You’d get the same kind of issues with macro redefinitions. I don’t see this as a big problem, and I’d rather keep the test case in one file over using separate files in %S/Inputs. His proposed alternative is to use in-language mechanisms when possible. This would mean using the C preprocessor for C, .if directives for assembler, and llvm-extract for LTO test cases in IR.

Hopefully I haven’t misrepresented Chandler’s perspective on this.

Unless someone else comes forward and says they hate having to add small files to %S/Inputs and they really want a text file splitting utility, I think we’re going to drop this for now. I’m happy enough to hack together lld test cases with .if.