Often, there are assignments to muteErrors here, that are never read. It seems like there is a (future?) intention here. So for now, disable warnings from clang-tidy. TODO(Alain): remove N0LINTBEGIN, run .github/bin/run-clang-tidy.sh and fix the intended places. NOLINTBEGIN(*.DeadStores)
| 70 | // |
| 71 | // NOLINTBEGIN(*.DeadStores) |
| 72 | Value* ExprBuilder::evalExpr(const FileContent* fC, NodeId parent, |
| 73 | ValuedComponentI* instance, bool muteErrors) { |
| 74 | Value* value = m_valueFactory.newLValue(); |
| 75 | NodeId child = fC->Child(parent); |
| 76 | VObjectType type = fC->Type(parent); |
| 77 | switch (type) { |
| 78 | case VObjectType::paPackage_scope: { |
| 79 | Value* sval = nullptr; |
| 80 | const std::string_view packageName = fC->SymName(child); |
| 81 | const std::string_view name = fC->SymName(fC->Sibling(parent)); |
| 82 | if (m_design) { |
| 83 | Package* pack = m_design->getPackage(packageName); |
| 84 | if (pack) { |
| 85 | if (pack->getComplexValue(name)) { |
| 86 | muteErrors = true; |
| 87 | value->setInvalid(); |
| 88 | break; |
| 89 | } else { |
| 90 | sval = pack->getValue(name); |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | std::string fullName; |
| 95 | if (sval == nullptr) fullName = StrCat(packageName, "::", name); |
| 96 | if (sval == nullptr) { |
| 97 | if (muteErrors == false) { |
| 98 | Location loc(fC->getFileId(parent), fC->Line(parent), |
| 99 | fC->Column(parent), m_symbols->registerSymbol(fullName)); |
| 100 | Error err(ErrorDefinition::ELAB_UNDEF_VARIABLE, loc); |
| 101 | m_errors->addError(err); |
| 102 | } |
| 103 | value->setInvalid(); |
| 104 | return value; |
| 105 | } |
| 106 | if (sval->getType() == Value::Type::String || |
| 107 | sval->getType() == Value::Type::Hexadecimal) { |
| 108 | m_valueFactory.deleteValue(value); |
| 109 | value = clone(sval); |
| 110 | } else { |
| 111 | value->u_plus(sval); |
| 112 | } |
| 113 | return value; |
| 114 | } |
| 115 | default: |
| 116 | break; |
| 117 | } |
| 118 | |
| 119 | if (child) { |
| 120 | VObjectType childType = fC->Type(child); |
| 121 | switch (childType) { |
| 122 | case VObjectType::paIncDec_PlusPlus: { |
| 123 | // Pre increment |
| 124 | NodeId sibling = fC->Sibling(child); |
| 125 | Value* tmp = evalExpr(fC, sibling, instance, muteErrors); |
| 126 | value->u_plus(tmp); |
| 127 | value->incr(); |
| 128 | m_valueFactory.deleteValue(tmp); |
| 129 | break; |