Use unique_ptr operator= instead of constructor to make it explicit that there's no conversion occurring.
Remove an unnecessary reference variable that pointed to a unique_ptr variable. Just use the unique_ptr variable directly.
Remove unnecessary calls to unique_ptr::get.
Use range-based for loop.
Use make_unique instead of reset() and 'new'
Use unique_ptr to remove an explicit delete. Change return type to pass the unique_ptr to caller.
Pass output stream to AsLexInput instead of the whole tool_output_file.