[PATCH] D44236: [llvm-objcopy] Switch over to using TableGen for parsing arguments
Alexander Shaposhnikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 4 23:34:43 PDT 2018
alexshap added a comment.
so maybe the following approach can also be considered: (deliberately presented in the reverse order to see how different pieces would fit together):
int main(int argc, char **argv) {
StringRef ToolName = path::filename(argv[0]);
Config Conf;
if (ToolName) == "objcopy")
Conf = parseObjcopyArgs(argc, argv);
else if (ToolName = "strip")
Conf = parseStripArgs(argc, argv);
ExecuteObjcopy(Conf);
return 0;
}
void ExecuteObjcopy(const Config &Conf) {
auto Reader = createReader(Conf.InputName);
if (Reader.isELF())
return ExecuteElfObjcopy(Conf, Reader);
if (Reader.isCoff())
return ExecuteCoffObjcopy(Conf, Reader);
}
void ExecuteElfObjcopy(const Config &C, Reader &R) {
Object O; // intermediate representation which we discussed with Jake and James
O.read(R);
/* modify the object according to the config, similarly to the existing handleArgs */
.....
.....
.....
auto W = createWriter(R.elftype(), C.OutputFormat, C.OutputFilename);
O.write(W);
}
}
(seems to be a bit simpler, less inheritance, all the classes are "stateful")
Repository:
rL LLVM
https://reviews.llvm.org/D44236
More information about the llvm-commits
mailing list