From d2b0a47c6fc4f3f4c9c869111c0750f6d5a9d574 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Tue, 11 Apr 2017 22:56:50 +0200 Subject: Add include-what-you-use mapping --- CMakeLists.txt | 11 ++++ Utilities/IWYU/mapping.imp | 136 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 Utilities/IWYU/mapping.imp diff --git a/CMakeLists.txt b/CMakeLists.txt index ed5de10..545177b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -226,6 +226,17 @@ option(CMAKE_USE_FOLDERS "Enable folder grouping of projects in IDEs." ON) mark_as_advanced(CMAKE_USE_FOLDERS) +option(CMake_RUN_IWYU "Run include-what-you-use with the compiler." OFF) +if(CMake_RUN_IWYU) + find_program(IWYU_COMMAND NAMES include-what-you-use iwyu) + if(NOT IWYU_COMMAND) + message(FATAL_ERROR "CMake_RUN_IWYU is ON but include-what-you-use is not found!") + endif() + set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE + "${IWYU_COMMAND};-Xiwyu;--mapping_file=${CMake_SOURCE_DIR}/Utilities/IWYU/mapping.imp") +endif() + + #----------------------------------------------------------------------- # a macro that only sets the FOLDER target property if it's # "appropriate" diff --git a/Utilities/IWYU/mapping.imp b/Utilities/IWYU/mapping.imp new file mode 100644 index 0000000..cfa90cc --- /dev/null +++ b/Utilities/IWYU/mapping.imp @@ -0,0 +1,136 @@ +[ + # C++ alternatives to C standard headers + { include: [ "", public, "", public ] }, + { include: [ "", public, "", public ] }, + { include: [ "", public, "", public ] }, + { include: [ "", public, "", public ] }, + { include: [ "", public, "", public ] }, + { include: [ "", public, "", public ] }, + { include: [ "", public, "", public ] }, + { include: [ "", public, "", public ] }, + { include: [ "", public, "", public ] }, + { include: [ "", public, "", public ] }, + { include: [ "", public, "", public ] }, + { include: [ "", public, "", public ] }, + { include: [ "", public, "", public ] }, + { include: [ "", public, "", public ] }, + { include: [ "", public, "", public ] }, + { include: [ "", public, "", public ] }, + { include: [ "", public, "", public ] }, + { include: [ "", public, "", public ] }, + { include: [ "", public, "", public ] }, + + # HACK: check whether this can be removed with next iwyu release. + { include: [ "", private, "", public ] }, + { include: [ "", private, "", public ] }, + { include: [ "", private, "", public ] }, + { include: [ "", private, "", public ] }, + { include: [ "", private, "", public ] }, + { include: [ "", private, "", public ] }, + + # HACK: check whether this can be removed with next iwyu release. + { symbol: [ "__GLIBC__", private, "", public ] }, + { symbol: [ "_Noreturn", private, "", public ] }, + + # HACK: iwyu wrongly thinks that including is sufficient. + { symbol: [ "std::stringstream", private, "", public ] }, + { symbol: [ "std::istringstream", private, "", public ] }, + { symbol: [ "std::ostringstream", private, "", public ] }, + + # HACK: iwyu suggests those two files each time vector[] is used. + # https://github.com/include-what-you-use/include-what-you-use/issues/166 + { include: [ "", private, "", public ] }, + { include: [ "", public, "", public ] }, + + # TODO: enable this block and remove some includes? + #{ symbol: [ "std::pair", private, "", public ] }, + #{ symbol: [ "std::pair", private, "", public ] }, + #{ symbol: [ "std::pair", private, "", public ] }, + + # Wrappers for headers added in TR1 / C++11 + # { include: [ "", public, "\"cm_array.hxx\"", public ] }, + # { include: [ "", public, "\"cm_functional.hxx\"", public ] }, + # { include: [ "", public, "\"cm_memory.hxx\"", public ] }, + { include: [ "", public, "\"cm_unordered_map.hxx\"", public ] }, + { include: [ "", public, "\"cm_unordered_set.hxx\"", public ] }, + # { include: [ "", public, "\"cm_array.hxx\"", public ] }, + # { include: [ "", public, "\"cm_functional.hxx\"", public ] }, + # { include: [ "", public, "\"cm_memory.hxx\"", public ] }, + { include: [ "", public, "\"cm_unordered_map.hxx\"", public ] }, + { include: [ "", public, "\"cm_unordered_set.hxx\"", public ] }, + + # KWIML + { include: [ "", public, "\"cm_kwiml.h\"", public ] }, + { include: [ "", public, "\"cm_kwiml.h\"", public ] }, + + # Self-sufficient wrapper for + { include: [ "", public, "\"cm_sys_stat.h\"", public ] }, + { symbol: [ "mode_t", private, "\"cm_sys_stat.h\"", public ] }, + + # TODO: remove once TR1 / C++11 is required. + { include: [ "\"cmsys/hash_fun.hxx\"", private, "\"cm_unordered_map.hxx\"", public ] }, + { include: [ "\"cmsys/hash_fun.hxx\"", private, "\"cm_unordered_set.hxx\"", public ] }, + { include: [ "\"cmsys/hash_map.hxx\"", private, "\"cm_unordered_map.hxx\"", public ] }, + { include: [ "\"cmsys/hash_set.hxx\"", private, "\"cm_unordered_set.hxx\"", public ] }, + { include: [ "\"cmsys/hashtable.hxx\"", private, "\"cm_unordered_map.hxx\"", public ] }, + { include: [ "\"cmsys/hashtable.hxx\"", private, "\"cm_unordered_set.hxx\"", public ] }, + + # Wrappers for 3rd-party libraries used from the system. + { include: [ "", private, "\"cm_libarchive.h\"", public ] }, + { include: [ "", private, "\"cm_libarchive.h\"", public ] }, + { include: [ "@", private, "\"cm_curl.h\"", public ] }, + { include: [ "", private, "\"cm_expat.h\"", public ] }, + { include: [ "", private, "\"cm_expat.h\"", public ] }, + { include: [ "", private, "\"cm_jsoncpp_reader.h\"", public ] }, + { include: [ "", private, "\"cm_jsoncpp_value.h\"", public ] }, + { include: [ "", private, "\"cm_jsoncpp_writer.h\"", public ] }, + { include: [ "", private, "\"cm_rhash.h\"", public ] }, + { include: [ "", private, "\"cm_uv.h\"", public ] }, + { include: [ "@", private, "\"cm_uv.h\"", public ] }, + { include: [ "", private, "\"cm_kwiml.h\"", public ] }, + { include: [ "", private, "\"cm_kwiml.h\"", public ] }, + { include: [ "", private, "\"cm_xmlrpc.h\"", public ] }, + { include: [ "", private, "\"cm_xmlrpc.h\"", public ] }, + { include: [ "@", private, "\"cm_xmlrpc.h\"", public ] }, + { include: [ "", private, "\"cm_zlib.h\"", public ] }, + { include: [ "", private, "\"cm_zlib.h\"", public ] }, + + # Wrappers for bundled 3rd-party libraries. + { include: [ "\"cmlibarchive/libarchive/archive.h\"", private, "\"cm_libarchive.h\"", public ] }, + { include: [ "\"cmlibarchive/libarchive/archive_entry.h\"", private, "\"cm_libarchive.h\"", public ] }, + { include: [ "@\"cmcurl/include/curl/.+\\.h\"", private, "\"cm_curl.h\"", public ] }, + { include: [ "\"cmexpat/lib/expat.h\"", private, "\"cm_expat.h\"", public ] }, + { include: [ "\"cmexpat/lib/expat_external.h\"", private, "\"cm_expat.h\"", public ] }, + { include: [ "\"cmjsoncpp/include/json/reader.h\"", private, "\"cm_jsoncpp_reader.h\"", public ] }, + { include: [ "\"cmjsoncpp/include/json/value.h\"", private, "\"cm_jsoncpp_value.h\"", public ] }, + { include: [ "\"cmjsoncpp/include/json/writer.h\"", private, "\"cm_jsoncpp_writer.h\"", public ] }, + { include: [ "\"cmlibrhash/librhash/rhash.h\"", private, "\"cm_rhash.h\"", public ] }, + { include: [ "\"cmlibuv/include/uv.h\"", private, "\"cm_uv.h\"", public ] }, + { include: [ "@\"cmlibuv/include/uv-.+\\.h\"", private, "\"cm_uv.h\"", public ] }, + { include: [ "\"KWIML/include/kwiml/abi.h\"", private, "\"cm_kwiml.h\"", public ] }, + { include: [ "\"KWIML/include/kwiml/int.h\"", private, "\"cm_kwiml.h\"", public ] }, + { include: [ "\"cmzlib/cm_zlib_mangle.h\"", private, "\"cm_zlib.h\"", public ] }, + { include: [ "\"cmzlib/zconf.h\"", private, "\"cm_zlib.h\"", public ] }, + { include: [ "\"cmzlib/zlib.h\"", private, "\"cm_zlib.h\"", public ] }, + + { symbol: [ "std::ifstream", private, "\"cmsys/FStream.hxx\"", public ] }, + { symbol: [ "std::ofstream", private, "\"cmsys/FStream.hxx\"", public ] }, + { symbol: [ "cmsys::ifstream", private, "\"cmsys/FStream.hxx\"", public ] }, + { symbol: [ "cmsys::ofstream", private, "\"cmsys/FStream.hxx\"", public ] }, + + { include: [ "", public, "\"cmsys/FStream.hxx\"", public ] }, + { include: [ "", public, "\"cmsys/FStream.hxx\"", public ] }, + { include: [ "", public, "\"cmsys/FStream.hxx\"", public ] }, + + # major and minor are used as macro arguments. Those are false matches. + { symbol: [ "major", private, "\"cm_kwiml.h\"", public ] }, + { symbol: [ "minor", private, "\"cm_kwiml.h\"", public ] }, + { symbol: [ "major", private, "\"cmVersion.h\"", public ] }, + { symbol: [ "minor", private, "\"cmVersion.h\"", public ] }, + + { include: [ "", private, "\"cmCursesStandardIncludes.h\"", public ] }, + { include: [ "\"form.h\"", private, "\"cmCursesStandardIncludes.h\"", public ] }, + { include: [ "", private, "\"cmCursesStandardIncludes.h\"", public ] }, +] + +# vim: set ft=toml: -- cgit v0.12