[Lldb-commits] [PATCH] D78462: get rid of PythonInteger::GetInteger()
Pavel Labath via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Apr 20 02:06:48 PDT 2020
labath added inline comments.
================
Comment at: lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp:55
+ return obj.takeError();
+ return obj.get().AsUnsignedLongLong();
+}
----------------
`obj->AsUnsignedLongLong()` ?
================
Comment at: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp:3153-3159
+ long long py_return = unwrapOrSetPythonException(
+ As<long long>(implementor.CallMethod(callee_name)));
// if it fails, print the error but otherwise go on
if (PyErr_Occurred()) {
PyErr_Print();
PyErr_Clear();
----------------
This converts the Expected into a python exception, only to clear (and print) it at the next line. Is there a more direct way of doing it?
================
Comment at: lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp:126-132
+ auto major_version_value = As<long long>(major_version_field);
+ auto minor_version_value = As<long long>(minor_version_field);
- EXPECT_EQ(PY_MAJOR_VERSION, major_version_value.GetInteger());
- EXPECT_EQ(PY_MINOR_VERSION, minor_version_value.GetInteger());
+ EXPECT_THAT_EXPECTED(major_version_value, llvm::Succeeded());
+ EXPECT_THAT_EXPECTED(minor_version_value, llvm::Succeeded());
+ EXPECT_EQ(PY_MAJOR_VERSION, major_version_value.get());
+ EXPECT_EQ(PY_MINOR_VERSION, minor_version_value.get());
----------------
`EXPECT_THAT_EXPECTED(As<long long>(major_version_field), llvm::HasValue(PY_MAJOR_VERSION))` (and similarly in other tests too)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D78462/new/
https://reviews.llvm.org/D78462
More information about the lldb-commits
mailing list