Clang: Fix infinite loop when resolving pointer type

Fixes: QTCREATORBUG-22010
Change-Id: I5a2932089e9f7fb1e283635e228192fdb7e59cab
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Nikolai Kosjar
2019-02-21 09:00:47 +01:00
parent 00ee1ca7e0
commit c00c9d19fa
3 changed files with 9 additions and 2 deletions

View File

@@ -36,6 +36,7 @@
#include <clangsupport/sourcerangecontainer.h> #include <clangsupport/sourcerangecontainer.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/textfileformat.h> #include <utils/textfileformat.h>
#include <utils/qtcassert.h>
#include <utf8string.h> #include <utf8string.h>
@@ -392,7 +393,7 @@ static bool isBuiltinOrPointerToBuiltin(const Type &type)
// TODO: Simplify // TODO: Simplify
// TODO: Test with ** // TODO: Test with **
while (theType.pointeeType().isValid()) { while (theType.pointeeType().isValid() && theType != theType.pointeeType()) {
theType = theType.pointeeType(); theType = theType.pointeeType();
if (theType.isBuiltinType()) if (theType.isBuiltinType())
return true; return true;
@@ -436,7 +437,7 @@ ToolTipInfo ToolTipInfoCollector::qDocInfo(const Cursor &cursor) const
} }
Type type = cursor.type(); Type type = cursor.type();
while (type.pointeeType().isValid()) while (type.pointeeType().isValid() && type != type.pointeeType())
type = type.pointeeType(); type = type.pointeeType();
const Cursor typeCursor = type.declaration(); const Cursor typeCursor = type.declaration();

View File

@@ -245,6 +245,11 @@ bool operator==(Type first, Type second)
return clang_equalTypes(first.m_cxType, second.m_cxType); 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) std::ostream &operator<<(std::ostream &os, CXTypeKind typeKind)
{ {
ClangString typeKindSpelling(clang_getTypeKindSpelling(typeKind)); ClangString typeKindSpelling(clang_getTypeKindSpelling(typeKind));

View File

@@ -81,6 +81,7 @@ private:
}; };
bool operator==(Type first, Type second); 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, CXTypeKind typeKind);
std::ostream &operator<<(std::ostream &os, const Type &type); std::ostream &operator<<(std::ostream &os, const Type &type);