Page MenuHomePhabricator

[clang][ASTContext] Try to avoid sorting comments for code completion
Changes PlannedPublic

Authored by jkorous on Apr 24 2019, 4:41 PM.

Details

Summary

For large number of deserialized comments (~100k) the way how we try to attach them to declaration in completion comments is too expensive.

Currently we're sorting all the comments by source location (expensive) and later bisecting them for every interesting declaration to find the closest comment before and after the declaration documentation comment.

This patch tries to just iterate over unsorted comments and see if there's any of the decls we're interested in nearby.

Diff Detail

Event Timeline

jkorous created this revision.Apr 24 2019, 4:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 24 2019, 4:41 PM
gribozavr added inline comments.Apr 25 2019, 8:51 AM
clang/include/clang/AST/ASTContext.h
800

Why not DenseMap?

808

Use ArrayRef.

clang/lib/AST/ASTContext.cpp
303

I'm really worried about all the logic duplication here vs. existing code.

clang/lib/AST/RawCommentList.cpp
366

Why is merging in RawCommentList::addComment not sufficient?

clang/lib/Sema/SemaCodeComplete.cpp
3180

There are only a couple of callers of this function, can we change them all to provide a comment if it exists?

3398

This method decl logic looks out of place here. It should be pushed down into the core logic for attaching comments.

jkorous planned changes to this revision.May 1 2019, 2:51 PM

@gribozavr thanks for the feedback. I'm rewriting the patch now as I figured out my detection of comments preceding declarations is unsound.