ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
manglingSupport.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

std::string replaceNonAlphaNum (const std::string &s)
 
std::string trimSpaces (const std::string &s)
 Returns the input std::string stripped of leading and trailing spaces. More...
 
std::string joinMangledQualifiersToString (const std::string &base, const std::string &name)
 Joins two sets of mangled qualifiers to form a new mangled qualifier. More...
 
SgName joinMangledQualifiers (const SgName &base, const SgName &name)
 Joins two sets of mangled qualifiers to form a new mangled qualifier. More...
 
const SgFunctionDefinitionfindRootFunc (const SgScopeStatement *scope)
 Returns the function definition containing the specified statement. More...
 
size_t getLocalScopeNum (const SgFunctionDefinition *func_def, const SgScopeStatement *target)
 
std::string mangleLocalScopeToString (const SgScopeStatement *scope)
 Produces a mangled name for a scope statement. More...
 
std::string mangleQualifiersToString (const SgScopeStatement *scope)
 
SgName mangleQualifiers (const SgScopeStatement *scope)
 
std::string mangleTypesToString (const SgTypePtrList::const_iterator b, const SgTypePtrList::const_iterator e)
 
SgName mangleTypes (const SgTypePtrList::const_iterator b, const SgTypePtrList::const_iterator e)
 
std::string mangleFunctionNameToString (const std::string &s, const std::string &ret_type_name=std::string(""))
 
SgName mangleFunctionName (const SgName &n, const SgName &ret_type_name=SgName(""))
 
std::string mangleTemplateArgsToString (const SgTemplateArgumentPtrList::const_iterator b, const SgTemplateArgumentPtrList::const_iterator e)
 
std::string mangleTemplateToString (const std::string &templ_name, const SgTemplateArgumentPtrList &templ_args, const SgScopeStatement *scope)
 
SgName mangleTemplate (const SgName &templ_name, const SgTemplateArgumentPtrList &templ_args, const SgScopeStatement *scope)
 Mangles an instantiated template, returning an SgName object. More...
 
std::string mangleTemplateFunctionToString (const std::string &templ_name, const SgTemplateArgumentPtrList &templ_args, const SgFunctionType *func_type, const SgScopeStatement *scope)
 
SgName mangleTemplateFunction (const std::string &templ_name, const SgTemplateArgumentPtrList &templ_args, const SgFunctionType *func_type, const SgScopeStatement *scope)
 
std::string mangleSgValueExp (const SgBoolValExp *expr)
 Mangles a boolean expression. More...
 
std::string mangleValueExp (const SgValueExp *expr)
 Mangles a value expression, as used in a template argument. More...
 
std::string mangleExpression (const SgExpression *expr)
 
std::string mangleTranslationUnitQualifiers (const SgDeclarationStatement *decl)
 

Function Documentation

std::string replaceNonAlphaNum ( const std::string &  s)
std::string trimSpaces ( const std::string &  s)

Returns the input std::string stripped of leading and trailing spaces.

std::string joinMangledQualifiersToString ( const std::string &  base,
const std::string &  name 
)

Joins two sets of mangled qualifiers to form a new mangled qualifier.

SgName joinMangledQualifiers ( const SgName base,
const SgName name 
)

Joins two sets of mangled qualifiers to form a new mangled qualifier.

const SgFunctionDefinition* findRootFunc ( const SgScopeStatement scope)

Returns the function definition containing the specified statement.

size_t getLocalScopeNum ( const SgFunctionDefinition func_def,
const SgScopeStatement target 
)

Returns a unique positive integer ID to an SgScopeStatement within a function definition.

This routine computes a preorder numbering of the SgScopeStatements in the subtree rooted at 'func_def', and returns the number assigned to the 'target' scope statement, or 0 if the target could not be found in 'func_def'.

std::string mangleLocalScopeToString ( const SgScopeStatement scope)

Produces a mangled name for a scope statement.

std::string mangleQualifiersToString ( const SgScopeStatement scope)

Mangles a chain of qualifiers followed from a given scope.

This routine starts at a given scope and collects all mangled scope names going 'up' through to global scope.

SgName mangleQualifiers ( const SgScopeStatement scope)

Mangles a chain of qualifiers, returning an SgName object.

See Also
mangleQualifiersToStd::String
std::string mangleTypesToString ( const SgTypePtrList::const_iterator  b,
const SgTypePtrList::const_iterator  e 
)

Mangles a container of types, returning an STL std::string object.

Parameters
[in]bFirst element in the container to mangle.
[in]eEnd (last+1) element in the container to mangle.
Returns
An STL std::string containing all mangled names in the list, concatenated by "__sep__".
SgName mangleTypes ( const SgTypePtrList::const_iterator  b,
const SgTypePtrList::const_iterator  e 
)

Mangles a list of types, returning an SgName object.

See Also
mangleTypesToStd::String
std::string mangleFunctionNameToString ( const std::string &  s,
const std::string &  ret_type_name = std::string("") 
)

Returns a mangled form of special C++ function names (excl. qualifiers).

Adapted from SgType::mangledNameSupport. This routine considers these cases:

  • An overloaded operator, including 'new/delete' and 'new[]/delete[]'.
  • Overloaded casting operators: the caller should specify the optional return type of the function as a mangled name (see parameters).
  • A destructor (signaled by a '~' prefix).

The caller may omit the second parameter to this function, but that is not recommended.

Parameters
[in]sUnmangled function name.
[in]ret_type_nameReturn type of this function, as a mangled name.
Returns
A mangled std::string name.
SgName mangleFunctionName ( const SgName n,
const SgName ret_type_name = SgName("") 
)

Returns a mangled form of a C++ function name, as an SgName object.

See Also
mangleFunctionNameToStd::String
std::string mangleTemplateArgsToString ( const SgTemplateArgumentPtrList::const_iterator  b,
const SgTemplateArgumentPtrList::const_iterator  e 
)

Mangles a template argument container, returning an STL std::string.

Parameters
[in]bFirst element in the container to mangle.
[in]eEnd (last+1) in the container to mangle.
Returns
The specified arguments mangled and concatenated by "__sep__".
std::string mangleTemplateToString ( const std::string &  templ_name,
const SgTemplateArgumentPtrList templ_args,
const SgScopeStatement scope 
)

Mangles an instantiated template.

Parameters
[in]templ_nameUnmangled base name of the template. This std::string should not contain the template arguments (i.e., should be 'foo' and not 'foo < int >').
[in]templ_argsContainer of template arguments.
[in]scopeScope of the function (e.g., via 'get_scope ()'), used to get qualifiers.
Returns
Mangled name, including all parameter information.
SgName mangleTemplate ( const SgName templ_name,
const SgTemplateArgumentPtrList templ_args,
const SgScopeStatement scope 
)

Mangles an instantiated template, returning an SgName object.

std::string mangleTemplateFunctionToString ( const std::string &  templ_name,
const SgTemplateArgumentPtrList templ_args,
const SgFunctionType func_type,
const SgScopeStatement scope 
)

Mangles an instantiated template function or template member function.

Parameters
[in]templ_nameUnmangled base name of the function. This std::string should not contain the template arguments (i.e., should be 'foo' and not 'foo < int >').
[in]templ_argsContainer of template arguments.
[in]func_typeThe function's type (e.g., via 'get_type ()')
[in]scopeScope of the function (e.g., via 'get_scope ()'), used to get qualifiers.
Returns
Mangled name, including all parameter information.
SgName mangleTemplateFunction ( const std::string &  templ_name,
const SgTemplateArgumentPtrList templ_args,
const SgFunctionType func_type,
const SgScopeStatement scope 
)

Mangles an instantiated template function or member function, returning a SgName object.

See Also
mangleTemplateFunctionToStd::String
std::string mangleSgValueExp ( const SgBoolValExp expr)

Mangles a boolean expression.

std::string mangleValueExp ( const SgValueExp expr)

Mangles a value expression, as used in a template argument.

std::string mangleExpression ( const SgExpression expr)

Mangles a constant expression, needed for template arguments.

Todo:
Find a better way to deal with general template expression arguments.
std::string mangleTranslationUnitQualifiers ( const SgDeclarationStatement decl)

If the declaration has translation unit scope (as opposed to program scope), mangle the translation unit name.