Commit aefb8559 authored by Brad King's avatar Brad King

IWYU: Fix workaround mapping for std::hash

It is provided by `functional`, not `utility`.  Fix the mapping added by
commit 276d3c7a (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.
parent 276d3c7a
......@@ -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()
......
......@@ -7,6 +7,7 @@
#include "cm_kwiml.h"
#include <cstddef>
#include <functional>
#include <map>
#include <set>
#include <string>
......@@ -15,14 +16,12 @@
// IWYU insists we should forward-declare instead of including <functional>,
// 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 <class T> struct hash;
}
/* clang-format on */
#else
# include <functional>
#endif
#include "cmFindCommon.h"
......
......@@ -37,7 +37,6 @@
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
// Get rid of some windows macros:
......
......@@ -53,7 +53,7 @@
#{ symbol: [ "std::pair", private, "<set>", public ] },
# HACK: iwyu wrongly thinks that <system_error> is needed for std::hash
{ symbol: [ "std::hash", private, "<utility>", public ] },
{ symbol: [ "std::hash", private, "<functional>", public ] },
# __decay_and_strip is used internally in the C++11 standard library.
# IWYU does not classify it as internal and suggests to add <type_traits>.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment