Example #1
0
json_objectt json(const source_locationt &location)
{
  json_objectt result;
  
  if(!location.get_file().empty())
    result["file"]=json_stringt(id2string(location.get_file()));

  if(!location.get_line().empty())
    result["line"]=json_stringt(id2string(location.get_line()));

  if(!location.get_column().empty())
    result["column"]=json_stringt(id2string(location.get_column()));

  if(!location.get_function().empty())
    result["function"]=json_stringt(id2string(location.get_function()));
  
  return result;
}
Example #2
0
xmlt xml(const source_locationt &location)
{
  xmlt result;

  result.name="location";
  
  if(!location.get_file().empty())
    result.set_attribute("file", id2string(location.get_file()));

  if(!location.get_line().empty())
    result.set_attribute("line", id2string(location.get_line()));

  if(!location.get_column().empty())
    result.set_attribute("column", id2string(location.get_column()));

  if(!location.get_function().empty())
    result.set_attribute("function", id2string(location.get_function()));
  
  return result;
}
Example #3
0
void gcc_message_handlert::print(
  unsigned level,
  const std::string &message,
  int sequence_number,
  const source_locationt &location)
{
  const irep_idt file=location.get_file();
  const irep_idt line=location.get_line();
  const irep_idt column=location.get_column();
  const irep_idt function=location.get_function();

  std::string dest;

  if(!function.empty())
  {
    if(!file.empty())
      dest+=id2string(file)+":";
    if(dest!="")
      dest+=' ';
    dest+="In function '"+id2string(function)+"':\n";
  }

  if(!line.empty())
  {
    if(!file.empty())
      dest+=id2string(file)+":";

    dest+=id2string(line)+":";

    if(column.empty())
      dest+="1: ";
    else
      dest+=id2string(column)+": ";

    if(level==message_clientt::M_ERROR)
      dest+="error: ";
    else if(level==message_clientt::M_WARNING)
      dest+="warning: ";
  }

  dest+=message;

  print(level, dest);
}