mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 10:03:44 +02:00
Internals: Improve cppcheck flow and fix up issues (#6311)
Added cppcheck-suppressions.txt in the repo root. You can add new patterns in there instead of having to parse the XML output. Also configure to add the -D__GNUC__ preprocessor macro, which makes it understand UASSERT (it understands the 'noreturn' function attribute). Added some case by case specific suppressions and fixed up other code, especially in V3Ast*h and V3Dfg*.h, including code generated by astgen that had some no-ops that irks cppcheck. One thing it does not seem to like is `const` class members with default initializers in the class. It will assume that's always the value, even if overridden in the constructor. We had few so removed them. With that a lot of files in `src/` are now clean or only have a handful of issues. Therefore, I have also deleted cppcheck_filtered, and made it produce human readable output straight to the terminal. Regarding cleaning up the reported nits, I kind of got bored after V3[A-E] so pausing here. Apologies for the merge conflicts. Tested with cppcheck 2.13.0
This commit is contained in:
+8
-8
@@ -724,28 +724,28 @@ class EmitCTrace final : EmitCFunc {
|
||||
&& m_typeSplitSize >= v3Global.opt.outputSplitCTrace();
|
||||
}
|
||||
|
||||
bool emitTraceIsScBv(AstTraceInc* nodep) {
|
||||
bool emitTraceIsScBv(const AstTraceInc* nodep) {
|
||||
const AstVarRef* const varrefp = VN_CAST(nodep->declp()->valuep(), VarRef);
|
||||
if (!varrefp) return false;
|
||||
AstVar* const varp = varrefp->varp();
|
||||
const AstVar* const varp = varrefp->varp();
|
||||
return varp->isSc() && varp->isScBv();
|
||||
}
|
||||
|
||||
bool emitTraceIsScBigUint(AstTraceInc* nodep) {
|
||||
bool emitTraceIsScBigUint(const AstTraceInc* nodep) {
|
||||
const AstVarRef* const varrefp = VN_CAST(nodep->declp()->valuep(), VarRef);
|
||||
if (!varrefp) return false;
|
||||
AstVar* const varp = varrefp->varp();
|
||||
const AstVar* const varp = varrefp->varp();
|
||||
return varp->isSc() && varp->isScBigUint();
|
||||
}
|
||||
|
||||
bool emitTraceIsScUint(AstTraceInc* nodep) {
|
||||
bool emitTraceIsScUint(const AstTraceInc* nodep) {
|
||||
const AstVarRef* const varrefp = VN_CAST(nodep->declp()->valuep(), VarRef);
|
||||
if (!varrefp) return false;
|
||||
AstVar* const varp = varrefp->varp();
|
||||
const AstVar* const varp = varrefp->varp();
|
||||
return varp->isSc() && (varp->isScUint() || varp->isScUintBool());
|
||||
}
|
||||
|
||||
void emitTraceInitOne(AstTraceDecl* nodep, int enumNum) {
|
||||
void emitTraceInitOne(const AstTraceDecl* nodep, int enumNum) {
|
||||
if (nodep->dtypep()->basicp()->isDouble()) {
|
||||
puts("tracep->declDouble(");
|
||||
} else if (nodep->isWide()) {
|
||||
@@ -906,7 +906,7 @@ class EmitCTrace final : EmitCFunc {
|
||||
|
||||
void emitTraceValue(AstTraceInc* nodep, int arrayindex) {
|
||||
if (AstVarRef* const varrefp = VN_CAST(nodep->valuep(), VarRef)) {
|
||||
AstVar* const varp = varrefp->varp();
|
||||
const AstVar* const varp = varrefp->varp();
|
||||
if (varp->isEvent()) puts("&");
|
||||
puts("(");
|
||||
if (emitTraceIsScBigUint(nodep)) {
|
||||
|
||||
Reference in New Issue
Block a user