From c00c9d19fa7a8dd141d610b1c771a5acd2f1d952 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Thu, 21 Feb 2019 09:00:47 +0100 Subject: Clang: Fix infinite loop when resolving pointer type Fixes: QTCREATORBUG-22010 Change-Id: I5a2932089e9f7fb1e283635e228192fdb7e59cab Reviewed-by: Ivan Donchevskii --- src/tools/clangbackend/source/clangtooltipinfocollector.cpp | 5 +++-- src/tools/clangbackend/source/clangtype.cpp | 5 +++++ 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 #include #include +#include #include @@ -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); -- cgit v1.2.3