ROSE  0.9.9.139
manglingSupport.h
1 #ifndef mangling_support_INCLUDED
2 #define mangling_support_INCLUDED
3 
4 // DQ (10/31/2015): Adding new namespace to organize mangled name handling.
5 namespace MangledNameSupport
6  {
7  // Although the purpose of this namespace is to eventually have most or all of
8  // the mangled name support function below (not in this namespace) be put into
9  // this namespace, at present it is used to organize data structures required
10  // to support handling of recursive template instantiations that are recognized
11  // as a problem for some rare case of C++ template support (test2015_105.C
12  // is so far the smallest example of this issue). There are many examples
13  // of recursive templates, but all except for test2015_105.C appear to terminate
14  // nicely and are not a problem for the mangled name support.
15 
16 
17  // We need to keep a set of visit template declarations so that in the processing
18  // of mangled names for each template instnatiation we can detect the use recursion
19  // that would represent a cycle in the type system represented by the instantiated
20  // template.
21  typedef std::set<SgClassDefinition*> setType;
22 
23  extern setType visitedTemplateDefinitions;
24 
25  void outputVisitedTemplateDefinitions();
26  }
27 
28 std::string replaceNonAlphaNum (const std::string& s);
29 
31 std::string trimSpaces (const std::string& s);
32 
33 #if 0
34 bool isValidMangledName (std::string name);
36 #endif
37 
39 std::string joinMangledQualifiersToString (const std::string& base, const std::string& name);
40 
42 SgName joinMangledQualifiers (const SgName& base, const SgName& name);
43 
45 const SgFunctionDefinition* findRootFunc (const SgScopeStatement* scope);
46 
47 // *****************************************************************
48 // New code added to support better name mangling
49 // *****************************************************************
50 
59 size_t getLocalScopeNum (const SgFunctionDefinition* func_def, const SgScopeStatement* target);
60 // size_t getLocalScopeNum ( SgFunctionDefinition* func_def, const SgScopeStatement* target);
61 
63 std::string mangleLocalScopeToString (const SgScopeStatement* scope);
64 
70 std::string mangleQualifiersToString (const SgScopeStatement* scope);
71 
75 SgName mangleQualifiers (const SgScopeStatement* scope);
76 
84 std::string mangleTypesToString (const SgTypePtrList::const_iterator b, const SgTypePtrList::const_iterator e);
85 
89 SgName mangleTypes (const SgTypePtrList::const_iterator b, const SgTypePtrList::const_iterator e);
90 
107 std::string mangleFunctionNameToString (const std::string& s, const std::string& ret_type_name = std::string (""));
108 
112 SgName mangleFunctionName (const SgName& n, const SgName& ret_type_name = SgName (""));
113 
120 std::string mangleTemplateArgsToString (const SgTemplateArgumentPtrList::const_iterator b, const SgTemplateArgumentPtrList::const_iterator e);
121 
122 #if 0
123 // DQ (2/7/2006): This function is not used or required.
127 SgName mangleTemplateArgs (const SgTemplateArgumentPtrList::const_iterator b, const SgTemplateArgumentPtrList::const_iterator e);
128 #endif
129 
140 std::string mangleTemplateToString (const std::string& templ_name,
141  const SgTemplateArgumentPtrList& templ_args,
142  const SgScopeStatement* scope);
143 
145 SgName mangleTemplate (const SgName& templ_name,
146  const SgTemplateArgumentPtrList& templ_args,
147  const SgScopeStatement* scope);
148 
160 std::string
161 mangleTemplateFunctionToString (const std::string& templ_name,
162  const SgTemplateArgumentPtrList& templ_args,
163  const SgFunctionType* func_type,
164  const SgScopeStatement* scope);
165 
170 SgName
171 mangleTemplateFunction (const std::string& templ_name,
172  const SgTemplateArgumentPtrList& templ_args,
173  const SgFunctionType* func_type,
174  const SgScopeStatement* scope);
175 
177 std::string mangleSgValueExp (const SgBoolValExp* expr);
178 
180 std::string mangleValueExp (const SgValueExp* expr);
181 
186 std::string mangleExpression (const SgExpression* expr);
187 
191 std::string mangleTranslationUnitQualifiers (const SgDeclarationStatement* decl);
192 
193 // DQ (10/29/2017): Added support for testing for a specific cycle in the type system for template arguments.
194 // It is not clear how readily this cycle detection can be easily generalized, so this is a test for a specific cycle at present.
195 void testForCycleInTemplateArgumentsOfTemplateDeclaration ( const SgTemplateInstantiationDefn* templateInstantiationDefinition );
196 
197 
198 #if 0
199 // DQ (3/29/2006): I think this is only required interanlly in the mangledSupport.C file (where it is defined)
200 
207 template <class SgValueExpType_>
208 std::string
209 mangleSgValueExp (const SgValueExpType_* expr)
210  {
211  // Verify that SgValueExpType_ descends from SgValueExp.
212  ROSE_ASSERT (isSgValueExp (expr) || !expr);
213 
214  ostringstream mangled_name;
215  if (expr)
216  mangled_name << expr->get_value ();
217  return mangled_name.str ();
218  }
219 #endif
220 
221 #endif // mangling_support_INCLUDED
This class represents the concept of a scope in C++ (e.g. global scope, fuction scope, etc.).
This class represents a boolean value (expression value).
This class represents the concept of a scope in C++ (e.g. global scope, fuction scope, etc.).
This class represents the notion of an expression. Expressions are derived from SgLocatedNodes, since similar to statement, expressions have a concrete location within the user's source code.
This class represents strings within the IR nodes.
This class represents the notion of an value (expression value).
This class represents a type for all functions.
This class represents the concept of a class definition in C++.
This class represents the concept of a declaration statement.