[include-fixer] Correct nested class search for identifiers with scoped information
authorHaojian Wu <hokein@google.com>
Tue, 2 Aug 2016 10:43:10 +0000 (10:43 +0000)
committerHaojian Wu <hokein@google.com>
Tue, 2 Aug 2016 10:43:10 +0000 (10:43 +0000)
commitadedac68dc300cb87eccfb9735d00325727ac58a
treee4bcbdaeabec2647d1b60ae3c27d997e2dec51e1
parent6c3591d33e8b7f4675e6ccdfadc647d0c2357564
[include-fixer] Correct nested class search for identifiers with scoped information

Summary:
include-fixer will firstly try to use scoped namespace context information to
search identifier. However, in some cases, it's unsafe to do nested class
search, because it might treat the identifier as a nested class of scoped
namespace.

Given the following code, and the symbol database only has two classes: "foo" and
"b::Bar".

    namespace foo { Bar t; }

Before getting fixing, include-fixer will never search "Bar" symbol.
Because it firstly tries to search "foo::Bar", there is no "Bar" in foo namespace,
then it finds "foo" in database finally. So it treats "Bar" is a nested class
of "foo".

Reviewers: bkramer

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D23023

llvm-svn: 277442
clang-tools-extra/include-fixer/IncludeFixer.cpp
clang-tools-extra/include-fixer/IncludeFixerContext.cpp
clang-tools-extra/include-fixer/SymbolIndexManager.cpp
clang-tools-extra/include-fixer/SymbolIndexManager.h
clang-tools-extra/unittests/include-fixer/IncludeFixerTest.cpp