[include-fixer] Desugar incomplete types.

This will look through typedefs so include-fixer will look up the target
of the typedef instead of the typedef itself (which is already in
scope).

llvm-svn: 289952
This commit is contained in:
Benjamin Kramer 2016-12-16 16:09:06 +00:00
parent 85347dde27
commit bc805aef33
2 changed files with 6 additions and 2 deletions

View File

@ -153,8 +153,8 @@ bool IncludeFixerSemaSource::MaybeDiagnoseMissingCompleteType(
return false;
clang::ASTContext &context = CI->getASTContext();
std::string QueryString =
T.getUnqualifiedType().getAsString(context.getPrintingPolicy());
std::string QueryString = QualType(T->getUnqualifiedDesugaredType(), 0)
.getAsString(context.getPrintingPolicy());
DEBUG(llvm::dbgs() << "Query missing complete type '" << QueryString << "'");
// Pass an empty range here since we don't add qualifier in this case.
std::vector<find_all_symbols::SymbolInfo> MatchedSymbols =

View File

@ -136,6 +136,10 @@ TEST(IncludeFixer, IncompleteType) {
"namespace std {\nclass string;\n}\nstd::string foo;\n",
runIncludeFixer("#include \"foo.h\"\n"
"namespace std {\nclass string;\n}\nstring foo;\n"));
EXPECT_EQ("#include <string>\n"
"class string;\ntypedef string foo;\nfoo f;\n",
runIncludeFixer("class string;\ntypedef string foo;\nfoo f;\n"));
}
TEST(IncludeFixer, MinimizeInclude) {