[PATCH] [PATCH] [clang-tools-extra] A Clang extra tool to find missing includes

Luke Zarko lukezarko at gmail.com
Tue Aug 27 18:31:56 PDT 2013


lzarko added you to the CC list for the revision "[PATCH] [clang-tools-extra] A Clang extra tool to find missing includes".

This is a tool that uses an external database, like a ctags file, to suggest missing includes to fix a broken translation unit. It can produce diagnostics like:

  TESTFILE:6:9: note: Inferring that M names a namespace.
  using ::M::X;
          ^
  TESTFILE:6:12: note: For M::X, include m_x_empty_class.h.
  using ::M::X;
             ^

or:

  TESTFILE:6:1: note: For M::Q::Y, include m_q_y_empty_class.h.
  Y a;
  ^
  TESTFILE:6:1: note: Alternately, for N::Q::Y, include n_q_y_empty_class.h.

It works by looping for a bounded number of times. On each iteration, the broken TU is parsed and passed through semantic analysis. When typos are encountered or when an incomplete type is detected where a complete type is required, the database is consulted to try and find a header with an appropriate declaration or definition. The header is inserted into the TU (currently using a fixed formatting rule).

http://llvm-reviews.chandlerc.com/D1538

Files:
  CMakeLists.txt
  Makefile
  fyi/CMakeLists.txt
  fyi/Core/CMakeLists.txt
  fyi/Core/CtagsSemaSearchPlugin.cpp
  fyi/Core/CtagsSemaSearchPlugin.h
  fyi/Core/FileTracker.cpp
  fyi/Core/FileTracker.h
  fyi/Core/FyiAction.cpp
  fyi/Core/FyiAction.h
  fyi/Core/FyiActionFactory.cpp
  fyi/Core/FyiActionFactory.h
  fyi/Core/FyiDiagnosticHooks.cpp
  fyi/Core/FyiDiagnosticHooks.h
  fyi/Core/FyiPreprocessorHooks.cpp
  fyi/Core/FyiPreprocessorHooks.h
  fyi/Core/Makefile
  fyi/Core/NameUtils.cpp
  fyi/Core/NameUtils.h
  fyi/Core/SemaSearchPlugin.h
  fyi/Makefile
  fyi/readtags/CMakeLists.txt
  fyi/readtags/Makefile
  fyi/readtags/readtags.c
  fyi/readtags/readtags.h
  fyi/tool/CMakeLists.txt
  fyi/tool/FindYourIncludes.cpp
  fyi/tool/Makefile
  test/CMakeLists.txt
  test/fyi/Input/Project/a_empty_class.h
  test/fyi/Input/Project/b_empty_class.h
  test/fyi/Input/Project/ba_empty_class.h
  test/fyi/Input/Project/c_empty_class.h
  test/fyi/Input/Project/m_q_y_empty_class.h
  test/fyi/Input/Project/m_x_empty_class.h
  test/fyi/Input/Project/n_q_y_empty_class.h
  test/fyi/Input/Project/n_q_z_empty_class.h
  test/fyi/Input/Project/n_x_empty_class.h
  test/fyi/Input/Project/s_static_method.h
  test/fyi/Input/Project/tags
  test/fyi/Input/System/stdfoo.h
  test/fyi/a_missing_decl.cpp
  test/fyi/a_missing_decl.cpp_expected
  test/fyi/a_missing_decl.cpp_stderr
  test/fyi/compound_unqualified_lookup.cpp
  test/fyi/compound_unqualified_lookup.cpp_expected
  test/fyi/compound_unqualified_lookup.cpp_stderr
  test/fyi/delete_incomplete.cpp
  test/fyi/delete_incomplete.cpp_expected
  test/fyi/delete_incomplete.cpp_stderr
  test/fyi/disjoint_unqualified_lookup.cpp
  test/fyi/disjoint_unqualified_lookup.cpp_expected
  test/fyi/disjoint_unqualified_lookup.cpp_stderr
  test/fyi/global_a_missing_decl.cpp
  test/fyi/global_a_missing_decl.cpp_expected
  test/fyi/global_a_missing_decl.cpp_stderr
  test/fyi/global_m_x_missing_decl.cpp
  test/fyi/global_m_x_missing_decl.cpp_expected
  test/fyi/global_m_x_missing_decl.cpp_stderr
  test/fyi/hopeless.cpp
  test/fyi/hopeless.cpp_stderr
  test/fyi/last_resort_unqualified_lookup.cpp
  test/fyi/last_resort_unqualified_lookup.cpp_expected
  test/fyi/last_resort_unqualified_lookup.cpp_stderr
  test/fyi/m_x_missing_decl.cpp
  test/fyi/m_x_missing_decl.cpp_expected
  test/fyi/m_x_missing_decl.cpp_stderr
  test/fyi/move_old_suffix.cpp
  test/fyi/move_old_suffix.cpp_expected
  test/fyi/move_old_suffix.cpp_stderr
  test/fyi/no_namespace_incomplete_class.cpp
  test/fyi/no_namespace_incomplete_class.cpp_expected
  test/fyi/no_namespace_incomplete_class.cpp_stderr
  test/fyi/ordered_include_0.cpp
  test/fyi/ordered_include_0.cpp_expected
  test/fyi/ordered_include_0.cpp_stderr
  test/fyi/ordered_include_1.cpp
  test/fyi/ordered_include_1.cpp_expected
  test/fyi/ordered_include_1.cpp_stderr
  test/fyi/ordered_include_2.cpp
  test/fyi/ordered_include_2.cpp_expected
  test/fyi/ordered_include_2.cpp_stderr
  test/fyi/ordered_include_3.cpp
  test/fyi/ordered_include_3.cpp_expected
  test/fyi/ordered_include_3.cpp_stderr
  test/fyi/ordered_include_4.cpp
  test/fyi/ordered_include_4.cpp_expected
  test/fyi/ordered_include_4.cpp_stderr
  test/fyi/save_new_suffix.cpp
  test/fyi/save_new_suffix.cpp.ffyi
  test/fyi/save_new_suffix.cpp_stderr
  test/fyi/shortpath_unqualified_lookup.cpp
  test/fyi/shortpath_unqualified_lookup.cpp_expected
  test/fyi/shortpath_unqualified_lookup.cpp_stderr
  test/fyi/static_method.cpp
  test/fyi/static_method.cpp_expected
  test/fyi/static_method.cpp_stderr
  test/fyi/using_m_x_missing_decl.cpp
  test/fyi/using_m_x_missing_decl.cpp_expected
  test/fyi/using_m_x_missing_decl.cpp_stderr
  unittests/CMakeLists.txt
  unittests/Makefile
  unittests/fyi/CMakeLists.txt
  unittests/fyi/CtagsSemaSearchPluginTest.cpp
  unittests/fyi/Makefile
  unittests/fyi/NameUtilsTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1538.1.patch
Type: text/x-patch
Size: 174715 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130827/7747a6db/attachment.bin>


More information about the cfe-commits mailing list