[cfe-dev] Selector::getAsString problem in CIndex
steve naroff
snaroff at apple.com
Tue Oct 20 08:36:29 PDT 2009
Hi John,
Comments below...
On Oct 20, 2009, at 11:03 AM, John Thompson wrote:
> Now that I have electricity again...
>
> Sorry, I was looking too deep, not noticing that the function
> returned a std::string. The problem was up higher in CIndex.cpp, in
> a couple of the functions that return const char *, with the same
> problem I described of the temporary going away before the string
> can be used.
>
Nice catch. I guess other platforms are more forgiving...
> I worked around it by using a static buffer, which is admittedly not
> so good. A cleaner way might be to have the user pass in a string
> buffer, since it seems this needs to be a C interface. Should I do
> that, or does the API need to remain unchanged? Let me know if
> there's a better way.
>
I'd like to avoid cluttering the interface if possible. I'm not an
expert on std::String, so I'll have to look into this. I'll get back
to you...
> The enclosed patch contains my hacked version, which also includes
> the DLL exporting glue (redone in the naming style I'm used to -
> apologies to Jeff Krall, who'd already done it).
>
Can you separate this from the other stuff in the patch? I'd like to
keep this type of mechanical change separate from the trickier stuff...
> Note that I moved the getLocationFromCursor function out of the
> extern "C" {} because MSVC was complaining about it because of the
> object return type.
>
> Where does "basename" come from on the non-Windows platforms? It
> was unresolved, so I guessed at it, but which seems to work.
>
basename is a Unix/Linux function...not standard C or POSIX. Does
Windows have something called _splitpath()?
> The c-index-api-test.m test passes on Windows with these changes.
Great. Thanks for helping out on this!
snaroff
>
> -John
> On Mon, Oct 19, 2009 at 12:14 PM, John Thompson <john.thompson.jtsoftware at gmail.com
> > wrote:
> I'm looking at a test failure of c-index-api-test.m on Windows, and
> I've run into a problem I don't know how to easily fix.
>
> In the function Selector::getAsString function in
> IdentifierTable.cpp at line 330:
>
> return II->getName().str() + ":";
>
> On Windows, at least, this isn't working as expected. I think it's
> because a tempory string created gets destructed before the return
> completes, causing the resulting string pointer to point to garbage,
> resulting in garbage for the identifier name in the index output.
>
> If someone more knowlegeable about it could take a look at it, I'd
> appreciate it.
>
> Note that if you need to run it on windows, you'll need some CIndex
> changes I'm working on, but haven't completed yet, so let me know if
> you need them.
>
> -John
>
> --
> John Thompson
> John.Thompson.JTSoftware at gmail.com
>
>
>
>
> --
> John Thompson
> John.Thompson.JTSoftware at gmail.com
>
> <cindex.patch>_______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20091020/c73310be/attachment.html>
More information about the cfe-dev
mailing list