From 89d6a36bc64b0e95136c925f4ed37f4520f9cb3a Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Fri, 9 Feb 2018 11:11:22 +0100 Subject: Clang: Disable internal threads in libclang We already run all operations in threads to avoid blocking, there is no need to start more threads within libclang. Before this change, a reparse would trigger 3 threads to start: 1. clangbackend: Utils::runAsync() for the job 2. libclang-internal: thread for reparse 3. libclang-internal: thread for annotating tokens (highlighting) Ensure that we use the same stack size for our threads as libclang was doing internally. C++ parsers usually have higher stack size requirements. Change-Id: I2f67602ddfbf77ea2c69144b56acf64ba08041f6 Reviewed-by: Ivan Donchevskii --- src/libs/clangsupport/clangcodemodelconnectionclient.cpp | 5 +++++ src/libs/clangsupport/processcreator.cpp | 9 +++++++++ src/libs/clangsupport/processcreator.h | 3 +++ 3 files changed, 17 insertions(+) (limited to 'src/libs') diff --git a/src/libs/clangsupport/clangcodemodelconnectionclient.cpp b/src/libs/clangsupport/clangcodemodelconnectionclient.cpp index 1938d06353..33d8987024 100644 --- a/src/libs/clangsupport/clangcodemodelconnectionclient.cpp +++ b/src/libs/clangsupport/clangcodemodelconnectionclient.cpp @@ -25,6 +25,7 @@ #include "clangcodemodelconnectionclient.h" +#include #include #include @@ -50,6 +51,10 @@ ClangCodeModelConnectionClient::ClangCodeModelConnectionClient( m_processCreator.setTemporaryDirectoryPattern("clangbackend-XXXXXX"); m_processCreator.setArguments({connectionName()}); + Utils::Environment environment; + environment.set(QStringLiteral("LIBCLANG_NOTHREADS"), QString()); + m_processCreator.setEnvironment(environment); + stdErrPrefixer().setPrefix("clangbackend.stderr: "); stdOutPrefixer().setPrefix("clangbackend.stdout: "); } diff --git a/src/libs/clangsupport/processcreator.cpp b/src/libs/clangsupport/processcreator.cpp index dfc7f56d9f..22b52793e3 100644 --- a/src/libs/clangsupport/processcreator.cpp +++ b/src/libs/clangsupport/processcreator.cpp @@ -56,6 +56,11 @@ void ProcessCreator::setArguments(const QStringList &arguments) m_arguments = arguments; } +void ProcessCreator::setEnvironment(const Utils::Environment &environment) +{ + m_environment = environment; +} + std::future ProcessCreator::createProcess() const { return std::async(std::launch::async, [&] { @@ -167,6 +172,10 @@ QProcessEnvironment ProcessCreator::processEnvironment() const processEnvironment.insert("TEMP", temporaryDirectoryPath); } + const Utils::Environment &env = m_environment; + for (auto it = env.constBegin(); it != env.constEnd(); ++it) + processEnvironment.insert(it.key(), it.value()); + return processEnvironment; } diff --git a/src/libs/clangsupport/processcreator.h b/src/libs/clangsupport/processcreator.h index 9742992175..928857319b 100644 --- a/src/libs/clangsupport/processcreator.h +++ b/src/libs/clangsupport/processcreator.h @@ -29,6 +29,7 @@ #include "processhandle.h" +#include #include #include @@ -51,6 +52,7 @@ public: void setTemporaryDirectoryPattern(const QString &temporaryDirectoryPattern); void setProcessPath(const QString &m_processPath); void setArguments(const QStringList &m_arguments); + void setEnvironment(const Utils::Environment &environment); void setObserver(QObject *m_observer); std::future createProcess() const; @@ -72,6 +74,7 @@ private: QString m_processPath; QString m_temporaryDirectoryPattern; QStringList m_arguments; + Utils::Environment m_environment; QObject *m_observer = nullptr; }; -- cgit v1.2.1 From fdd695c35c271bd467fd9da8a67589d733443c67 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Fri, 2 Feb 2018 15:18:40 +0100 Subject: Clang: Disable crash recovery in libclang ...because 1. We already run in a separate process. 2. It's not entirely clear in which state we end up after a crash, except for: 3. A "crashed" translation unit won't be freed, even when calling clang_disposeTranslationUnit(). This avoids undefined behavior within clangbackend and accumulated leaking memory in the long run. On the other side, crashes within libclang will crash clangbackend now, too. Change-Id: I0789c52db08ace2f7e181e3b7bdfc9f595f75e8d Reviewed-by: Ivan Donchevskii --- src/libs/clangsupport/clangcodemodelconnectionclient.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/libs') diff --git a/src/libs/clangsupport/clangcodemodelconnectionclient.cpp b/src/libs/clangsupport/clangcodemodelconnectionclient.cpp index 33d8987024..56186e24dc 100644 --- a/src/libs/clangsupport/clangcodemodelconnectionclient.cpp +++ b/src/libs/clangsupport/clangcodemodelconnectionclient.cpp @@ -53,6 +53,7 @@ ClangCodeModelConnectionClient::ClangCodeModelConnectionClient( Utils::Environment environment; environment.set(QStringLiteral("LIBCLANG_NOTHREADS"), QString()); + environment.set(QStringLiteral("LIBCLANG_DISABLE_CRASH_RECOVERY"), QString()); m_processCreator.setEnvironment(environment); stdErrPrefixer().setPrefix("clangbackend.stderr: "); -- cgit v1.2.1 From f8e88e8ce45a462f27d274c654e31a67032da757 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 31 May 2018 11:31:59 +0200 Subject: Fix compilation issues with C++17 Testable on Linux/macOS by changing c++14 to c++1z in qtcreator.pri. Testable with latest MSVC2017 by setting _CL_=/std:c++17. unary_function, binary_function, and a few other things that were deprecated are removed in C++17. std::string got a non-const overload for its "data" member function, so we cannot create a function pointer on it without specifying its type. Use std::declval instead (though it requires a default constructor for the type). MSVC seems to have an issue with Utils::transform for std::vector (used in Nim plugin), but that looks like a compiler issue. Change-Id: I94f9a93d591d55b610f86fabfc618158927d6221 Reviewed-by: Tobias Hunger --- src/libs/3rdparty/botan/botan.cpp | 2 +- src/libs/3rdparty/cplusplus/Name.h | 2 +- src/libs/3rdparty/cplusplus/Names.h | 2 +- src/libs/glsl/glslengine.h | 2 +- src/libs/qtcreatorcdbext/containers.cpp | 2 +- src/libs/qtcreatorcdbext/stringutils.h | 2 +- src/libs/qtcreatorcdbext/symbolgroup.cpp | 2 +- src/libs/utils/smallstringview.h | 4 +--- 8 files changed, 8 insertions(+), 10 deletions(-) (limited to 'src/libs') diff --git a/src/libs/3rdparty/botan/botan.cpp b/src/libs/3rdparty/botan/botan.cpp index 87736d5fe3..0d912062b3 100644 --- a/src/libs/3rdparty/botan/botan.cpp +++ b/src/libs/3rdparty/botan/botan.cpp @@ -465,7 +465,7 @@ inline V search_map(const std::map& mapping, * Function adaptor for delete operation */ template -class del_fun : public std::unary_function +class del_fun { public: void operator()(T* ptr) { delete ptr; } diff --git a/src/libs/3rdparty/cplusplus/Name.h b/src/libs/3rdparty/cplusplus/Name.h index 200ccac75d..460f0bca11 100644 --- a/src/libs/3rdparty/cplusplus/Name.h +++ b/src/libs/3rdparty/cplusplus/Name.h @@ -59,7 +59,7 @@ public: bool match(const Name *other, Matcher *matcher = 0) const; public: - struct Compare: std::binary_function { + struct Compare { bool operator()(const Name *name, const Name *other) const; }; diff --git a/src/libs/3rdparty/cplusplus/Names.h b/src/libs/3rdparty/cplusplus/Names.h index 41f3e761b4..b8d090da2f 100644 --- a/src/libs/3rdparty/cplusplus/Names.h +++ b/src/libs/3rdparty/cplusplus/Names.h @@ -101,7 +101,7 @@ public: bool isSpecialization() const { return _isSpecialization; } // Comparator needed to distinguish between two different TemplateNameId(e.g.:used in std::map) - struct Compare: std::binary_function { + struct Compare { bool operator()(const TemplateNameId *name, const TemplateNameId *other) const; }; diff --git a/src/libs/glsl/glslengine.h b/src/libs/glsl/glslengine.h index 6b126111f6..7cf6e2d164 100644 --- a/src/libs/glsl/glslengine.h +++ b/src/libs/glsl/glslengine.h @@ -71,7 +71,7 @@ template class TypeTable { public: - struct Compare: std::binary_function { + struct Compare { bool operator()(const Type &value, const Type &other) const { return value.isLessThan(&other); } diff --git a/src/libs/qtcreatorcdbext/containers.cpp b/src/libs/qtcreatorcdbext/containers.cpp index 1248fca175..128f450caf 100644 --- a/src/libs/qtcreatorcdbext/containers.cpp +++ b/src/libs/qtcreatorcdbext/containers.cpp @@ -245,7 +245,7 @@ AbstractSymbolGroupNodePtrVector linkedListChildList(SymbolGroupValue headNode, } // Helper function for linkedListChildList that returns a member by name -class MemberByName : public std::unary_function +class MemberByName { public: explicit MemberByName(const char *name) : m_name(name) {} diff --git a/src/libs/qtcreatorcdbext/stringutils.h b/src/libs/qtcreatorcdbext/stringutils.h index 89316d7e9a..e8297d44a4 100644 --- a/src/libs/qtcreatorcdbext/stringutils.h +++ b/src/libs/qtcreatorcdbext/stringutils.h @@ -52,7 +52,7 @@ void split(const std::string &s, char sep, Iterator it) // A boolean predicate that can be used for grepping sequences // of strings for a 'needle' substring. -class SubStringPredicate : public std::unary_function +class SubStringPredicate { public: explicit SubStringPredicate(const char *needle) : m_needle(needle) {} diff --git a/src/libs/qtcreatorcdbext/symbolgroup.cpp b/src/libs/qtcreatorcdbext/symbolgroup.cpp index 5ea3e8930e..52cf5d1645 100644 --- a/src/libs/qtcreatorcdbext/symbolgroup.cpp +++ b/src/libs/qtcreatorcdbext/symbolgroup.cpp @@ -251,7 +251,7 @@ std::string SymbolGroup::debug(const std::string &iname, typedef std::pair InamePathEntry; -struct InamePathEntryLessThan : public std::binary_function { +struct InamePathEntryLessThan bool operator()(const InamePathEntry &i1, const InamePathEntry& i2) const { if (i1.first < i2.first) diff --git a/src/libs/utils/smallstringview.h b/src/libs/utils/smallstringview.h index 0d8600e5de..7881500ce6 100644 --- a/src/libs/utils/smallstringview.h +++ b/src/libs/utils/smallstringview.h @@ -39,9 +39,7 @@ using enable_if_has_char_data_pointer = typename std::enable_if_t< std::is_same< std::remove_const_t< std::remove_pointer_t< - std::result_of_t< - decltype(&String::data)(String) - > + decltype(std::declval().data()) > >, char>::value , int>; -- cgit v1.2.1 From 85ffe78e9642f553b5e3eb6298eabb9cd4c651b7 Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Tue, 5 Jun 2018 14:22:26 +0200 Subject: Utils: Properly name withNtfsPermissions() Change-Id: I759e702b63f8bed9384ccbfae6345f858e50830b Reviewed-by: Eike Ziller --- src/libs/utils/fileutils.cpp | 2 +- src/libs/utils/fileutils.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/libs') diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index 776d7aa66f..001dd70a05 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -801,7 +801,7 @@ QTextStream &operator<<(QTextStream &s, const FileName &fn) #ifdef Q_OS_WIN template <> -void withNTFSPermissions(const std::function &task) +void withNtfsPermissions(const std::function &task) { qt_ntfs_permission_lookup++; task(); diff --git a/src/libs/utils/fileutils.h b/src/libs/utils/fileutils.h index b0068f4341..011069e118 100644 --- a/src/libs/utils/fileutils.h +++ b/src/libs/utils/fileutils.h @@ -51,7 +51,7 @@ class QWidget; QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug dbg, const Utils::FileName &c); -// for withNTFSPermissions +// for withNtfsPermissions #ifdef Q_OS_WIN extern Q_CORE_EXPORT int qt_ntfs_permission_lookup; #endif @@ -135,7 +135,7 @@ public: #ifdef Q_OS_WIN template -T withNTFSPermissions(const std::function &task) +T withNtfsPermissions(const std::function &task) { qt_ntfs_permission_lookup++; T result = task(); @@ -144,12 +144,12 @@ T withNTFSPermissions(const std::function &task) } template <> -QTCREATOR_UTILS_EXPORT void withNTFSPermissions(const std::function &task); +QTCREATOR_UTILS_EXPORT void withNtfsPermissions(const std::function &task); #else // Q_OS_WIN template -T withNTFSPermissions(const std::function &task) +T withNtfsPermissions(const std::function &task) { return task(); } -- cgit v1.2.1 From 97fadb5c7fae1afec11d019371d55ab8972e8062 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Tue, 5 Jun 2018 23:18:16 +0300 Subject: CDB: Fix compilation This amends commit f8e88e8ce45a462f27d274c654e31a67032da757. Change-Id: Iec2e553c1e63fa6e25301d04eba0c7ad42f14d66 Reviewed-by: Christian Stenger --- src/libs/qtcreatorcdbext/symbolgroup.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libs') diff --git a/src/libs/qtcreatorcdbext/symbolgroup.cpp b/src/libs/qtcreatorcdbext/symbolgroup.cpp index 52cf5d1645..8404f0d77c 100644 --- a/src/libs/qtcreatorcdbext/symbolgroup.cpp +++ b/src/libs/qtcreatorcdbext/symbolgroup.cpp @@ -251,7 +251,7 @@ std::string SymbolGroup::debug(const std::string &iname, typedef std::pair InamePathEntry; -struct InamePathEntryLessThan +struct InamePathEntryLessThan { bool operator()(const InamePathEntry &i1, const InamePathEntry& i2) const { if (i1.first < i2.first) -- cgit v1.2.1