Author: d0k Date: Fri Dec 16 10:09:06 2016 New Revision: 289952 URL: http://llvm.org/viewvc/llvm-project?rev=289952&view=rev Log: [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). Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp?rev=289952&r1=289951&r2=289952&view=diff ============================================================================== --- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original) +++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Fri Dec 16 10:09:06 2016 @@ -153,8 +153,8 @@ bool IncludeFixerSemaSource::MaybeDiagno 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 = Modified: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp?rev=289952&r1=289951&r2=289952&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp (original) +++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Fri Dec 16 10:09:06 2016 @@ -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) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits