[Lldb-commits] [PATCH] D15312: Fix scope-based lookup when more than one function is found.

Dawn Perchik via lldb-commits lldb-commits at lists.llvm.org
Tue Dec 8 15:12:52 PST 2015

dawn added a comment.

> Greg: But going forward I would like to see more of "find a struct named 'X'

in CompilerDeclContext 'Y'" queries, instead of ...

I think lldb should have both, a "search for anything named foo in my scope context" (for when a user does "p foo"), and a "search for a thingy (functions/types/variables/etc.) named foo in my scope context" (for when a user does "expr --type function -- foo").

> tberghammer: I am not sure if doing all of the parsing lazily is the good approach because of speed considerations.  ...  looking into the direction we are heading now we will need to parse more and more information to improve the expression evaluation


> Greg:


>   int32_t CompilerDeclContext::GetDepth (const CompilerDeclContext &decl_ctx);


> This would get the depth of one CompilerDeclContext within another CompilerDeclContext, it would return -1 if "decl_ctx" doesn't fall within the object, and zero or above it is is contained.

The problem with this is that it won't work for using declarations which require information about the thing we're looking up before it can determine the proper scope levels.

> BTW: I fixed DeclContextFindDeclByName to return a vector of CompilerDecl objects:

Cool, but it needs to accept an optional type to deal with function overloading.  I can add that and see if I can come up with a new patch that uses the new DeclContextFindDeclByName. (In my copious spare time - heh).  But...

One major performance benefit of my original implementation is that the function's name and type *only* need to be tested in the case of a using declaration, so in general it's much faster, because we only need to look for the function's parent's lookup scope.  So, are you sure you want to go down this path?



More information about the lldb-commits mailing list