summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/CPPLanguageRuntime.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Target/CPPLanguageRuntime.cpp')
-rw-r--r--lldb/source/Target/CPPLanguageRuntime.cpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/lldb/source/Target/CPPLanguageRuntime.cpp b/lldb/source/Target/CPPLanguageRuntime.cpp
index d80ed210440..22fbd8479b5 100644
--- a/lldb/source/Target/CPPLanguageRuntime.cpp
+++ b/lldb/source/Target/CPPLanguageRuntime.cpp
@@ -40,3 +40,81 @@ CPPLanguageRuntime::GetObjectDescription (Stream &str, Value &value, ExecutionCo
// C++ has no generic way to do this.
return false;
}
+
+bool
+CPPLanguageRuntime::IsCPPMangledName (const char *name)
+{
+ // FIXME, we should really run through all the known C++ Language plugins and ask each one if
+ // this is a C++ mangled name, but we can put that off till there is actually more than one
+ // we care about.
+
+ if (name && name[0] == '_' && name[1] == 'Z')
+ return true;
+ else
+ return false;
+}
+
+bool
+CPPLanguageRuntime::StripNamespacesFromVariableName (const char *name, const char *&base_name_start, const char *&base_name_end)
+{
+ if (base_name_end == NULL)
+ base_name_end = name + strlen (name);
+
+ const char *last_colon = NULL;
+ for (const char *ptr = base_name_end; ptr != name; ptr--)
+ {
+ if (*ptr == ':')
+ {
+ last_colon = ptr;
+ break;
+ }
+ }
+
+ if (last_colon == NULL)
+ {
+ base_name_start = name;
+ return true;
+ }
+
+ // Can't have a C++ name that begins with a single ':', nor contains an internal single ':'
+ if (last_colon == name)
+ return false;
+ else if (last_colon[-1] != ':')
+ return false;
+ else
+ {
+ // FIXME: should check if there is
+ base_name_start = last_colon + 1;
+ return true;
+ }
+}
+bool
+CPPLanguageRuntime::IsPossibleCPPCall (const char *name, const char *&base_name_start, const char *&base_name_end)
+{
+ if (!name)
+ return false;
+ // For now, I really can't handle taking template names apart, so if you
+ // have < or > I'll say "could be CPP but leave the base_name empty which
+ // means I couldn't figure out what to use for that.
+ // FIXME: Do I need to do more sanity checking here?
+
+ if (strchr(name, '>') != NULL || strchr (name, '>') != NULL)
+ return true;
+
+ size_t name_len = strlen (name);
+
+ if (name[name_len - 1] == ')')
+ {
+ // We've got arguments.
+ base_name_end = strchr (name, '(');
+ if (base_name_end == NULL)
+ return false;
+
+ // FIXME: should check that this parenthesis isn't a template specialized
+ // on a function type or something gross like that...
+ }
+ else
+ base_name_end = name + strlen (name);
+
+ return StripNamespacesFromVariableName (name, base_name_start, base_name_end);
+}
OpenPOWER on IntegriCloud