Changeset f47d0ad for src/SymTab
- Timestamp:
- Aug 6, 2018, 10:47:55 AM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 8316a49
- Parents:
- 4084928e
- Location:
- src/SymTab
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Demangle.cc
r4084928e rf47d0ad 509 509 return true; 510 510 } 511 512 std::string demangle(const std::string & mangleName) { 513 SymTab::Mangler::StringView view(mangleName); 514 std::string name; 515 Type * type = nullptr; 516 if (! view.parse(name, type)) return mangleName; 517 return genDemangleType(type, name); 518 } 511 519 } // namespace 512 520 } // namespace Mangler … … 514 522 515 523 extern "C" { 516 std::string cforall_demangle(const std::string & mangleName) { 517 SymTab::Mangler::StringView view(mangleName); 518 std::string name; 519 Type * type = nullptr; 520 if (! view.parse(name, type)) return mangleName; 521 return genDemangleType(type, name); 522 } // extern "C" 524 char * cforall_demangle(const char * mangleName) { 525 const std::string & demangleName = SymTab::Mangler::demangle(mangleName); 526 return strdup(demangleName.c_str()); 527 } 523 528 } 524 529 -
src/SymTab/Mangler.h
r4084928e rf47d0ad 69 69 70 70 extern "C" { 71 std::string cforall_demangle(const std::string &);71 char * cforall_demangle(const char *); 72 72 } 73 73 -
src/SymTab/demangler.cc
r4084928e rf47d0ad 5 5 6 6 void f(const std::string & mangleName) { 7 cout << mangleName << " => " << std::flush << cforall_demangle(mangleName) << endl; 7 char * demangleName = cforall_demangle(mangleName.c_str()); 8 cout << mangleName << " => " << std::flush << demangleName << endl; 9 free(demangleName); 8 10 } 9 11 10 12 int main() { 11 12 13 14 15 16 17 13 ifstream in("in-demangle.txt"); 14 std::string line; 15 while (getline(in, line)) { 16 if (line.empty()) { cout << "=================================" << endl; continue; } 17 else if (line[0] == '#') continue; 18 f(line); 19 } 18 20 }
Note: See TracChangeset
for help on using the changeset viewer.