From 15a1266d501829e9c5d1ca6a0fa3ba3effe455d9 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Fri, 3 Jul 2020 16:35:49 +0200 Subject: [PATCH] clangbackend: Do not handle built-in types specially ... when collecing tooltips. The more general functions provide more information, such as constness. Fixes: QTCREATORBUG-14950 Change-Id: I6d0a890a695e19e9754b5538ba092a188a3bbbb0 Reviewed-by: Marco Bubke --- .../clangbackend/source/clangtooltipinfocollector.cpp | 3 --- tests/unit/unittest/clangtooltipinfo-test.cpp | 10 ++++++++++ tests/unit/unittest/data/tooltipinfo.cpp | 8 ++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/tools/clangbackend/source/clangtooltipinfocollector.cpp b/src/tools/clangbackend/source/clangtooltipinfocollector.cpp index a4ab626a8a4..af28c7a5a9f 100644 --- a/src/tools/clangbackend/source/clangtooltipinfocollector.cpp +++ b/src/tools/clangbackend/source/clangtooltipinfocollector.cpp @@ -252,9 +252,6 @@ Utf8String ToolTipInfoCollector::text(const Cursor &cursor, const Cursor &refere if (referenced.isFunctionLike() || referenced.kind() == CXCursor_Constructor) return textForFunctionLike(referenced); - if (referenced.type().canonical().isBuiltinType()) - return referenced.type().canonical().builtinTypeToString(); - if (referenced.kind() == CXCursor_VarDecl) return referenced.type().spelling(); // e.g. "Zii" diff --git a/tests/unit/unittest/clangtooltipinfo-test.cpp b/tests/unit/unittest/clangtooltipinfo-test.cpp index 26b6596cc5d..0c9db57dc34 100644 --- a/tests/unit/unittest/clangtooltipinfo-test.cpp +++ b/tests/unit/unittest/clangtooltipinfo-test.cpp @@ -115,6 +115,16 @@ TEST_F(ToolTipInfo, LocalVariableInt) ASSERT_THAT(actual, IsToolTip(::ToolTipInfo(Utf8StringLiteral("int")))); } +TEST_F(ToolTipInfo, LocalVariableConstInt) +{ + ASSERT_THAT(tooltip(211, 19), IsToolTip(::ToolTipInfo(Utf8StringLiteral("const int")))); +} + +TEST_F(ToolTipInfo, FileScopeVariableConstInt) +{ + ASSERT_THAT(tooltip(206, 11), IsToolTip(::ToolTipInfo(Utf8StringLiteral("const int")))); +} + TEST_F(ToolTipInfo, LocalVariablePointerToConstInt) { const ::ToolTipInfo actual = tooltip(4, 5); diff --git a/tests/unit/unittest/data/tooltipinfo.cpp b/tests/unit/unittest/data/tooltipinfo.cpp index 6844a823cc5..bc1f17066ef 100644 --- a/tests/unit/unittest/data/tooltipinfo.cpp +++ b/tests/unit/unittest/data/tooltipinfo.cpp @@ -202,3 +202,11 @@ Nuu **pointers(Nuu **p1) static constexpr int calcValue() { return 1 + 2; } const auto val = calcValue() + sizeof(char); + +const int zero = 0; + +static void func() +{ + const int i = 5; + const int j = i; +}