Imported Upstream version 58.1
[platform/upstream/icu.git] / as_is / os400 / cxxfilt.cpp
1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /* Copyright (C) 2012 IBM Corporation and Others. All Rights Reserved */
4
5 #include <stdio.h>
6 #include <demangle.h>
7
8 void showSym(char *str) {
9   char *rest;
10   struct Name *name = Demangle(str, rest); // "f__1XFi"
11
12   printf("# '%s'\n", str);
13   if(*rest) printf("\trest: '%s'\n", rest);
14   if(name->Kind() == MemberFunction) {
15     //((MemberFunctionName *) name)->Scope()->Text() is "X"
16     //((MemberFunctionName *) name)->RootName() is "f"
17     //((MemberFunctionName *) name)->Text() is "X::f(int)"
18     printf("\t=> %s\n", ((MemberFunctionName *) name)->Text());
19   } else {
20     printf("\t(not MemberFunction)\n");
21   }
22 }
23
24
25
26
27
28 int main(int argc, /*const*/ char *argv[]) {
29   if(argc>1) {
30     for(int i=1;i<argc;i++) {
31        showSym(argv[i]);
32     }
33   } else {
34     printf("Usage: %s <symbol> ...\n", argv[0]);
35   }
36
37
38
39 }