-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[LLVM-C] Add binding to BitcodeReader::getBitcodeProducerString
#166063
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
base: main
Are you sure you want to change the base?
Conversation
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
fb0a289 to
3c09040
Compare
llvm/tools/llvm-c-test/module.c
Outdated
| return 1; | ||
| } | ||
|
|
||
| if (Producer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it not an error for Producer to be NULL here (and for Err to be non-NULL)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I extended the predicate in the if statement above to Ret || Err and handled the lack of Producer as an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is what I meant. I was thinking we'd want the test to be as strict as possible - to me that means no || anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, how does it look for you now?
ca7f55e to
fdebb42
Compare
Add `LLVMGetBircodeProducerString` function in LLVM C API that binds to `BitcodeReader::getBitcodeProducerString` in LLVM C++ API.
fdebb42 to
e91bd0f
Compare
| if (Producer) | ||
| fprintf(stderr, | ||
| "LLVMGetBitcodeProducerString returned %d, but Producer is not " | ||
| "NULL: %s", | ||
| Res, Producer); | ||
| if (Err) | ||
| fprintf(stderr, "LLVMGetBitcodeProducerSring returned %d, error: %s\n", | ||
| Res, Err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just be outside the if (Res), right? you always want to print these if they are non-null. Then you can immediately dispose them, and then you can:
int Ret = 0;
if (Res) {
fprintf(stderr, "LLVMGetBitcodeProducerString(...) returned %d", Res);
Ret = 1;
}
if (!Producer) {
fprintf(...)
Ret = 1;
}
if (Err) {
...
}
return Ret;
by the way, do we need a negative test, for the error case? It is not currently exercised.
Add
LLVMGetBircodeProducerStringfunction in LLVM C API that binds toBitcodeReader::getBitcodeProducerStringin LLVM C++ API.