Fallback to TU url when looking for a cached ParseSession.

Milian Wolff mail at milianw.de
Thu Apr 23 12:02:31 UTC 2015


On Thursday 23 April 2015 12:28:57 Sergey Kalinichev wrote:
> >The code to pick the right sessionData (i.e. the right URL) is in
> >ClangIndex and reused by my patch. Or what do you mean exactly?
> 
> We only attach an AST to the URL for which we have TU, but why can't
> we attach the AST for all opened in editor documents and reset the AST
> pointer when session data changes instead? It'd save us from passing
> ClangIndex around.
>
> >- you have a .cpp open and parse it. The .cpp URL/DUContext gets the Clang
> >AST attached
> >now you open the corresponding .h file. Without my patch, you won't get any
> >code completion now, even though all required information is available but
> >code completion looks for the AST attached to the .h file, not the .cpp
> >file (fixed by my >patch).
>
> That's odd because now I do have code-completion in headers, but to
> enable it I first have to modify cpp, then h, then again cpp and only
> then code-completion in headers begins to work.

I'll try to investigate this and try to come up with a different solution. 
Maybe it's enough to just always reparse open documents when they don't have 
an AST attached. And of course we must make sure to attach the AST also to 
included files as necessary.
 
> >Sergey, is the above with or without my patch? Do you have an example file
> >pair for me to play with? What do you change to trigger the behavior?
> 
> It happens always, even without your patch. Just open any pair of
> files, e.g.: tuduchain.* and see how much time clang_codeCompleteAt
> takes.
> 
> >note that this might be problematic when files depend on defines or similar
> >that are set in project files
> 
> But the same is valid for system headers. Still you suggest to create
> PCH for STL + Qt headers. So, why it'd work for system headers, but
> won't work for project headers?

Good question. I think this invalidates my reasoning. Maybe a different reason 
might be valid though: System headers won't get updated often, and thus the 
PCH also does not need to be updated. When you create PCHs for project files, 
they will need to be updated regularly which might not give any desirable 
performance gain.

Bye
-- 
Milian Wolff
mail at milianw.de
http://milianw.de


More information about the KDevelop-devel mailing list