This patch fixes ScriptedProcessPythonInterface::GetGenericInteger to
avoid compiler warning emitted due to size_t being 32 bit when built
on 32 bit paltform.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Hello @omjavaid, apologies for only looking at this now but I was on vacation last week. This changes make sense but I'd rather conform to the Python interface types. Also, I'm still working on Scripted Processes and I'm planning to land a patch with these changes soon. Thanks for letting me know about this oversight.
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp | ||
---|---|---|
187–188 | I'd use to unsigned long long to match the interface. |
Some nits but otherwise this seems like the right direction. Thanks!
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp | ||
---|---|---|
66–72 | Unrelated to the change here, but that looks like a typo in the string. | |
143 | Could we return an llvm::Optional<...> here? Then we don't need the invalid_address variable but instead just return llvm::None in the early exits. | |
298–303 | I think this should return false when the underlying object is invalid? Bit out of scope for this patch, so feel free to fix this in another review. | |
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h | ||
54 | Could you actually make a typedef for this? typedef unsigned long long PythonInteger or so. cpython really like to change their API between versions and this would make the potential fixups a bit easier if they decide to change the return value. We might actually want to put this typedef into the PythonObject API int the future, but that's probably out-of-scope for this patch. |
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp | ||
---|---|---|
66–72 | Thanks for catching that! | |
298–303 | This is just the interface between Python and C++, the object sanity check is done above in ScriptedProcess::IsAlive. | |
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h | ||
54 | There is actually a PythonInteger class already but in order to extract the scalar, I have to make a proxy StructuredData::Integer to get the uint64_t value. Notice, in this case, the return type is not unsigned long long anymore ... |
I think this is the last round of review so I'll just accept this modulo a few nits.
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp | ||
---|---|---|
190 | As discussed offline, I think with the API we got here I would much rather have the unhandled llvm::Expected from the old code than the strange StructuredData code that just silently hides errors. Let's revert this back to the old but with llvm::None and put a big FIXME there. llvm::Expected<unsigned long long> size = py_return.AsUnsignedLongLong(); if (!size) { // FIXME: Handle error. return llvm::None; } return *size; | |
293–294 | Could you spell the auto out here? llvm::Optional<uint64_t> is I think simple enough. | |
298–303 | Same as above. |
Could you actually make a typedef for this? typedef unsigned long long PythonInteger or so. cpython really like to change their API between versions and this would make the potential fixups a bit easier if they decide to change the return value.
We might actually want to put this typedef into the PythonObject API int the future, but that's probably out-of-scope for this patch.