@@ -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
@@ -2917,6 +2920,18 @@ void mlir::python::populateIRCore(nb::module_ &m) {
29172920 nb::arg (" filename" ), nb::arg (" line" ), nb::arg (" col" ),
29182921 nb::arg (" context" ).none () = nb::none (),
29192922 kContextGetFileLocationDocstring )
2923+ .def_static (
2924+ " file" ,
2925+ [](std::string filename, int startLine, int startCol, int endLine,
2926+ int endCol, DefaultingPyMlirContext context) {
2927+ return PyLocation (context->getRef (),
2928+ mlirLocationFileLineColRangeGet (
2929+ context->get (), toMlirStringRef (filename),
2930+ startLine, startCol, endLine, endCol));
2931+ },
2932+ nb::arg (" filename" ), nb::arg (" start_line" ), nb::arg (" start_col" ),
2933+ nb::arg (" end_line" ), nb::arg (" end_col" ),
2934+ nb::arg (" context" ).none () = nb::none (), kContextGetFileRangeDocstring )
29202935 .def_static (
29212936 " fused" ,
29222937 [](const std::vector<PyLocation> &pyLocations,
0 commit comments