From e60f52ee0cd75f9472656ee626568238cf94d8aa Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 7 Sep 2025 17:18:23 -0400 Subject: [PATCH] Internals: Add CCall assertion --- src/V3AstNodeExpr.h | 5 ++++- src/V3DfgContext.h | 9 +++------ src/V3EmitCBase.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/V3AstNodeExpr.h b/src/V3AstNodeExpr.h index 85b59620a..cf45eaf21 100644 --- a/src/V3AstNodeExpr.h +++ b/src/V3AstNodeExpr.h @@ -4512,7 +4512,9 @@ class AstCCall final : public AstNodeCCall { // pointer (e.g.: 'this') public: AstCCall(FileLine* fl, AstCFunc* funcp, AstNodeExpr* argsp = nullptr) - : ASTGEN_SUPER_CCall(fl, funcp, argsp) {} + : ASTGEN_SUPER_CCall(fl, funcp, argsp) { + UASSERT_OBJ(funcp, this, "CCall created calling null function"); + } ASTGEN_MEMBERS_AstCCall; const VSelfPointerText& selfPointer() const { return m_selfPointer; } @@ -4528,6 +4530,7 @@ public: AstCMethodCall(FileLine* fl, AstNodeExpr* fromp, AstCFunc* funcp, AstNodeExpr* argsp = nullptr) : ASTGEN_SUPER_CMethodCall(fl, funcp, argsp) { this->fromp(fromp); + UASSERT_OBJ(funcp, this, "CMethodCall created calling null function"); } ASTGEN_MEMBERS_AstCMethodCall; }; diff --git a/src/V3DfgContext.h b/src/V3DfgContext.h index 42cf6e69e..b67516c74 100644 --- a/src/V3DfgContext.h +++ b/src/V3DfgContext.h @@ -33,9 +33,8 @@ class V3DfgContext; -////////////////////////////////////////////////////////////////////////////// +//###################################################################### // Base class for all context objects -////////////////////////////////////////////////////////////////////////////// class V3DfgSubContext VL_NOT_FINAL { V3DfgContext& m_ctx; // The whole context @@ -59,9 +58,8 @@ public: const std::string& label() const { return m_label; } }; -////////////////////////////////////////////////////////////////////////////// +//###################################################################### // Contexts for various algorithms - keep sorted -////////////////////////////////////////////////////////////////////////////// class V3DfgAstToDfgContext final : public V3DfgSubContext { // Only V3DfgContext can create an instance @@ -334,9 +332,8 @@ private: } }; -////////////////////////////////////////////////////////////////////////////// +//###################################################################### // Top level V3DfgContext -////////////////////////////////////////////////////////////////////////////// class V3DfgContext final { const std::string m_label; // Label to add to stats, etc. diff --git a/src/V3EmitCBase.cpp b/src/V3EmitCBase.cpp index a6530a2d1..166955a2d 100644 --- a/src/V3EmitCBase.cpp +++ b/src/V3EmitCBase.cpp @@ -127,7 +127,7 @@ string EmitCBaseVisitorConst::cFuncArgs(const AstCFunc* nodep) { for (const AstNode* stmtp = nodep->argsp(); stmtp; stmtp = stmtp->nextp()) { if (const AstVar* const portp = VN_CAST(stmtp, Var)) { if (portp->isIO() && !portp->isFuncReturn()) { - if (args != "") args += ", "; + if (!args.empty()) args += ", "; if (nodep->dpiImportPrototype() || nodep->dpiExportDispatcher()) { args += portp->dpiArgType(true, false); } else if (nodep->funcPublic()) {