From 0d3389718ab168022aceded05930b883b5ca6851 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Tue, 12 May 2020 16:11:42 +1200 Subject: [PATCH] Make Clang-Tidy happy. --- cmake/common.cmake | 3 +++ src/generator.cpp | 45 +++++++++++++++++++------------------ src/parser.cpp | 36 +++++++++++++++--------------- src/validator.cpp | 52 +++++++++++++++++++++---------------------- tests/model/model.cpp | 2 +- 5 files changed, 71 insertions(+), 67 deletions(-) diff --git a/cmake/common.cmake b/cmake/common.cmake index 7e83ec707..c0c691f9f 100644 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -140,6 +140,7 @@ function(CONFIGURE_CLANG_AND_CLANG_TIDY_SETTINGS _TARGET) -cert-err58-cpp cppcoreguidelines-* -cppcoreguidelines-avoid-magic-numbers + -cppcoreguidelines-init-variables -cppcoreguidelines-owning-memory -cppcoreguidelines-pro-type-reinterpret-cast ${_NO_CPPCOREGUIDELINES_PRO_TYPE_VARARG} @@ -159,6 +160,7 @@ function(CONFIGURE_CLANG_AND_CLANG_TIDY_SETTINGS _TARGET) -hicpp-special-member-functions ${_NO_HICPP_VARARG} llvm-* + -llvm-qualified-auto -llvm-header-guard misc-* -misc-non-private-member-variables-in-classes @@ -172,6 +174,7 @@ function(CONFIGURE_CLANG_AND_CLANG_TIDY_SETTINGS _TARGET) readability-* -readability-convert-member-functions-to-static -readability-magic-numbers + -readability-qualified-auto ) string(REPLACE ";" "," _CLANG_TIDY_CHECKS "${_CLANG_TIDY_CHECKS}") diff --git a/src/generator.cpp b/src/generator.cpp index 81c7a50fa..5bdc8298c 100644 --- a/src/generator.cpp +++ b/src/generator.cpp @@ -641,7 +641,7 @@ struct Generator::GeneratorImpl void addOriginCommentCode(std::string &code); - void addInterfaceHeaderCode(std::string &code); + void addInterfaceHeaderCode(std::string &code) const; void addImplementationHeaderCode(std::string &code); void addVersionAndLibcellmlVersionCode(std::string &code, @@ -650,7 +650,7 @@ struct Generator::GeneratorImpl void addStateAndVariableCountCode(std::string &code, bool interface = false); - void addVariableTypeObjectCode(std::string &code); + void addVariableTypeObjectCode(std::string &code) const; std::string generateVariableInfoObjectCode(const std::string &objectString); @@ -661,20 +661,20 @@ struct Generator::GeneratorImpl const std::string &units, const std::string &component); - void addInterfaceVoiStateAndVariableInfoCode(std::string &code); + void addInterfaceVoiStateAndVariableInfoCode(std::string &code) const; void addImplementationVoiInfoCode(std::string &code); void addImplementationStateInfoCode(std::string &code); void addImplementationVariableInfoCode(std::string &code); - void addArithmeticFunctionsCode(std::string &code); - void addTrigonometricFunctionsCode(std::string &code); + void addArithmeticFunctionsCode(std::string &code) const; + void addTrigonometricFunctionsCode(std::string &code) const; - void addInterfaceCreateDeleteArrayMethodsCode(std::string &code); - void addImplementationCreateStatesArrayMethodCode(std::string &code); - void addImplementationCreateVariablesArrayMethodCode(std::string &code); - void addImplementationDeleteArrayMethodCode(std::string &code); + void addInterfaceCreateDeleteArrayMethodsCode(std::string &code) const; + void addImplementationCreateStatesArrayMethodCode(std::string &code) const; + void addImplementationCreateVariablesArrayMethodCode(std::string &code) const; + void addImplementationDeleteArrayMethodCode(std::string &code) const; - std::string generateMethodBodyCode(const std::string &methodBody); + std::string generateMethodBodyCode(const std::string &methodBody) const; std::string generateDoubleCode(const std::string &value); std::string generateVariableNameCode(const VariablePtr &variable, @@ -697,7 +697,7 @@ struct Generator::GeneratorImpl std::vector &remainingEquations, bool onlyStateRateBasedEquations = false); - void addInterfaceComputeModelMethodsCode(std::string &code); + void addInterfaceComputeModelMethodsCode(std::string &code) const; void addImplementationInitializeStatesAndConstantsMethodCode(std::string &code, std::vector &remainingEquations); void addImplementationComputeComputedConstantsMethodCode(std::string &code, @@ -1987,7 +1987,7 @@ void Generator::GeneratorImpl::addOriginCommentCode(std::string &code) } } -void Generator::GeneratorImpl::addInterfaceHeaderCode(std::string &code) +void Generator::GeneratorImpl::addInterfaceHeaderCode(std::string &code) const { if (!mProfile->interfaceHeaderString().empty()) { if (!code.empty()) { @@ -2073,7 +2073,7 @@ void Generator::GeneratorImpl::addStateAndVariableCountCode(std::string &code, code += stateAndVariableCountCode; } -void Generator::GeneratorImpl::addVariableTypeObjectCode(std::string &code) +void Generator::GeneratorImpl::addVariableTypeObjectCode(std::string &code) const { if (!mProfile->variableTypeObjectString().empty()) { if (!code.empty()) { @@ -2140,7 +2140,7 @@ std::string Generator::GeneratorImpl::generateVariableInfoEntryCode(const std::s "", component); } -void Generator::GeneratorImpl::addInterfaceVoiStateAndVariableInfoCode(std::string &code) +void Generator::GeneratorImpl::addInterfaceVoiStateAndVariableInfoCode(std::string &code) const { std::string interfaceVoiStateAndVariableInfoCode; @@ -2257,7 +2257,7 @@ void Generator::GeneratorImpl::addImplementationVariableInfoCode(std::string &co } } -void Generator::GeneratorImpl::addArithmeticFunctionsCode(std::string &code) +void Generator::GeneratorImpl::addArithmeticFunctionsCode(std::string &code) const { if (mNeedEq && !mProfile->hasEqOperator() && !mProfile->eqFunctionString().empty()) { @@ -2368,7 +2368,7 @@ void Generator::GeneratorImpl::addArithmeticFunctionsCode(std::string &code) } } -void Generator::GeneratorImpl::addTrigonometricFunctionsCode(std::string &code) +void Generator::GeneratorImpl::addTrigonometricFunctionsCode(std::string &code) const { if (mNeedSec && !mProfile->secFunctionString().empty()) { @@ -2479,7 +2479,7 @@ void Generator::GeneratorImpl::addTrigonometricFunctionsCode(std::string &code) } } -void Generator::GeneratorImpl::addInterfaceCreateDeleteArrayMethodsCode(std::string &code) +void Generator::GeneratorImpl::addInterfaceCreateDeleteArrayMethodsCode(std::string &code) const { std::string interfaceCreateDeleteArraysCode; @@ -2502,7 +2502,7 @@ void Generator::GeneratorImpl::addInterfaceCreateDeleteArrayMethodsCode(std::str code += interfaceCreateDeleteArraysCode; } -void Generator::GeneratorImpl::addImplementationCreateStatesArrayMethodCode(std::string &code) +void Generator::GeneratorImpl::addImplementationCreateStatesArrayMethodCode(std::string &code) const { if (!mProfile->implementationCreateStatesArrayMethodString().empty()) { if (!code.empty()) { @@ -2513,7 +2513,7 @@ void Generator::GeneratorImpl::addImplementationCreateStatesArrayMethodCode(std: } } -void Generator::GeneratorImpl::addImplementationCreateVariablesArrayMethodCode(std::string &code) +void Generator::GeneratorImpl::addImplementationCreateVariablesArrayMethodCode(std::string &code) const { if (!mProfile->implementationCreateVariablesArrayMethodString().empty()) { if (!code.empty()) { @@ -2524,7 +2524,7 @@ void Generator::GeneratorImpl::addImplementationCreateVariablesArrayMethodCode(s } } -void Generator::GeneratorImpl::addImplementationDeleteArrayMethodCode(std::string &code) +void Generator::GeneratorImpl::addImplementationDeleteArrayMethodCode(std::string &code) const { if (!mProfile->implementationDeleteArrayMethodString().empty()) { if (!code.empty()) { @@ -2535,7 +2535,7 @@ void Generator::GeneratorImpl::addImplementationDeleteArrayMethodCode(std::strin } } -std::string Generator::GeneratorImpl::generateMethodBodyCode(const std::string &methodBody) +std::string Generator::GeneratorImpl::generateMethodBodyCode(const std::string &methodBody) const { return methodBody.empty() ? mProfile->emptyMethodString().empty() ? @@ -3327,7 +3327,8 @@ std::string Generator::GeneratorImpl::generateEquationCode(const GeneratorEquati return res; } -void Generator::GeneratorImpl::addInterfaceComputeModelMethodsCode(std::string &code) + +void Generator::GeneratorImpl::addInterfaceComputeModelMethodsCode(std::string &code) const { std::string interfaceComputeModelMethodsCode; diff --git a/src/parser.cpp b/src/parser.cpp index 5ab84b125..8f09fb936 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -80,7 +80,7 @@ struct Parser::ParserImpl * @param component The @c ComponentPtr to update. * @param node The @c XmlNodePtr to parse and update the @p component with. */ - void loadComponent(const ComponentPtr &component, const XmlNodePtr &node); + void loadComponent(const ComponentPtr &component, const XmlNodePtr &node) const; /** * @brief Update the @p model with a connection parsed from @p node. @@ -92,7 +92,7 @@ struct Parser::ParserImpl * @param model The @c ModelPtr to update. * @param node The @c XmlNodePtr to parse and update the model with. */ - void loadConnection(const ModelPtr &model, const XmlNodePtr &node); + void loadConnection(const ModelPtr &model, const XmlNodePtr &node) const; /** * @brief Update the @p model with an encapsulation parsed from @p node. @@ -132,7 +132,7 @@ struct Parser::ParserImpl * @param model The @c ModelPtr to add imported components/units to. * @param node The @c XmlNodePtr to parse and update the @p import source with. */ - void loadImport(const ImportSourcePtr &importSource, const ModelPtr &model, const XmlNodePtr &node); + void loadImport(const ImportSourcePtr &importSource, const ModelPtr &model, const XmlNodePtr &node) const; /** * @brief Update the @p units with attributes parsed from @p node. @@ -144,7 +144,7 @@ struct Parser::ParserImpl * @param units The @c UnitsPtr to update. * @param node The @c XmlNodePtr to parse and update the @p units with. */ - void loadUnits(const UnitsPtr &units, const XmlNodePtr &node); + void loadUnits(const UnitsPtr &units, const XmlNodePtr &node) const; /** * @brief Update the @p units with a unit parsed from @p node. @@ -156,7 +156,7 @@ struct Parser::ParserImpl * @param units The @c UnitsPtr to update. * @param node The unit @c XmlNodePtr to parse and update the @p units with. */ - void loadUnit(const UnitsPtr &units, const XmlNodePtr &node); + void loadUnit(const UnitsPtr &units, const XmlNodePtr &node) const; /** * @brief Update the @p variable with attributes parsed from @p node. @@ -168,7 +168,7 @@ struct Parser::ParserImpl * @param variable The @c VariablePtr to update. * @param node The @c XmlNodePtr to parse and update the @p variable with. */ - void loadVariable(const VariablePtr &variable, const XmlNodePtr &node); + void loadVariable(const VariablePtr &variable, const XmlNodePtr &node) const; /** * @brief Update the @p reset with attributes parsed from the @p node. @@ -181,7 +181,7 @@ struct Parser::ParserImpl * @param component The @c ComponentPtr the reset belongs to. * @param node The @c XmlNodePtr to parse and update the @p variable with. */ - void loadReset(const ResetPtr &reset, const ComponentPtr &component, const XmlNodePtr &node); + void loadReset(const ResetPtr &reset, const ComponentPtr &component, const XmlNodePtr &node) const; /** * @brief Update the @p reset with the child parsed from the @p node. @@ -195,7 +195,7 @@ struct Parser::ParserImpl * @param component The @c ComponentPtr the reset belongs to. * @param node The @c XmlNodePtr to parse and update the @p variable with. */ - void loadResetChild(const std::string &childType, const ResetPtr &reset, const ComponentPtr &component, const XmlNodePtr &node); + void loadResetChild(const std::string &childType, const ResetPtr &reset, const ComponentPtr &component, const XmlNodePtr &node) const; /** * @brief Checks the multiplicity of the @p childType. @@ -209,7 +209,7 @@ struct Parser::ParserImpl * @param reset The @c ResetPtr to update. * @param component The @c ComponentPtr the reset belongs to. */ - void checkResetChildMultiplicity(size_t count, const std::string &childType, const ResetPtr &reset, const ComponentPtr &component); + void checkResetChildMultiplicity(size_t count, const std::string &childType, const ResetPtr &reset, const ComponentPtr &component) const; }; Parser::Parser() @@ -481,7 +481,7 @@ std::string cleanMath(const std::string &math) return cleanMath; } -void Parser::ParserImpl::loadComponent(const ComponentPtr &component, const XmlNodePtr &node) +void Parser::ParserImpl::loadComponent(const ComponentPtr &component, const XmlNodePtr &node) const { XmlAttributePtr attribute = node->firstAttribute(); while (attribute) { @@ -544,7 +544,7 @@ void Parser::ParserImpl::loadComponent(const ComponentPtr &component, const XmlN } } -void Parser::ParserImpl::loadUnits(const UnitsPtr &units, const XmlNodePtr &node) +void Parser::ParserImpl::loadUnits(const UnitsPtr &units, const XmlNodePtr &node) const { XmlAttributePtr attribute = node->firstAttribute(); while (attribute) { @@ -587,7 +587,7 @@ void Parser::ParserImpl::loadUnits(const UnitsPtr &units, const XmlNodePtr &node } } -void Parser::ParserImpl::loadUnit(const UnitsPtr &units, const XmlNodePtr &node) +void Parser::ParserImpl::loadUnit(const UnitsPtr &units, const XmlNodePtr &node) const { std::string reference; std::string prefix; @@ -674,7 +674,7 @@ void Parser::ParserImpl::loadUnit(const UnitsPtr &units, const XmlNodePtr &node) units->addUnit(reference, prefix, exponent, multiplier, id); } -void Parser::ParserImpl::loadVariable(const VariablePtr &variable, const XmlNodePtr &node) +void Parser::ParserImpl::loadVariable(const VariablePtr &variable, const XmlNodePtr &node) const { // A variable should not have any children. XmlNodePtr childNode = node->firstChild(); @@ -720,7 +720,7 @@ void Parser::ParserImpl::loadVariable(const VariablePtr &variable, const XmlNode } } -void Parser::ParserImpl::loadConnection(const ModelPtr &model, const XmlNodePtr &node) +void Parser::ParserImpl::loadConnection(const ModelPtr &model, const XmlNodePtr &node) const { // Define types for variable and component pairs. using NamePair = std::pair; @@ -1128,7 +1128,7 @@ void Parser::ParserImpl::loadEncapsulation(const ModelPtr &model, const XmlNodeP } } -void Parser::ParserImpl::loadImport(const ImportSourcePtr &importSource, const ModelPtr &model, const XmlNodePtr &node) +void Parser::ParserImpl::loadImport(const ImportSourcePtr &importSource, const ModelPtr &model, const XmlNodePtr &node) const { XmlAttributePtr attribute = node->firstAttribute(); while (attribute) { @@ -1217,7 +1217,7 @@ void Parser::ParserImpl::loadImport(const ImportSourcePtr &importSource, const M } } -void Parser::ParserImpl::loadResetChild(const std::string &childType, const ResetPtr &reset, const ComponentPtr &component, const XmlNodePtr &node) +void Parser::ParserImpl::loadResetChild(const std::string &childType, const ResetPtr &reset, const ComponentPtr &component, const XmlNodePtr &node) const { // TODO The spec. has not yet defined the test_value and reset_value specification elements. std::string variableName; @@ -1275,7 +1275,7 @@ void Parser::ParserImpl::loadResetChild(const std::string &childType, const Rese } } -void Parser::ParserImpl::checkResetChildMultiplicity(size_t count, const std::string &childType, const ResetPtr &reset, const ComponentPtr &component) +void Parser::ParserImpl::checkResetChildMultiplicity(size_t count, const std::string &childType, const ResetPtr &reset, const ComponentPtr &component) const { std::string variableName; std::string testVariableName; @@ -1306,7 +1306,7 @@ void Parser::ParserImpl::checkResetChildMultiplicity(size_t count, const std::st } } -void Parser::ParserImpl::loadReset(const ResetPtr &reset, const ComponentPtr &component, const XmlNodePtr &node) +void Parser::ParserImpl::loadReset(const ResetPtr &reset, const ComponentPtr &component, const XmlNodePtr &node) const { int order = 0; bool orderValid = false; diff --git a/src/validator.cpp b/src/validator.cpp index be9f3abbf..13ad15eb9 100644 --- a/src/validator.cpp +++ b/src/validator.cpp @@ -87,7 +87,7 @@ struct Validator::ValidatorImpl * @param name The name of the component to validate. * @param names The list of component names already used in the model. */ - void validateUniqueName(const ModelPtr &model, const std::string &name, std::vector &names); + void validateUniqueName(const ModelPtr &model, const std::string &name, std::vector &names) const; /** * @brief Validate the @p component using the CellML 2.0 Specification. @@ -109,7 +109,7 @@ struct Validator::ValidatorImpl * * @param component The imported component to validate. */ - void validateImportedComponent(const ComponentPtr &component); + void validateImportedComponent(const ComponentPtr &component) const; /** * @brief Validate the component tree of the given @p component. @@ -132,7 +132,7 @@ struct Validator::ValidatorImpl * @param units The units to validate. * @param unitsNames A vector list of the name attributes of the @p units and its siblings. */ - void validateUnits(const UnitsPtr &units, const std::vector &unitsNames); + void validateUnits(const UnitsPtr &units, const std::vector &unitsNames) const; /** * @brief Validate the variable connections in the @p model using the CellML 2.0 Specification. @@ -142,7 +142,7 @@ struct Validator::ValidatorImpl * * @param model The model which may contain variable connections to validate. */ - void validateConnections(const ModelPtr &model); + void validateConnections(const ModelPtr &model) const; /** * @brief Validate the units of the given variables equivalent variables. @@ -154,7 +154,7 @@ struct Validator::ValidatorImpl * @param variable The variable to validate. * @param alreadyReported A list of variable pointer pairs. */ - void validateEquivalenceUnits(const ModelPtr &model, const VariablePtr &variable, VariableMap &alreadyReported); + void validateEquivalenceUnits(const ModelPtr &model, const VariablePtr &variable, VariableMap &alreadyReported) const; /** * @brief Validate the structure of the variables equivalences. @@ -163,7 +163,7 @@ struct Validator::ValidatorImpl * * @param variable The variable to validate. */ - void validateEquivalenceStructure(const VariablePtr &variable); + void validateEquivalenceStructure(const VariablePtr &variable) const; /** * @brief Validate the variable interface type. @@ -173,7 +173,7 @@ struct Validator::ValidatorImpl * @param variable The variable to validate. * @param alreadyReported A list of variable pointer pairs. */ - void validateVariableInterface(const VariablePtr &variable, VariableMap &alreadyReported); + void validateVariableInterface(const VariablePtr &variable, VariableMap &alreadyReported) const; /** * @brief Check if the provided @p name is a valid CellML identifier. @@ -187,7 +187,7 @@ struct Validator::ValidatorImpl * * @return @c true if @name is a valid CellML identifier and @c false otherwise. */ - bool isCellmlIdentifier(const std::string &name); + bool isCellmlIdentifier(const std::string &name) const; /** * @brief Validate the @c unit at index @c index from @p units using the CellML 2.0 Specification. @@ -199,7 +199,7 @@ struct Validator::ValidatorImpl * @param units The units to validate. * @param unitsNames A vector list of the name attributes of the @p units and its siblings. */ - void validateUnitsUnit(size_t index, const UnitsPtr &units, const std::vector &unitsNames); + void validateUnitsUnit(size_t index, const UnitsPtr &units, const std::vector &unitsNames) const; /** * @brief Validate the @p variable using the CellML 2.0 Specification. @@ -210,7 +210,7 @@ struct Validator::ValidatorImpl * @param variable The variable to validate. * @param variableNames A vector list of the name attributes of the @p variable and its siblings. */ - void validateVariable(const VariablePtr &variable, const std::vector &variableNames); + void validateVariable(const VariablePtr &variable, const std::vector &variableNames) const; /** * @brief Validate the @p reset using the CellML 2.0 Specification. @@ -245,9 +245,9 @@ struct Validator::ValidatorImpl */ void validateMathMLElements(const XmlNodePtr &node, const ComponentPtr &component); - void validateAndCleanCnNode(const XmlNodePtr &node, const ComponentPtr &component); - void validateAndCleanCiNode(const XmlNodePtr &node, const ComponentPtr &component, const std::vector &variableNames); - bool validateCnUnits(const ComponentPtr &component, const std::string &unitsName, const std::string &textNode); + void validateAndCleanCnNode(const XmlNodePtr &node, const ComponentPtr &component) const; + void validateAndCleanCiNode(const XmlNodePtr &node, const ComponentPtr &component, const std::vector &variableNames) const; + bool validateCnUnits(const ComponentPtr &component, const std::string &unitsName, const std::string &textNode) const; /** * @brief Validate CellML variables and units in MathML @c ci and @c cn variables. Removes CellML units from the @p node. @@ -404,7 +404,7 @@ void Validator::validateModel(const ModelPtr &model) mPimpl->validateConnections(model); } -void Validator::ValidatorImpl::validateUniqueName(const ModelPtr &model, const std::string &name, std::vector &names) +void Validator::ValidatorImpl::validateUniqueName(const ModelPtr &model, const std::string &name, std::vector &names) const { if (!name.empty()) { if (std::find(names.begin(), names.end(), name) != names.end()) { @@ -432,7 +432,7 @@ void Validator::ValidatorImpl::validateComponentTree(const ModelPtr &model, cons } } -void Validator::ValidatorImpl::validateImportedComponent(const ComponentPtr &component) +void Validator::ValidatorImpl::validateImportedComponent(const ComponentPtr &component) const { if (!isCellmlIdentifier(component->name())) { IssuePtr issue = Issue::create(); @@ -521,7 +521,7 @@ void Validator::ValidatorImpl::validateComponent(const ComponentPtr &component) } } -void Validator::ValidatorImpl::validateUnits(const UnitsPtr &units, const std::vector &unitsNames) +void Validator::ValidatorImpl::validateUnits(const UnitsPtr &units, const std::vector &unitsNames) const { // Check for a valid name attribute. if (!isCellmlIdentifier(units->name())) { @@ -552,7 +552,7 @@ void Validator::ValidatorImpl::validateUnits(const UnitsPtr &units, const std::v } } -void Validator::ValidatorImpl::validateUnitsUnit(size_t index, const UnitsPtr &units, const std::vector &unitsNames) +void Validator::ValidatorImpl::validateUnitsUnit(size_t index, const UnitsPtr &units, const std::vector &unitsNames) const { // Validate the unit at the given index. std::string reference; @@ -601,7 +601,7 @@ void Validator::ValidatorImpl::validateUnitsUnit(size_t index, const UnitsPtr &u } } -void Validator::ValidatorImpl::validateVariable(const VariablePtr &variable, const std::vector &variableNames) +void Validator::ValidatorImpl::validateVariable(const VariablePtr &variable, const std::vector &variableNames) const { // Check for a valid name attribute. if (!isCellmlIdentifier(variable->name())) { @@ -840,7 +840,7 @@ void Validator::ValidatorImpl::validateMath(const std::string &input, const Comp } } -bool Validator::ValidatorImpl::validateCnUnits(const ComponentPtr &component, const std::string &unitsName, const std::string &textNode) +bool Validator::ValidatorImpl::validateCnUnits(const ComponentPtr &component, const std::string &unitsName, const std::string &textNode) const { if (isCellmlIdentifier(unitsName)) { return true; @@ -865,7 +865,7 @@ std::string text(const XmlNodePtr &node) return {}; } -void Validator::ValidatorImpl::validateAndCleanCnNode(const XmlNodePtr &node, const ComponentPtr &component) +void Validator::ValidatorImpl::validateAndCleanCnNode(const XmlNodePtr &node, const ComponentPtr &component) const { // Get cellml:units attribute. XmlAttributePtr attribute = node->firstAttribute(); @@ -921,7 +921,7 @@ void Validator::ValidatorImpl::validateAndCleanCnNode(const XmlNodePtr &node, co } } -void Validator::ValidatorImpl::validateAndCleanCiNode(const XmlNodePtr &node, const ComponentPtr &component, const std::vector &variableNames) +void Validator::ValidatorImpl::validateAndCleanCiNode(const XmlNodePtr &node, const ComponentPtr &component, const std::vector &variableNames) const { XmlNodePtr childNode = node->firstChild(); std::string textInNode = text(childNode); @@ -1014,7 +1014,7 @@ bool interfaceTypeIsCompatible(Variable::InterfaceType interfaceTypeMinimumRequi return interfaceTypeCompatibleWith.find(interfaceTypeMinimumRequiredString) != std::string::npos; } -void Validator::ValidatorImpl::validateVariableInterface(const VariablePtr &variable, VariableMap &alreadyReported) +void Validator::ValidatorImpl::validateVariableInterface(const VariablePtr &variable, VariableMap &alreadyReported) const { Variable::InterfaceType interfaceType = determineInterfaceType(variable); auto component = std::dynamic_pointer_cast(variable->parent()); @@ -1055,7 +1055,7 @@ void Validator::ValidatorImpl::validateVariableInterface(const VariablePtr &vari } } -void Validator::ValidatorImpl::validateEquivalenceUnits(const ModelPtr &model, const VariablePtr &variable, VariableMap &alreadyReported) +void Validator::ValidatorImpl::validateEquivalenceUnits(const ModelPtr &model, const VariablePtr &variable, VariableMap &alreadyReported) const { std::string hints; for (size_t index = 0; index < variable->equivalentVariableCount(); ++index) { @@ -1082,7 +1082,7 @@ void Validator::ValidatorImpl::validateEquivalenceUnits(const ModelPtr &model, c } } -void Validator::ValidatorImpl::validateEquivalenceStructure(const VariablePtr &variable) +void Validator::ValidatorImpl::validateEquivalenceStructure(const VariablePtr &variable) const { for (size_t index = 0; index < variable->equivalentVariableCount(); ++index) { auto equivalentVariable = variable->equivalentVariable(index); @@ -1099,7 +1099,7 @@ void Validator::ValidatorImpl::validateEquivalenceStructure(const VariablePtr &v } } -void Validator::ValidatorImpl::validateConnections(const ModelPtr &model) +void Validator::ValidatorImpl::validateConnections(const ModelPtr &model) const { VariableMap interfaceErrorsAlreadyReported; VariableMap equivalentUnitErrorsAlreadyReported; @@ -1123,7 +1123,7 @@ bool Validator::ValidatorImpl::isSupportedMathMLElement(const XmlNodePtr &node) && std::find(supportedMathMLElements.begin(), supportedMathMLElements.end(), node->name()) != supportedMathMLElements.end(); } -bool Validator::ValidatorImpl::isCellmlIdentifier(const std::string &name) +bool Validator::ValidatorImpl::isCellmlIdentifier(const std::string &name) const { bool result = true; // One or more alphabetic characters. diff --git a/tests/model/model.cpp b/tests/model/model.cpp index a4999a83d..1ce97bb0b 100644 --- a/tests/model/model.cpp +++ b/tests/model/model.cpp @@ -375,7 +375,7 @@ struct structure } private: - big_and_complicated *m_data; + big_and_complicated *m_data = nullptr; }; TEST(Model, replaceComponent)