Sending this out a bit half-baked unfortunately - we added support for
this context a couple of years ago in D102122 (which turned up in clang 15
onwards: https://godbolt.org/z/haz8qrTT3 ), not sure if the macro detection
will correctly detect that the attribute is usable in a typedef context...
Details
- Reviewers
lhames aaron.ballman deadalnix
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Time | Test | |
---|---|---|
60,060 ms | x64 debian > MLIR.Examples/standalone::test.toy |
Event Timeline
llvm/examples/OrcV2Examples/OrcV2CBindingsLazy/OrcV2CBindingsLazy.c | ||
---|---|---|
198 | Keep in mind, I know nothing about Orc. :-D It seems that the only in-tree uses of this API that check results are the unit tests. Perhaps this function's return type is inappropriate? Or does this suggest we should be marking individual APIs instead of the return type itself? | |
llvm/include/llvm-c/ExternC.h | ||
47–51 | Hmm, worth it to add __has_c_attribute(nodiscard) as a branch, or given C2x's newness, not worth it? |
llvm/include/llvm-c/ExternC.h | ||
---|---|---|
47–51 | Does C2x support the attribute on typedefs? (the C++ committee wasn't so enthusiastic about that change & I don't follow the C committee directly) I'm happy enough to include C support, if it applies. |
llvm/include/llvm-c/ExternC.h | ||
---|---|---|
47–51 | Ah good point, it's not allowed on typedefs there either. Neeeevermind. :-) |
llvm/include/llvm-c/ExternC.h | ||
---|---|---|
47–51 | could rename the macro WARN_UNUSED_RESULT rather than NODISCARD_GNU_STYLE? |
llvm/include/llvm-c/ExternC.h | ||
---|---|---|
47–51 | Hmmm, either seems about equally as confusing. What about LLVM_NODISCARD_TYPEDEF to make it clear that this should be used for typedefs and leave it to another macro to handle non-discardable function markings? |
llvm/include/llvm-c/ExternC.h | ||
---|---|---|
47–51 | I guess, sure. I guess this also needs a more narrow macro check to verify the clang version (since it seems we support back to clang 5, and this only works on clang 15 and above) - I can't seem to find an example of a macro check for clang version in any of our Compiler.h and similar macro-y/compat headers in LLVM - do you happen to know of an example off-hand? |
Adding warn-unused attribute(s) either to LLVMErrorRef (if possible) or to the individual APIs seems like a great idea to me. No opinion on the mechanics -- I don't know anything about the relevant C attributes.
llvm/examples/OrcV2Examples/OrcV2CBindingsLazy/OrcV2CBindingsLazy.c | ||
---|---|---|
198 | The return type is appropriate, I've just been lazy about checking it -- adding warn-unused seems like a big win for that reason. :) Rather than casting to void I should add an LLVMCantFail macro that asserts that the result is LLVMErrorSuccess. |
Keep in mind, I know nothing about Orc. :-D
It seems that the only in-tree uses of this API that check results are the unit tests. Perhaps this function's return type is inappropriate? Or does this suggest we should be marking individual APIs instead of the return type itself?