summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2019-03-19 21:56:50 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2019-03-19 21:56:50 +0000
commitd399910103de05bc15ebc90a732f55a50732146e (patch)
tree3a22459dd2e4faf60f54b0bd5840fab2dfb1c77c
parentExplicitly disable checker for generated code (diff)
downloadslicer-d399910103de05bc15ebc90a732f55a50732146e.tar.bz2
slicer-d399910103de05bc15ebc90a732f55a50732146e.tar.xz
slicer-d399910103de05bc15ebc90a732f55a50732146e.zip
Clang tidy our own generated code
Builds tools with gcc to run a real slicer for the codegen. Fixs results tidy warnings
-rw-r--r--slicer/slicer/modelPartsTypes.impl.h18
-rw-r--r--slicer/test/Jamfile.jam8
-rw-r--r--slicer/test/slicer.jam2
-rw-r--r--slicer/tool/parser.cpp20
4 files changed, 36 insertions, 12 deletions
diff --git a/slicer/slicer/modelPartsTypes.impl.h b/slicer/slicer/modelPartsTypes.impl.h
index 74bf0c6..e75c849 100644
--- a/slicer/slicer/modelPartsTypes.impl.h
+++ b/slicer/slicer/modelPartsTypes.impl.h
@@ -146,6 +146,7 @@ namespace Slicer {
template<typename T>
void ModelPartForSimple<T>::SetValue(ValueSource && s)
{
+ // NOLINTNEXTLINE(hicpp-no-array-decay,-warnings-as-errors)
BOOST_ASSERT(this->Model);
s.set(*this->Model);
}
@@ -153,6 +154,7 @@ namespace Slicer {
template<typename T>
bool ModelPartForSimple<T>::GetValue(ValueTarget && s)
{
+ // NOLINTNEXTLINE(hicpp-no-array-decay,-warnings-as-errors)
BOOST_ASSERT(this->Model);
s.get(*this->Model);
return true;
@@ -174,6 +176,7 @@ namespace Slicer {
template<typename T, typename M, Ice::optional<T> M::* MV>
bool ModelPartForConverted<Ice::optional<T>, M, MV>::HasValue() const
{
+ // NOLINTNEXTLINE(hicpp-no-array-decay,-warnings-as-errors)
BOOST_ASSERT(this->Model);
return (bool)*this->Model;
}
@@ -289,6 +292,7 @@ namespace Slicer {
template<typename T>
bool ModelPartForOptional<T>::hasModel() const
{
+ // NOLINTNEXTLINE(hicpp-no-array-decay,-warnings-as-errors)
BOOST_ASSERT(this->Model);
return (bool)*this->Model;
}
@@ -296,6 +300,7 @@ namespace Slicer {
template<typename T>
void ModelPartForOptional<T>::Create()
{
+ // NOLINTNEXTLINE(hicpp-no-array-decay,-warnings-as-errors)
BOOST_ASSERT(this->Model);
if (!*this->Model) {
*this->Model = typename T::element_type();
@@ -307,6 +312,7 @@ namespace Slicer {
template<typename T>
bool ModelPartForOptional<T>::GetValue(ValueTarget && s)
{
+ // NOLINTNEXTLINE(hicpp-no-array-decay,-warnings-as-errors)
BOOST_ASSERT(this->Model);
if (*this->Model) {
return modelPart->GetValue(std::move(s));
@@ -446,6 +452,7 @@ namespace Slicer {
template<typename T>
void ModelPartForClass<T>::Create()
{
+ // NOLINTNEXTLINE(hicpp-no-array-decay,-warnings-as-errors)
BOOST_ASSERT(this->Model);
*this->Model = std::make_shared<T>();
}
@@ -459,6 +466,7 @@ namespace Slicer {
template<typename T>
ModelPartPtr ModelPartForClass<T>::GetSubclassModelPart(const std::string & name)
{
+ // NOLINTNEXTLINE(hicpp-no-array-decay,-warnings-as-errors)
BOOST_ASSERT(this->Model);
return ModelPartForComplexBase::getSubclassModelPart(name, this->Model);
}
@@ -466,6 +474,7 @@ namespace Slicer {
template<typename T>
bool ModelPartForClass<T>::HasValue() const
{
+ // NOLINTNEXTLINE(hicpp-no-array-decay,-warnings-as-errors)
BOOST_ASSERT(this->Model);
return (bool)*this->Model;
}
@@ -507,6 +516,7 @@ namespace Slicer {
TypeId
ModelPartForClass<T>::GetTypeId() const
{
+ // NOLINTNEXTLINE(hicpp-no-array-decay,-warnings-as-errors)
BOOST_ASSERT(this->Model);
return ModelPartForComplexBase::GetTypeId(getTypeId(), *className);
}
@@ -591,6 +601,7 @@ namespace Slicer {
template<typename T>
void ModelPartForEnum<T>::SetValue(ValueSource && s)
{
+ // NOLINTNEXTLINE(hicpp-no-array-decay,-warnings-as-errors)
BOOST_ASSERT(this->Model);
std::string val;
s.set(val);
@@ -600,6 +611,7 @@ namespace Slicer {
template<typename T>
bool ModelPartForEnum<T>::GetValue(ValueTarget && s)
{
+ // NOLINTNEXTLINE(hicpp-no-array-decay,-warnings-as-errors)
BOOST_ASSERT(this->Model);
s.get(lookup(*this->Model));
return true;
@@ -615,6 +627,7 @@ namespace Slicer {
template<typename T>
void ModelPartForSequence<T>::OnEachChild(const ChildHandler & ch)
{
+ // NOLINTNEXTLINE(hicpp-no-array-decay,-warnings-as-errors)
BOOST_ASSERT(this->Model);
for(auto & element : *this->Model) {
ch(elementName, elementModelPart(element), NULL);
@@ -624,6 +637,7 @@ namespace Slicer {
template<typename T>
ChildRef ModelPartForSequence<T>::GetAnonChildRef(const HookFilter &)
{
+ // NOLINTNEXTLINE(hicpp-no-array-decay,-warnings-as-errors)
BOOST_ASSERT(this->Model);
this->Model->push_back(typename element_type::value_type());
return ChildRef(ModelPart::CreateFor(this->Model->back()));
@@ -671,6 +685,7 @@ namespace Slicer {
template<typename T>
void ModelPartForDictionary<T>::OnEachChild(const ChildHandler & ch)
{
+ // NOLINTNEXTLINE(hicpp-no-array-decay,-warnings-as-errors)
BOOST_ASSERT(this->Model);
for (auto & pair : *this->Model) {
ch(pairName, std::make_shared<ModelPartForStruct<typename T::value_type>>(&pair), NULL);
@@ -680,6 +695,7 @@ namespace Slicer {
template<typename T>
ChildRef ModelPartForDictionary<T>::GetAnonChildRef(const HookFilter &)
{
+ // NOLINTNEXTLINE(hicpp-no-array-decay,-warnings-as-errors)
BOOST_ASSERT(this->Model);
return ChildRef(std::make_shared<ModelPartForDictionaryElementInserter<T>>(this->Model));
}
@@ -687,6 +703,7 @@ namespace Slicer {
template<typename T>
ChildRef ModelPartForDictionary<T>::GetChildRef(const std::string & name, const HookFilter &, bool matchCase)
{
+ // NOLINTNEXTLINE(hicpp-no-array-decay,-warnings-as-errors)
BOOST_ASSERT(this->Model);
if (!optionalCaseEq(name, pairName, matchCase)) {
throw IncorrectElementName(name);
@@ -724,6 +741,7 @@ namespace Slicer {
void
ModelPartForStream<T>::OnEachChild(const ChildHandler & ch)
{
+ // NOLINTNEXTLINE(hicpp-no-array-decay,-warnings-as-errors)
BOOST_ASSERT(this->Model);
this->Model->Produce([&ch](const T & element) {
ch(ModelPartForSequence<std::vector<T>>::elementName, ModelPart::CreateFor(element), NULL);
diff --git a/slicer/test/Jamfile.jam b/slicer/test/Jamfile.jam
index c288fc9..4c0acbd 100644
--- a/slicer/test/Jamfile.jam
+++ b/slicer/test/Jamfile.jam
@@ -22,9 +22,13 @@ lib types :
[ glob *.ice ]
conversions.cpp
:
- <dependency>../tool//slicer
+ <toolset>gcc:<dependency>../tool//slicer/<toolset>gcc
+ <toolset>clang:<dependency>../tool//slicer/<toolset>clang
+ <toolset>tidy:<dependency>../tool//slicer/<toolset>gcc
<slicer>pure
- <slicerbin>../tool//slicer
+ <toolset>gcc:<slicerbin>../tool//slicer/<toolset>gcc
+ <toolset>clang:<slicerbin>../tool//slicer/<toolset>clang
+ <toolset>tidy:<slicerbin>../tool//slicer/<toolset>gcc
<include>.
<library>..//adhocutil
<library>boost_date_time
diff --git a/slicer/test/slicer.jam b/slicer/test/slicer.jam
index f43d087..f413628 100644
--- a/slicer/test/slicer.jam
+++ b/slicer/test/slicer.jam
@@ -14,13 +14,11 @@ toolset.flags slicer INCLUDES <include> ;
actions slicer bind SLICERBIN
{
slice2cpp -I"$(INCLUDES)" --checksum --output-dir $(1[1]:D) $(2) --dll-export JAM_DLL_PUBLIC
- touch $(1[2])
"$(SLICERBIN)" -I"$(INCLUDES)" $(2) $(1[2]) --headerPrefix="\"\""
}
actions slicer.pure bind SLICERBIN
{
- touch $(1[1])
"$(SLICERBIN)" -I"$(INCLUDES)" $(2) $(1[1]) --headerPrefix="\"\""
}
diff --git a/slicer/tool/parser.cpp b/slicer/tool/parser.cpp
index 9aa27cd..0edcc2f 100644
--- a/slicer/tool/parser.cpp
+++ b/slicer/tool/parser.cpp
@@ -50,16 +50,17 @@ namespace Slicer {
fprintbf(cpp, "template<> DLL_PUBLIC\nvoid\n");
createModelPartForConverted(type, c->scoped(), dm);
fprintbf(cpp, "::SetValue(ValueSource && vsp)\n{\n");
+ fprintbf(cpp, "\t// NOLINTNEXTLINE(hicpp-no-array-decay,-warnings-as-errors)\n");
fprintbf(cpp, "\tBOOST_ASSERT(Model);\n");
for (const auto & conversion : conversions) {
- fprintbf(cpp, "\tif (tryConvertFrom< %s >(vsp, Model, &%s)) return;\n",
+ fprintbf(cpp, "\tif (tryConvertFrom< %s >(vsp, Model, &%s)) {\n\t\treturn;\n\t}\n",
conversion.ExchangeType,
conversion.ConvertToModelFunc);
}
// Default conversion
if (!dm->hasMetaData("slicer:nodefaultconversion")) {
- fprintbf(cpp, "\tif (tryConvertFrom< %s >(vsp, Model)) return;\n",
+ fprintbf(cpp, "\tif (tryConvertFrom< %s >(vsp, Model)) {\n\t\treturn;\n\t}\n",
Slice::typeToString(type));
}
// Failed to convert
@@ -70,16 +71,17 @@ namespace Slicer {
fprintbf(cpp, "template<> DLL_PUBLIC\nbool\n");
createModelPartForConverted(type, c->scoped(), dm);
fprintbf(cpp, "::GetValue(ValueTarget && vtp)\n{\n");
+ fprintbf(cpp, "\t// NOLINTNEXTLINE(hicpp-no-array-decay,-warnings-as-errors)\n");
fprintbf(cpp, "\tBOOST_ASSERT(Model);\n");
for (const auto & conversion : conversions) {
- fprintbf(cpp, "\tif (auto r = tryConvertTo< %s >(vtp, Model, &%s)) return (r == tcr_Value);\n",
+ fprintbf(cpp, "\tif (auto r = tryConvertTo< %s >(vtp, Model, &%s)) {\n\t\treturn (r == tcr_Value);\n\t}\n",
conversion.ExchangeType,
conversion.ConvertToExchangeFunc);
}
// Default conversion
if (!dm->hasMetaData("slicer:nodefaultconversion")) {
- fprintbf(cpp, "\tif (auto r = tryConvertTo< %s >(vtp, Model)) return (r == tcr_Value);\n",
+ fprintbf(cpp, "\tif (auto r = tryConvertTo< %s >(vtp, Model)) {\n\t\treturn (r == tcr_Value);\n\t}\n",
Slice::typeToString(type));
}
// Failed to convert
@@ -199,6 +201,7 @@ namespace Slicer {
copyMetadata(c->getMetaData());
fprintbf(cpp, ";\n\n");
+ fprintbf(cpp, "// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)\n");
if (auto cmp = metaDataValue("slicer:custommodelpart:", c->getMetaData())) {
fprintbf(cpp, "CUSTOMMODELPARTFOR(%s, %s< %s >, %s);\n\n",
Slice::typeToString(decl), getBasicModelPart(decl), c->scoped(), boost::algorithm::replace_all_copy(*cmp, ".", "::"));
@@ -243,8 +246,8 @@ namespace Slicer {
{
if (!cpp) { return; }
- fprintbf(cpp, "typedef ModelPartForComplex< %s > C%d;\n",
- it->scoped(), components);
+ fprintbf(cpp, "using C%d = ModelPartForComplex< %s >;\n",
+ components, it->scoped());
fprintbf(cpp, "template<> DLL_PUBLIC\n");
fprintbf(cpp, "const C%d::Hooks ",
components);
@@ -373,8 +376,8 @@ namespace Slicer {
d->scoped(),
iname ? *iname : "element");
- fprintbf(cpp, "typedef ModelPartForComplex< %s::value_type > C%d;\n",
- d->scoped(), components);
+ fprintbf(cpp, "using C%d = ModelPartForComplex< %s::value_type >;\n",
+ components, d->scoped());
fprintbf(cpp, "template<> DLL_PUBLIC\n");
fprintbf(cpp, "const C%d::Hooks ",
components);
@@ -550,6 +553,7 @@ namespace Slicer {
void
Slicer::defineMODELPART(const std::string & type, const Slice::TypePtr & stype, const Slice::StringList & metadata) const
{
+ fprintbf(cpp, "// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)\n");
if (auto cmp = metaDataValue("slicer:custommodelpart:", metadata)) {
fprintbf(cpp, "CUSTOMMODELPARTFOR(%s, %s< %s >, %s);\n\n",
type, getBasicModelPart(stype), type, boost::algorithm::replace_all_copy(*cmp, ".", "::"));