@@ -50,6 +50,9 @@ static const char kContextGetCallSiteLocationDocstring[] =
5050static const char kContextGetFileLocationDocstring [] =
5151 R"( Gets a Location representing a file, line and column)" ;
5252
53+ static const char kContextGetFileRangeDocstring [] =
54+ R"( Gets a Location representing a file, line and column range)" ;
55+
5356static const char kContextGetFusedLocationDocstring [] =
5457 R"( Gets a Location representing a fused location with optional metadata)" ;
5558
@@ -2902,6 +2905,18 @@ void mlir::python::populateIRCore(nb::module_ &m) {
29022905 nb::arg (" filename" ), nb::arg (" line" ), nb::arg (" col" ),
29032906 nb::arg (" context" ).none () = nb::none (),
29042907 kContextGetFileLocationDocstring )
2908+ .def_static (
2909+ " file" ,
2910+ [](std::string filename, int startLine, int startCol, int endLine,
2911+ int endCol, DefaultingPyMlirContext context) {
2912+ return PyLocation (context->getRef (),
2913+ mlirLocationFileLineColRangeGet (
2914+ context->get (), toMlirStringRef (filename),
2915+ startLine, startCol, endLine, endCol));
2916+ },
2917+ nb::arg (" filename" ), nb::arg (" start_line" ), nb::arg (" start_col" ),
2918+ nb::arg (" end_line" ), nb::arg (" end_col" ),
2919+ nb::arg (" context" ).none () = nb::none (), kContextGetFileRangeDocstring )
29052920 .def_static (
29062921 " fused" ,
29072922 [](const std::vector<PyLocation> &pyLocations,
0 commit comments