GCC Middle and Back End API Reference
env_manager Struct Reference
Collaboration diagram for env_manager:

Data Structures

struct  kv
 

Public Member Functions

void init (bool can_restore, bool debug)
 
const char * get (const char *name)
 
void xput (const char *string)
 
void restore ()
 

Private Attributes

bool m_can_restore
 
bool m_debug
 
vec< kvm_keys
 

Detailed Description

Manage the manipulation of env vars.

We poison "getenv" and "putenv", so that all enviroment-handling is
done through this class.  Note that poisoning happens in the
preprocessor at the identifier level, and doesn't distinguish between
  env.getenv ();
and
  getenv ();
Hence we need to use "get" for the accessor method, not "getenv".   

Member Function Documentation

◆ get()

const char * env_manager::get ( const char * name)
Get the value of NAME within the environment.  Essentially
a wrapper for ::getenv, but adding logging, and the possibility
of caching results.   

References m_debug.

Referenced by getenv_spec_function(), and process_command().

◆ init()

void env_manager::init ( bool can_restore,
bool debug )
Initializer for class env_manager.

We can't do this as a constructor since we have a statically
allocated instance ("env" above).   

References debug, m_can_restore, and m_debug.

Referenced by driver::driver().

◆ restore()

void env_manager::restore ( )
Undo any xputenv changes made since last restore.
Can only be called if the env_manager was initialized with
CAN_RESTORE enabled.   

References FOR_EACH_VEC_ELT_REVERSE, free(), gcc_assert, i, m_can_restore, m_debug, env_manager::kv::m_key, m_keys, and env_manager::kv::m_value.

Referenced by driver::finalize().

◆ xput()

void env_manager::xput ( const char * string)
Put the given KEY=VALUE entry STRING into the environment.
If the env_manager was initialized with CAN_RESTORE set, then
also record the old value of KEY within the environment, so that it
can be later restored.   

References CONST_CAST, fnotice(), gcc_assert, m_can_restore, m_debug, env_manager::kv::m_key, m_keys, env_manager::kv::m_value, and NULL.

Referenced by xputenv().

Field Documentation

◆ m_can_restore

bool env_manager::m_can_restore
private

Referenced by init(), restore(), and xput().

◆ m_debug

bool env_manager::m_debug
private

Referenced by get(), init(), restore(), and xput().

◆ m_keys

vec<kv> env_manager::m_keys
private

Referenced by restore(), and xput().


The documentation for this struct was generated from the following file: