Skip to content
  • David Nolden's avatar
    Search declarations by ID in addition to their range · 50041d95
    David Nolden authored
    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.
    50041d95