-
Notifications
You must be signed in to change notification settings - Fork 593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix lints in generated C++ code #3262
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1111,9 +1111,14 @@ Slice::Gen::ForwardDeclVisitor::visitEnum(const EnumPtr& p) | |
H << "class "; | ||
} | ||
H << getDeprecatedAttribute(p) << fixKwd(p->name()); | ||
if (!unscoped && p->maxValue() <= 0xFF) | ||
if (!unscoped) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately we have no test for unscoped: we should either test it or remove it. |
||
{ | ||
H << " : ::std::uint8_t"; | ||
H << " : ::std::" << (p->maxValue() <= numeric_limits<uint8_t>::max() ? "uint8_t" : "int32_t"); | ||
|
||
if (p->maxValue() > numeric_limits<uint8_t>::max() && p->maxValue() <= numeric_limits<int16_t>::max()) | ||
{ | ||
H << " // NOLINT:performance-enum-size"; | ||
} | ||
} | ||
H << sb; | ||
|
||
|
@@ -1221,7 +1226,12 @@ Slice::Gen::ForwardDeclVisitor::visitConst(const ConstPtr& p) | |
<< typeToString(p->type(), false, scope, p->typeMetadata(), _useWstring) << " " << fixKwd(p->name()) << " " | ||
<< getDeprecatedAttribute(p) << "= "; | ||
writeConstantValue(H, p->type(), p->valueType(), p->value(), _useWstring, p->typeMetadata(), scope); | ||
H << ';' << sp; | ||
H << ';'; | ||
if (!isConstexprType(p->type())) | ||
bernardnormier marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
H << " // NOLINT:cert-err58-cpp"; | ||
} | ||
H << sp; | ||
} | ||
|
||
Slice::Gen::DefaultFactoryVisitor::DefaultFactoryVisitor(Output& c) : C(c), _factoryTableInitDone(false) {} | ||
|
@@ -1543,6 +1553,10 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) | |
} | ||
H << nl << deprecatedAttribute << retS << ' ' << fixKwd(name) << spar << paramsDecl << contextDecl << epar | ||
<< " const;"; | ||
if (ret) | ||
{ | ||
H << " // NOLINT:modernize-use-nodiscard"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't generate a [[nodiscard]] for sync proxy functions returning something. |
||
} | ||
|
||
C << sp; | ||
C << nl << retSImpl << nl << scoped << fixKwd(name) << spar << paramsImplDecl << "const ::Ice::Context& context" | ||
|
@@ -2068,7 +2082,7 @@ Slice::Gen::DataDefVisitor::visitExceptionStart(const ExceptionPtr& p) | |
C << nl << "return \"" << p->scoped() << "\";"; | ||
C << eb; | ||
|
||
H << sp << nl << _dllMemberExport << "const char* ice_id() const noexcept override;"; | ||
H << sp << nl << _dllMemberExport << "[[nodiscard]] const char* ice_id() const noexcept override;"; | ||
C << sp << nl << "const char*" << nl << scoped.substr(2) << "::ice_id() const noexcept"; | ||
C << sb; | ||
C << nl << "return ice_staticId();"; | ||
|
@@ -2084,7 +2098,7 @@ Slice::Gen::DataDefVisitor::visitExceptionStart(const ExceptionPtr& p) | |
{ | ||
H << sp; | ||
H << nl << "/// \\cond STREAM"; | ||
H << nl << _dllMemberExport << "bool _usesClasses() const override;"; | ||
H << nl << _dllMemberExport << "[[nodiscard]] bool _usesClasses() const override;"; | ||
H << nl << "/// \\endcond"; | ||
|
||
C << sp; | ||
|
@@ -2218,7 +2232,7 @@ Slice::Gen::DataDefVisitor::visitClassDefStart(const ClassDefPtr& p) | |
C << nl << "return \"" << p->scoped() << "\";"; | ||
C << eb; | ||
|
||
H << sp << nl << _dllMemberExport << "const char* ice_id() const noexcept override;"; | ||
H << sp << nl << _dllMemberExport << "[[nodiscard]] const char* ice_id() const noexcept override;"; | ||
C << sp << nl << "const char*" << nl << scoped.substr(2) << "::ice_id() const noexcept"; | ||
C << sb; | ||
C << nl << "return ice_staticId();"; | ||
|
@@ -2235,7 +2249,7 @@ Slice::Gen::DataDefVisitor::visitClassDefStart(const ClassDefPtr& p) | |
H << sp; | ||
H << nl << "/// Creates a shallow polymorphic copy of this instance."; | ||
H << nl << "/// @return The cloned value."; | ||
H << nl << p->name() << "Ptr ice_clone() const { return ::std::static_pointer_cast<" << name | ||
H << nl << "[[nodiscard]] " << p->name() << "Ptr ice_clone() const { return ::std::static_pointer_cast<" << name | ||
<< ">(_iceCloneImpl()); }"; | ||
|
||
return true; | ||
|
@@ -2302,7 +2316,7 @@ Slice::Gen::DataDefVisitor::visitClassDefEnd(const ClassDefPtr& p) | |
} | ||
|
||
H << nl << name << "(const " << name << "&) = default;"; | ||
H << sp << nl << _dllMemberExport << "::Ice::ValuePtr _iceCloneImpl() const override;"; | ||
H << sp << nl << _dllMemberExport << "[[nodiscard]] ::Ice::ValuePtr _iceCloneImpl() const override;"; | ||
C << sp; | ||
C << nl << "::Ice::ValuePtr" << nl << scoped.substr(2) << "::_iceCloneImpl() const"; | ||
C << sb; | ||
|
@@ -2571,13 +2585,13 @@ Slice::Gen::InterfaceVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) | |
H << nl << "/// Obtains a list of the Slice type IDs representing the interfaces supported by this object."; | ||
H << nl << "/// @param current The Current object for the invocation."; | ||
H << nl << "/// @return A list of fully-scoped type IDs."; | ||
H << nl << "::std::vector<::std::string> ice_ids(const " << getUnqualified("::Ice::Current&", scope) | ||
H << nl << "[[nodiscard]] ::std::vector<::std::string> ice_ids(const " << getUnqualified("::Ice::Current&", scope) | ||
<< " current) const override;"; | ||
H << sp; | ||
H << nl << "/// Obtains a Slice type ID representing the most-derived interface supported by this object."; | ||
H << nl << "/// @param current The Current object for the invocation."; | ||
H << nl << "/// @return A fully-scoped type ID."; | ||
H << nl << "::std::string ice_id(const " << getUnqualified("::Ice::Current&", scope) << " current) const override;"; | ||
H << nl << "[[nodiscard]] ::std::string ice_id(const " << getUnqualified("::Ice::Current&", scope) << " current) const override;"; | ||
H << sp; | ||
H << nl << "/// Obtains the Slice type ID corresponding to this interface."; | ||
H << nl << "/// @return A fully-scoped type ID."; | ||
|
@@ -2743,12 +2757,20 @@ Slice::Gen::InterfaceVisitor::visitOperation(const OperationPtr& p) | |
|
||
DocCommentPtr comment = p->parseDocComment(cppLinkFormatter); | ||
|
||
string isConst = p->hasMetadata("cpp:const") ? " const" : ""; | ||
string noDiscard = ""; | ||
|
||
if (ret) | ||
{ | ||
string typeS = inputTypeToString(ret, p->returnIsOptional(), interfaceScope, p->getMetadata(), _useWstring); | ||
responseParams.push_back(typeS + " " + returnValueParam); | ||
responseParamsDecl.push_back(typeS + " ret"); | ||
responseParamsImplDecl.push_back(typeS + " ret"); | ||
|
||
if (!amd && !isConst.empty()) | ||
{ | ||
noDiscard = "[[nodiscard]] "; | ||
bernardnormier marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
string retS; | ||
|
@@ -2880,8 +2902,6 @@ Slice::Gen::InterfaceVisitor::visitOperation(const OperationPtr& p) | |
C << eb; | ||
} | ||
|
||
string isConst = p->hasMetadata("cpp:const") ? " const" : ""; | ||
|
||
string opName = amd ? (name + "Async") : fixKwd(name); | ||
|
||
H << sp; | ||
|
@@ -2905,7 +2925,7 @@ Slice::Gen::InterfaceVisitor::visitOperation(const OperationPtr& p) | |
postParams.push_back("@param " + currentParam + " The Current object for the invocation."); | ||
writeOpDocSummary(H, p, comment, pt, true, GenerateDeprecated::No, StringList(), postParams, returns); | ||
} | ||
H << nl << "virtual " << retS << ' ' << opName << spar << params << epar << isConst << " = 0;"; | ||
H << nl << noDiscard << "virtual " << retS << ' ' << opName << spar << params << epar << isConst << " = 0;"; | ||
H << nl << "/// \\cond INTERNAL"; | ||
H << nl << "void _iceD_" << name << "(::Ice::IncomingRequest&, ::std::function<void(::Ice::OutgoingResponse)>)" | ||
<< isConst << ';'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use C++20 types (std::span) for a test in C++20 mode; clang-tidy doesn't like -std=c++17 for that test.