Bug 174840 - IASTCompletionContext finds duplicate bindings
Summary: IASTCompletionContext finds duplicate bindings
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 4.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 4.0 M6   Edit
Assignee: Bryan Wilkinson CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-02-20 14:20 EST by Bryan Wilkinson CLA
Modified: 2008-06-20 10:58 EDT (History)
1 user (show)

See Also:


Attachments
proposed patch (61.39 KB, patch)
2007-02-20 14:24 EST, Bryan Wilkinson CLA
bjorn.freeman-benson: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bryan Wilkinson CLA 2007-02-20 14:20:54 EST
Implementations of IASTCompletionContext.findBindings(...) can return duplicate bindings.  Each implementation starts by searching the AST with the help of either CPPSemantics or CVisitor.  Afterwards, the index is searched as well.  This can result in bindings from the AST that are identical to bindings from the index.

Although this does not produce any negative side-effects (as duplicate completion proposals are filtered out later on), it is clearly not ideal.
Comment 1 Bryan Wilkinson CLA 2007-02-20 14:24:57 EST
Created attachment 59404 [details]
proposed patch

This patch moves the index lookups into CPPSemantics and CVisitor.  The index is used to get bindings from translation units and namespaces instead of searching through the AST.  If there is no index, however, the AST is searched as per usual.

The resulting IASTCompletionContext.findBindings(...) implementations now simply consist of a call to the appropriate CPPSemantics or CVisitor helper, followed by any necessary filtering of the bindings.
Comment 2 Anton Leherbauer CLA 2007-02-21 03:49:24 EST
Avoiding duplicates in the first place is a good thing. I'll try it out.
Comment 3 Anton Leherbauer CLA 2007-02-22 06:24:46 EST
Committed. Could not find a flaw.