C++ (Cpp) var_infot Example

Introduction

The c++ (cpp) var_infot example is extracted from the most popular open source projects, you can refer to the following example for usage.

Programming language: C++ (Cpp)

Class/type: var_infot

Example#1
File: var_map.cppProject: lihaol/cbmc

void var_mapt::init(var_infot &var_info)
{
  if(has_prefix(id2string(var_info.symbol), "symex_dynamic::"))
  {
    var_info.kind=var_infot::SHARED;
  }
  else
  {
    // Check for the presence of va_args
    std::size_t found=id2string(var_info.symbol).find("::va_arg");
    if(found != std::string::npos)
    {
      var_info.kind=var_infot::PROCEDURE_LOCAL;
    }
    else
    {
      const symbolt *symbol=0;
      if(ns.lookup(var_info.symbol, symbol))
        throw "var_mapt::init identifier \""
          +id2string(var_info.full_identifier)
          +"\" lookup in ns failed";

      if(symbol->is_static_lifetime)
      {
        if(symbol->is_thread_local)
          var_info.kind=var_infot::THREAD_LOCAL;
        else
          var_info.kind=var_infot::SHARED;
      }
      else
        var_info.kind=var_infot::PROCEDURE_LOCAL;
    }
  }

  if(var_info.is_shared())
    var_info.number=shared_count++;
  else
    var_info.number=local_count++;
}

Example#2
File: var_map.cppProject: diffblue/cbmc

void var_mapt::init(var_infot &var_info)
{
  if(has_prefix(id2string(var_info.symbol), "symex_dynamic::"))
  {
    var_info.kind=var_infot::SHARED;
  }
  else
  {
    try
    {
      const symbolt &symbol=ns.lookup(var_info.symbol);

      if(symbol.is_static_lifetime)
      {
        if(symbol.is_thread_local)
          var_info.kind=var_infot::THREAD_LOCAL;
        else
          var_info.kind=var_infot::SHARED;
      }
      else
        var_info.kind=var_infot::PROCEDURE_LOCAL;
    }

    catch(std::string s)
    {
      throw "var_mapt::init identifier \"" +
            id2string(var_info.full_identifier)+
            "\" lookup in ns failed";
    }
  }

  if(var_info.is_shared())
    var_info.number=shared_count++;
  else
    var_info.number=local_count++;
}