ROSE 0.11.145.192
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.
5namespace 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
28std::string replaceNonAlphaNum (const std::string& s);
29
31std::string trimSpaces (const std::string& s);
32
33#if 0
35bool isValidMangledName (std::string name);
36#endif
37
39std::string joinMangledQualifiersToString (const std::string& base, const std::string& name);
40
42SgName joinMangledQualifiers (const SgName& base, const SgName& name);
43
45const SgFunctionDefinition* findRootFunc (const SgScopeStatement* scope);
46
47// *****************************************************************
48// New code added to support better name mangling
49// *****************************************************************
50
59size_t getLocalScopeNum (const SgFunctionDefinition* func_def, const SgScopeStatement* target);
60// size_t getLocalScopeNum ( SgFunctionDefinition* func_def, const SgScopeStatement* target);
61
63std::string mangleLocalScopeToString (const SgScopeStatement* scope);
64
70std::string mangleQualifiersToString (const SgScopeStatement* scope);
71
75SgName mangleQualifiers (const SgScopeStatement* scope);
76
84std::string mangleTypesToString (const SgTypePtrList::const_iterator b, const SgTypePtrList::const_iterator e);
85
89SgName mangleTypes (const SgTypePtrList::const_iterator b, const SgTypePtrList::const_iterator e);
90
107std::string mangleFunctionNameToString (const std::string& s, const std::string& ret_type_name = std::string (""));
108
112SgName mangleFunctionName (const SgName& n, const SgName& ret_type_name = SgName (""));
113
120std::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.
127SgName mangleTemplateArgs (const SgTemplateArgumentPtrList::const_iterator b, const SgTemplateArgumentPtrList::const_iterator e);
128#endif
129
140std::string mangleTemplateToString (const std::string& templ_name,
141 const SgTemplateArgumentPtrList& templ_args,
142 const SgScopeStatement* scope);
143
145SgName mangleTemplate (const SgName& templ_name,
146 const SgTemplateArgumentPtrList& templ_args,
147 const SgScopeStatement* scope);
148
160std::string
161mangleTemplateFunctionToString (const std::string& templ_name,
162 const SgTemplateArgumentPtrList& templ_args,
163 const SgFunctionType* func_type,
164 const SgScopeStatement* scope);
165
170SgName
171mangleTemplateFunction (const std::string& templ_name,
172 const SgTemplateArgumentPtrList& templ_args,
173 const SgFunctionType* func_type,
174 const SgScopeStatement* scope);
175
182std::string mangleTemplateArgsToString (const SgTemplateParameterPtrList::const_iterator b, const SgTemplateParameterPtrList::const_iterator e);
183
194std::string mangleTemplateToString (const std::string& templ_name,
195 const SgTemplateParameterPtrList& templ_params,
196 const SgScopeStatement* scope);
197
199SgName mangleTemplate (const SgName& templ_name,
200 const SgTemplateParameterPtrList& templ_params,
201 const SgScopeStatement* scope);
202
204std::string mangleSgValueExp (const SgBoolValExp* expr);
205
207std::string mangleValueExp (const SgValueExp* expr);
208
213std::string mangleExpression (const SgExpression* expr);
214
218std::string mangleTranslationUnitQualifiers (const SgDeclarationStatement* decl);
219
220// DQ (10/29/2017): Added support for testing for a specific cycle in the type system for template arguments.
221// It is not clear how readily this cycle detection can be easily generalized, so this is a test for a specific cycle at present.
222void testForCycleInTemplateArgumentsOfTemplateDeclaration ( const SgTemplateInstantiationDefn* templateInstantiationDefinition );
223
224
225#if 0
226// DQ (3/29/2006): I think this is only required interanlly in the mangledSupport.C file (where it is defined)
227
234template <class SgValueExpType_>
235std::string
236mangleSgValueExp (const SgValueExpType_* expr)
237 {
238 // Verify that SgValueExpType_ descends from SgValueExp.
239 ROSE_ASSERT (isSgValueExp (expr) || !expr);
240
241 ostringstream mangled_name;
242 if (expr)
243 mangled_name << expr->get_value ();
244 return mangled_name.str ();
245 }
246#endif
247
248#endif // mangling_support_INCLUDED
This class represents a boolean value (expression value).
This class represents the concept of a declaration statement.
This class represents the notion of an expression. Expressions are derived from SgLocatedNodes,...
This class represents the concept of a scope in C++ (e.g. global scope, fuction scope,...
This class represents a type for all functions.
This class represents strings within the IR nodes.
This class represents the concept of a scope in C++ (e.g. global scope, fuction scope,...
This class represents the concept of a class definition in C++.
This class represents the notion of an value (expression value).