Internals: Minor coverage improvement as followup to (#7128 followup) (#7184)

This commit is contained in:
em2machine 2026-03-03 11:13:32 -05:00 committed by GitHub
parent f232449252
commit 5f3d475736
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 32 additions and 20 deletions

View File

@ -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");

View File

@ -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,