-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CommandLine] Set the 'ValueStr' with the selected argument #90816
Conversation
Setting ValueStr allows us to query which option was selected.
@llvm/pr-subscribers-llvm-support Author: Bill Wendling (bwendling) ChangesSetting ValueStr allows us to query which option was selected. Full diff: https://github.com/llvm/llvm-project/pull/90816.diff 1 Files Affected:
diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h
index b035209406b680..8acdd5b12efaec 100644
--- a/llvm/include/llvm/Support/CommandLine.h
+++ b/llvm/include/llvm/Support/CommandLine.h
@@ -865,6 +865,7 @@ template <class DataType> class parser : public generic_parser_base {
for (size_t i = 0, e = Values.size(); i != e; ++i)
if (Values[i].Name == ArgVal) {
+ O.setValueStr(Values[i].Name);
V = Values[i].V.getValue();
return false;
}
|
Could you add a test? |
Perhaps a unittest in llvm/unittests/Support/CommandLineTest.cpp |
Sure. I'll do that soon. |
Done. (That was more work than it needed to be.) PTAL. |
Thanks for the test. However, it is still not clear to me what the motivation for the change was. Maybe similar changes should be made to the specializations of the |
I'm doing this for an upcoming change where I want to know which register allocator is used (if it's not the "greedy" allocator, we won't support the change). I know it's a bit of a hack, but it's the best we can do without a rewrite of a large part of ISel and other places. (I can add you to the PR when I create it.) As for other similar changes, it looks like all of the other fields are filled out correctly.
Maybe? To be honest, I was surprised that it wasn't available in the situation I'm working with. In the case of the |
Friendly ping. |
My understanding is that
which result in
It would not be correct to reuse the same member for another purpose. |
Crumbs! Okay, I was mistaken. I think that Python calls this |
Setting ValueStr allows us to query which option was selected.