From d3d2e16137dccf9269f1f2d017606be24ab31d39 Mon Sep 17 00:00:00 2001 From: IOBYTE Date: Tue, 9 Feb 2021 08:19:01 -0500 Subject: [PATCH] fix hang from f48e195c31f8f7de60826036f2fc797c9e7f942c (fix #10136 TODO test (#3117)) (#3120) Co-authored-by: Robert Reif --- lib/tokenize.cpp | 2 +- test/testsimplifyusing.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index d71a2c3f5..cc97f836e 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1812,7 +1812,7 @@ namespace { const ScopeInfo3 * tempScope = this; while (tempScope) { for (const auto & child : tempScope->children) { - if (child.name == scope || child.fullName == scope) + if (child.type == Record && (child.name == scope || child.fullName == scope)) return &child; } diff --git a/test/testsimplifyusing.cpp b/test/testsimplifyusing.cpp index 88d9f68d4..394ae2668 100644 --- a/test/testsimplifyusing.cpp +++ b/test/testsimplifyusing.cpp @@ -974,6 +974,33 @@ private: ASSERT_EQUALS(exp, tok(code, true)); ASSERT_EQUALS("", errout.str()); } + { + const char code[] = "foo::ResultCodes_e\n" + "GemImpl::setR(const ::foo::s _ipSource)\n" + "{\n" + " M3_LOG_EE_DEBUG();\n" + " using MLSource = foo::s::Literal;\n" + " auto ret = foo::ResultCodes_e::NO_ERROR;\n" + " M3_LOG_INFO(\"foo(\" << static_cast(_ipSource) << \")\");\n" + " return ret;\n" + "}\n" + "foo::ResultCodes_e\n" + "GemImpl::getF(::foo::s &_ipSource)\n" + "{\n" + " M3_LOG_EE_DEBUG();\n" + " auto ret = foo::ResultCodes_e::NO_ERROR;\n" + " return ret;\n" + "}\n" + "foo::ResultCodes_e\n" + "GemImpl::setF(const ::foo::s _ipSource)\n" + "{\n" + " M3_LOG_EE_DEBUG();\n" + " using MLSource = foo::s::Literal;\n" + " auto ret = foo::ResultCodes_e::NO_ERROR;\n" + " return ret;\n" + "}"; + tok(code, true); // don't crash + } } void simplifyUsing10171() {