From aefb8559dca283b81d20a3f40afc8f39e6161ecb Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 7 Aug 2018 08:18:25 -0400 Subject: IWYU: Fix workaround mapping for std::hash It is provided by `functional`, not `utility`. Fix the mapping added by commit 276d3c7afe (IWYU: Add workaround mapping for std::hash, 2018-07-31). Also generalize the workaround from commit v3.12.0-rc1~39^2~1 (IWYU: Define a macro to tell code it is preprocessing for iwyu, 2018-05-25) to allow local builds to configure specific flags. This is needed because iwyu behaves differently in different environments. --- CMakeLists.txt | 3 ++- Source/cmFindPackageCommand.h | 5 ++--- Source/cmServerProtocol.cxx | 1 - Utilities/IWYU/mapping.imp | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e20d770..1fcd8f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -285,7 +285,8 @@ if(CMake_RUN_IWYU) 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;-w;-DCMAKE_IWYU") + "${IWYU_COMMAND};-Xiwyu;--mapping_file=${CMake_SOURCE_DIR}/Utilities/IWYU/mapping.imp;-w") + list(APPEND CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${CMake_IWYU_OPTIONS}) endif() diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index d8c7ab3..48f17ef 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -7,6 +7,7 @@ #include "cm_kwiml.h" #include +#include #include #include #include @@ -15,14 +16,12 @@ // IWYU insists we should forward-declare instead of including , // but we cannot forward-declare reliably because some C++ standard libraries // put the template in an inline namespace. -#ifdef CMAKE_IWYU +#ifdef CMAKE_IWYU_FORWARD_STD_HASH /* clang-format off */ namespace std { template struct hash; } /* clang-format on */ -#else -# include #endif #include "cmFindCommon.h" diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index b05eac4..c267160 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -37,7 +37,6 @@ #include #include #include -#include #include // Get rid of some windows macros: diff --git a/Utilities/IWYU/mapping.imp b/Utilities/IWYU/mapping.imp index 77bb572..5af8b85 100644 --- a/Utilities/IWYU/mapping.imp +++ b/Utilities/IWYU/mapping.imp @@ -53,7 +53,7 @@ #{ symbol: [ "std::pair", private, "", public ] }, # HACK: iwyu wrongly thinks that is needed for std::hash - { symbol: [ "std::hash", private, "", public ] }, + { symbol: [ "std::hash", private, "", public ] }, # __decay_and_strip is used internally in the C++11 standard library. # IWYU does not classify it as internal and suggests to add . -- cgit v0.12