2281ece9c3
My original upstream commits to fix the detection of the <unordered_map> and <ext/hash_map> headers needed some fixes which were committed later. The original patches have now been replaced by all the needed commits squashed into a single 'patch-fix-clang-support' diff.
147 lines
5 KiB
Text
147 lines
5 KiB
Text
commit 934b7b7b7571cec0e0f4affdc181807080a999cf
|
|
Author: Raphael Kubo da Costa <rakuco@FreeBSD.org>
|
|
Date: Tue May 29 16:14:00 2012 -0300
|
|
|
|
Fix finding the unordered_map header.
|
|
|
|
Apply the fix made in kdevplatform commit
|
|
d756d28f4b000d2b7af12822c935dd13754876b4.
|
|
|
|
Including unordered_map generates a warning when the compiler is not
|
|
passed the -std=c++0x option, which made the check fail when the
|
|
compilation CMake tried in check_include_file_cxx did not use it.
|
|
|
|
commit e37294eaa6694e4cf93012569f5ef947651f50e3
|
|
Author: Raphael Kubo da Costa <rakuco@FreeBSD.org>
|
|
Date: Mon May 28 15:40:15 2012 -0300
|
|
|
|
Look for ext/hash_map and unordered_map instead of checking gcc's version.
|
|
|
|
Follow-up to commits 9f8e8f662974a1035ea64f0ab9404b8858a02a57 and
|
|
5c59bd61b1df1b963959f086c5202689c084e0f3. The decision of whether to
|
|
include <ext/hash_map> or <unordered_map> for gcc/clang was based on
|
|
whether gcc > 4.3 was installed or whether clang was being used. The
|
|
latter implicitly assumed a recent enough libstdc++ version (ie. >=
|
|
4.3) was being used, which might not be the case on systems such as
|
|
FreeBSD and possibly OS X.
|
|
|
|
Instead of checking for compiler versions, we now look for these
|
|
headers: CMake first detects whether <unordered_map> is present and,
|
|
in case it is not, it looks for <ext/hash_map>. The checks in
|
|
languages/cpp/parser/parser.h have been updated as well. This should
|
|
cover all the cases being previously detected, as well as fix the
|
|
checks for FreeBSD and other systems where the build was failing
|
|
before with clang.
|
|
|
|
Reviewed-by: Millian Wolff
|
|
REVIEW: 105067
|
|
|
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index 8a3be21..bd79a69 100644
|
|
--- ./CMakeLists.txt
|
|
+++ ./CMakeLists.txt
|
|
@@ -34,6 +34,22 @@ add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
|
|
|
|
include_directories(${KDevelop_SOURCE_DIR} ${KDevelop_BINARY_DIR} ${KDE4_INCLUDES} )
|
|
|
|
+# TODO: Remove when LTS for g++ < 4.3 has ended.
|
|
+# See also: languages/cpp/parser/parser.h
|
|
+if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
+ include(CheckIncludeFileCXX)
|
|
+ set(CMAKE_REQUIRED_FLAGS "-std=c++0x")
|
|
+ check_include_file_cxx(unordered_map HAVE_UNORDERED_MAP)
|
|
+ set(CMAKE_REQUIRED_FLAGS "")
|
|
+
|
|
+ if(HAVE_UNORDERED_MAP)
|
|
+ message(STATUS "Enabling c++0x support for unordered map")
|
|
+ add_definitions( -std=c++0x ) # For unordered_map
|
|
+ else(HAVE_UNORDERED_MAP)
|
|
+ check_include_file_cxx(ext/hash_map HAVE_EXT_HASH_MAP)
|
|
+ endif(HAVE_UNORDERED_MAP)
|
|
+endif(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
+
|
|
# create config.h
|
|
include (ConfigureChecks.cmake)
|
|
configure_file (config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h )
|
|
diff --git a/config.h.cmake b/config.h.cmake
|
|
index 0c41fe4..d76b3df 100644
|
|
--- ./config.h.cmake
|
|
+++ ./config.h.cmake
|
|
@@ -8,4 +8,10 @@
|
|
/* Valgrind presence */
|
|
#cmakedefine HAVE_VALGRIND_H 1
|
|
|
|
+/* Whether <unordered_map> exists */
|
|
+#cmakedefine HAVE_UNORDERED_MAP 1
|
|
+
|
|
+/* Whether <ext/hash_map> exists */
|
|
+#cmakedefine HAVE_EXT_HASH_MAP 1
|
|
+
|
|
#endif // KDEVELOP_CONFIG_H
|
|
diff --git a/languages/cpp/CMakeLists.txt b/languages/cpp/CMakeLists.txt
|
|
index 1577a7b..94a9bec 100644
|
|
--- ./languages/cpp/CMakeLists.txt
|
|
+++ ./languages/cpp/CMakeLists.txt
|
|
@@ -9,22 +9,6 @@ include_directories(
|
|
|
|
add_definitions( -DKDE_DEFAULT_DEBUG_AREA=9007 )
|
|
|
|
-if(CMAKE_COMPILER_IS_GNUCXX)
|
|
- # TODO: Remove when LTS for g++ < 4.3 has ended.
|
|
- # See also: languages/cpp/parser/parser.h
|
|
- macro_ensure_version("4.3.0" "${_gcc_version}" GCC_IS_NEWER_THAN_4_3)
|
|
- if (GCC_IS_NEWER_THAN_4_3)
|
|
- message(STATUS "Enabling c++0x support for unordered map")
|
|
- add_definitions( -std=c++0x ) # For unordered_map
|
|
- else(GCC_IS_NEWER_THAN_4_3)
|
|
- add_definitions( -DGXX_LT_4_3 )
|
|
- endif (GCC_IS_NEWER_THAN_4_3)
|
|
-endif(CMAKE_COMPILER_IS_GNUCXX)
|
|
-if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
- # TODO: version check?
|
|
- add_definitions( -std=c++0x )
|
|
-endif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
-
|
|
add_subdirectory(parser)
|
|
add_subdirectory(cppduchain)
|
|
add_subdirectory(tests)
|
|
diff --git a/languages/cpp/parser/parser.h b/languages/cpp/parser/parser.h
|
|
index c519891..f498868 100644
|
|
--- ./languages/cpp/parser/parser.h
|
|
+++ ./languages/cpp/parser/parser.h
|
|
@@ -20,6 +20,8 @@
|
|
#ifndef PARSER_H
|
|
#define PARSER_H
|
|
|
|
+#include "config.h"
|
|
+
|
|
#include "ast.h"
|
|
#include "lexer.h"
|
|
#include "commentparser.h"
|
|
@@ -30,18 +32,18 @@
|
|
#include <cppparserexport.h>
|
|
#include "commentformatter.h"
|
|
|
|
-#ifdef Q_CC_MSVC
|
|
-#include <hash_map>
|
|
-using namespace stdext;
|
|
+#if defined(HAVE_UNORDERED_MAP) // CXX-0
|
|
+#include <unordered_map>
|
|
+template <class Key, class Data>
|
|
+class hash_map : public std::unordered_map<Key, Data> { };
|
|
|
|
-#elif defined GXX_LT_4_3
|
|
+#elif defined(HAVE_EXT_HASH_MAP)
|
|
#include <ext/hash_map>
|
|
using namespace __gnu_cxx;
|
|
|
|
-#else // CXX-0
|
|
-#include <unordered_map>
|
|
-template <class Key, class Data>
|
|
-class hash_map : public std::unordered_map<Key, Data> { };
|
|
+#elif defined(Q_CC_MSVC)
|
|
+#include <hash_map>
|
|
+using namespace stdext;
|
|
#endif
|
|
|
|
class TokenStream;
|