Program Listing for File manglingSupport.h

Program Listing for File manglingSupport.h#

Return to documentation for file (src/frontend/SageIII/manglingSupport.h)

#ifndef mangling_support_INCLUDED
#define mangling_support_INCLUDED

// DQ (10/31/2015): Adding new namespace to organize mangled name handling.
namespace MangledNameSupport
   {
  // Although the purpose of this namespace is to eventually have most or all of
  // the mangled name support function below (not in this namespace) be put into
  // this namespace, at present it is used to organize data structures required
  // to support handling of recursive template instantiations that are recognized
  // as a problem for some rare case of C++ template support (test2015_105.C
  // is so far the smallest example of this issue).  There are many examples
  // of recursive templates, but all except for test2015_105.C appear to terminate
  // nicely and are not a problem for the mangled name support.


  // We need to keep a set of visit template declarations so that in the processing
  // of mangled names for each template instnatiation we can detect the use recursion
  // that would represent a cycle in the type system represented by the instantiated
  // template.
     typedef std::set<SgClassDefinition*> setType;

     extern setType visitedTemplateDefinitions;

     void outputVisitedTemplateDefinitions();
   }

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

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

#if 0
bool isValidMangledName (std::string name);
#endif

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

SgName joinMangledQualifiers (const SgName& base, const SgName& name);

const SgFunctionDefinition* findRootFunc (const SgScopeStatement* scope);

// *****************************************************************
//         New code added to support better name mangling
// *****************************************************************

size_t getLocalScopeNum (const SgFunctionDefinition* func_def, const SgScopeStatement* target);
// size_t getLocalScopeNum ( SgFunctionDefinition* func_def, const SgScopeStatement* target);

std::string mangleLocalScopeToString (const SgScopeStatement* scope);

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);

#if 0
// DQ (2/7/2006): This function is not used or required.
SgName mangleTemplateArgs (const SgTemplateArgumentPtrList::const_iterator b, const SgTemplateArgumentPtrList::const_iterator e);
#endif

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);

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 mangleTemplateArgsToString (const SgTemplateParameterPtrList::const_iterator b, const SgTemplateParameterPtrList::const_iterator e);

std::string mangleTemplateToString (const std::string& templ_name,
                               const SgTemplateParameterPtrList& templ_params,
                               const SgScopeStatement* scope);

SgName mangleTemplate (const SgName& templ_name,
                       const SgTemplateParameterPtrList& templ_params,
                       const SgScopeStatement* scope);

std::string mangleSgValueExp (const SgBoolValExp* expr);

std::string mangleValueExp (const SgValueExp* expr);

std::string mangleExpression (const SgExpression* expr);

std::string mangleTranslationUnitQualifiers (const SgDeclarationStatement* decl);

// DQ (10/29/2017): Added support for testing for a specific cycle in the type system for template arguments.
// It is not clear how readily this cycle detection can be easily generalized, so this is a test for a specific cycle at present.
void testForCycleInTemplateArgumentsOfTemplateDeclaration ( const SgTemplateInstantiationDefn* templateInstantiationDefinition );


#if 0
// DQ (3/29/2006): I think this is only required interanlly in the mangledSupport.C file (where it is defined)

template <class SgValueExpType_>
std::string
mangleSgValueExp (const SgValueExpType_* expr)
  {
    // Verify that SgValueExpType_ descends from SgValueExp.
    ROSE_ASSERT (isSgValueExp (expr) || !expr);

    ostringstream mangled_name;
    if (expr)
      mangled_name << expr->get_value ();
    return mangled_name.str ();
  }
#endif

#endif // mangling_support_INCLUDED