Skip to content

[clang-tidy] modernize-return-braced-init-list and complex type casts #148942

@EugeneZelenko

Description

@EugeneZelenko

I got modernize-return-braced-init-list warning for next code:

#include <boost/python/extract.hpp>
#include <boost/python/object.hpp>

std::string test(const boost::python::object& data_set, const char* attr)
{
    const boost::python::object attribute_object = data_set.attr(attr);
    if (attribute_object.is_none())
    {
        return {};
    }
    else
    {
        return boost::python::extract<std::string>(attribute_object);
    }
}
warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]
      return boost::python::extract<std::string>(attribute_object);

I tried 19.1 and ~ month-old main. Boost version is 1.86. Sorry, was not able to reproduce in on GodBolt, because it's not obvious how to specify path to local Boost libraries.

I think will be good idea to have option to filter out such complex type casts in modernize-return-braced-init-list.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions