Search declarations by ID in addition to their range

Authored by zwabel on Jul 5 2016, 1:57 PM.

Description

Search declarations by ID in addition to their range

The declaration search based on "findContextAt" completely fails when
there are multiple different versions of a header which were parsed
differently depending on a macro. Also, findContextAt does a linear
search, and may be slow when there is a large list of contexts.
Whenever possible, try finding the declaration by its qualified
identifier based on the duchain symbol table, which should be more
efficient and scalable.

Extract the qualified identifier from clang by
following up the chain of semantic parents. After declarations
were found based on the symbol table, they are filtered
the same way as those found by findContextAt -- so there should
be no regressions. When the search fails, then use the previous
findContextAt method instead.

Added a test which tests several difficult cases that failed
without this change, and that succeed with it.

This also fixes the testDeclarationsInsideMacroExpansion test,
which was EXPECT_FAIL, but which succeeds now.

Details

Committed
zwabelJul 20 2016, 5:19 PM
Parents
R32:a36ae3281e24: If no pinned translation unit is available, ask the duchain
Branches
Unknown
Tags
Unknown