diff options
author | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2019-02-21 09:00:47 +0100 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2019-02-21 09:38:28 +0000 |
commit | c00c9d19fa7a8dd141d610b1c771a5acd2f1d952 (patch) | |
tree | 515db2c0c333c22f88fa69f1ad517a96febdbd48 | |
parent | 00ee1ca7e030d59630925decdfd14d3ed57beb69 (diff) |
Clang: Fix infinite loop when resolving pointer type
Fixes: QTCREATORBUG-22010
Change-Id: I5a2932089e9f7fb1e283635e228192fdb7e59cab
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
-rw-r--r-- | src/tools/clangbackend/source/clangtooltipinfocollector.cpp | 5 | ||||
-rw-r--r-- | src/tools/clangbackend/source/clangtype.cpp | 5 | ||||
-rw-r--r-- | src/tools/clangbackend/source/clangtype.h | 1 |
3 files changed, 9 insertions, 2 deletions
diff --git a/src/tools/clangbackend/source/clangtooltipinfocollector.cpp b/src/tools/clangbackend/source/clangtooltipinfocollector.cpp index 8eb15eb89e..beecf63bb6 100644 --- a/src/tools/clangbackend/source/clangtooltipinfocollector.cpp +++ b/src/tools/clangbackend/source/clangtooltipinfocollector.cpp @@ -36,6 +36,7 @@ #include <clangsupport/sourcerangecontainer.h> #include <utils/qtcassert.h> #include <utils/textfileformat.h> +#include <utils/qtcassert.h> #include <utf8string.h> @@ -392,7 +393,7 @@ static bool isBuiltinOrPointerToBuiltin(const Type &type) // TODO: Simplify // TODO: Test with ** - while (theType.pointeeType().isValid()) { + while (theType.pointeeType().isValid() && theType != theType.pointeeType()) { theType = theType.pointeeType(); if (theType.isBuiltinType()) return true; @@ -436,7 +437,7 @@ ToolTipInfo ToolTipInfoCollector::qDocInfo(const Cursor &cursor) const } Type type = cursor.type(); - while (type.pointeeType().isValid()) + while (type.pointeeType().isValid() && type != type.pointeeType()) type = type.pointeeType(); const Cursor typeCursor = type.declaration(); diff --git a/src/tools/clangbackend/source/clangtype.cpp b/src/tools/clangbackend/source/clangtype.cpp index 46ed23d54c..af58f71595 100644 --- a/src/tools/clangbackend/source/clangtype.cpp +++ b/src/tools/clangbackend/source/clangtype.cpp @@ -245,6 +245,11 @@ bool operator==(Type first, Type second) return clang_equalTypes(first.m_cxType, second.m_cxType); } +bool operator!=(Type first, Type second) +{ + return !operator==(first, second); +} + std::ostream &operator<<(std::ostream &os, CXTypeKind typeKind) { ClangString typeKindSpelling(clang_getTypeKindSpelling(typeKind)); diff --git a/src/tools/clangbackend/source/clangtype.h b/src/tools/clangbackend/source/clangtype.h index ed6977ee73..53953392e3 100644 --- a/src/tools/clangbackend/source/clangtype.h +++ b/src/tools/clangbackend/source/clangtype.h @@ -81,6 +81,7 @@ private: }; bool operator==(Type first, Type second); +bool operator!=(Type first, Type second); std::ostream &operator<<(std::ostream &os, CXTypeKind typeKind); std::ostream &operator<<(std::ostream &os, const Type &type); |