Need to fix our internal code analysis reports
Lots of problems are like
auto node = dynamic_cast<luci::CircleNode *>(nodes->at(n));
assert(node != nullptr);
if (node->dosomething())
{
where node can be nullptr
We can introduce template method loco::cast<luci::CircleNode *>(nodes->at(n)); that throws when result is nullptr
CC @parjong
Just for suggestion. How about must<T> instead of cast<T> ;-)
This example code shows how to rewrite the above code ;-)
auto node = must<luci::CircleNode>(nodes.at(n));
if (node ->dosomething())
{
...
}
If node can be nullptr, I usually prefer to the following pattern:
if (auto node = dynamic_cast...)
{
node->doSomething()
}
I think this can be close.