[Lldb-commits] [PATCH] Fix handling of CommandInterpreter's events in lldb-mi
Greg Clayton
clayborg at gmail.com
Fri Mar 20 10:15:22 PDT 2015
No need to strcmp, see my inlined comments.
================
Comment at: source/API/SBCommandInterpreter.cpp:554
@@ +553,3 @@
+{
+ return strcmp (event.GetBroadcasterClass(), SBCommandInterpreter::GetBroadcasterClass()) == 0;
+}
----------------
ki.stfu wrote:
> clayborg wrote:
> > The strings are returns as the "const char *" from a lldb_private::ConstString object, so just do a pointer compare instead of a strcmp.
> I think it's wrong.
> ```
> file1.cpp:
>
> const char s1 [] = "abc";
> ```
>
> ```
> file2.cpp:
>
> extern const char s1 [];
> const char *s2 = "abc";
> assert (s1==s2); // error
> assert (!strcmp (s1,s2)); // ok
> ```
>
> I'd prefer to keep it as is.
What I am saying is the "const char *" that comes back from both "event.GetBroadcasterClass()" is a "const char *" that comes from a ConstString object. Same thing with the "const char *" that is returned from "SBCommandInterpreter::GetBroadcasterClass()". So of course "file1.cpp" and "file2.cpp" will fail, that is obvious. So your example will work with ConstString objects:
```
file1.cpp:
ConstString s1("abc");
```
```
file2.cpp:
extern ConstString s1;
ConstString s2("abc");
assert(s1.GetCString() == s2.GetCString());
assert(strcmp(s1.GetCString(), s2.GetCString()) == 0);
```
http://reviews.llvm.org/D8382
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the lldb-commits
mailing list