From 5f3d47573640080682dd5a2a915fbb605babfc88 Mon Sep 17 00:00:00 2001 From: em2machine <92717390+em2machine@users.noreply.github.com> Date: Tue, 3 Mar 2026 11:13:32 -0500 Subject: [PATCH] Internals: Minor coverage improvement as followup to (#7128 followup) (#7184) --- src/V3LinkDot.cpp | 3 ++- src/V3LinkDotIfaceCapture.cpp | 49 +++++++++++++++++++++-------------- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index a482a04f5..14f0be075 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -5582,7 +5582,8 @@ class LinkDotResolveVisitor final : public VNVisitor { // typedef is first linked. if (V3LinkDotIfaceCapture::enabled()) { if (AstRefDType* const resolvedRefp = VN_CAST(resolvedDTypep, RefDType)) { - if (VL_UNCOVERABLE(VN_IS(resolvedRefp->user2p(), Cell))) { + if (VL_UNCOVERABLE( + VN_IS(resolvedRefp->user2p(), Cell))) { // LCOV_EXCL_LINE resolvedRefp->v3fatalSrc( // LCOV_EXCL_LINE "typeofp resolved RefDType has Cell in user2p;" " expected to be captured already"); diff --git a/src/V3LinkDotIfaceCapture.cpp b/src/V3LinkDotIfaceCapture.cpp index 24e98721b..dde304e2b 100644 --- a/src/V3LinkDotIfaceCapture.cpp +++ b/src/V3LinkDotIfaceCapture.cpp @@ -139,41 +139,52 @@ string resolveOwnerName(const string& hint, AstNode* nodep) { } // namespace AstTypedef* V3LinkDotIfaceCapture::findTypedefInModule(AstNodeModule* modp, const string& name) { + AstTypedef* resultp = nullptr; const StmtNameMap& cache = getOrBuild(modp); const auto it = cache.m_byName.find(name); - if (it == cache.m_byName.end()) return nullptr; - for (AstNode* nodep : it->second) { - if (AstTypedef* const tdp = VN_CAST(nodep, Typedef)) return tdp; + if (!(it == cache.m_byName.end())) { + for (AstNode* nodep : it->second) { + if (AstTypedef* const tdp = VN_CAST(nodep, Typedef)) { + resultp = tdp; + break; + } + } } - // Cache has entry for this name but no Typedef - unexpected. - v3fatalSrc("findTypedefInModule: name '" << name << "' found in " << modp->prettyNameQ() - << " but no Typedef node"); - return nullptr; // LCOV_EXCL_LINE + return resultp; } AstNodeDType* V3LinkDotIfaceCapture::findDTypeInModule(AstNodeModule* modp, const string& name, VNType type) { + + AstNodeDType* resultp = nullptr; const StmtNameMap& cache = getOrBuild(modp); const auto it = cache.m_byName.find(name); - if (it == cache.m_byName.end()) return nullptr; - for (AstNode* nodep : it->second) { - if (AstNodeDType* const dtp = VN_CAST(nodep, NodeDType)) { - if (dtp->type() == type) return dtp; + if (!(it == cache.m_byName.end())) { + for (AstNode* nodep : it->second) { + if (AstNodeDType* const dtp = VN_CAST(nodep, NodeDType)) { + if (dtp->type() == type) { + resultp = dtp; + break; + } + } } } - // Cache has entry for this name but no matching DType - unexpected. - v3fatalSrc("findDTypeInModule: name '" << name << "' found in " << modp->prettyNameQ() - << " but no matching DType"); - return nullptr; // LCOV_EXCL_LINE + return resultp; } AstParamTypeDType* V3LinkDotIfaceCapture::findParamTypeInModule(AstNodeModule* modp, const string& name) { + + AstParamTypeDType* resultp = nullptr; const StmtNameMap& cache = getOrBuild(modp); const auto it = cache.m_byName.find(name); - if (it == cache.m_byName.end()) return nullptr; - for (AstNode* nodep : it->second) { - if (AstParamTypeDType* const ptdp = VN_CAST(nodep, ParamTypeDType)) return ptdp; + if (!(it == cache.m_byName.end())) { + for (AstNode* nodep : it->second) { + if (AstParamTypeDType* const ptdp = VN_CAST(nodep, ParamTypeDType)) { + resultp = ptdp; + break; + } + } } - return nullptr; + return resultp; } AstNodeDType* V3LinkDotIfaceCapture::findDTypeByPrettyName(AstNodeModule* modp,