Merge pull request #435 from borglab/fix/clang-warnings

Fix clang warnings
release/4.3a0
Frank Dellaert 2020-07-27 10:16:40 -04:00 committed by GitHub
commit b0a48a6ba2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 21 additions and 10 deletions

View File

@ -104,7 +104,14 @@ if(MSVC)
set(GTSAM_COMPILE_OPTIONS_PRIVATE_TIMING /MD /O2 CACHE STRING "(User editable) Private compiler flags for Timing configuration.") set(GTSAM_COMPILE_OPTIONS_PRIVATE_TIMING /MD /O2 CACHE STRING "(User editable) Private compiler flags for Timing configuration.")
else() else()
# Common to all configurations, next for each configuration: # Common to all configurations, next for each configuration:
if (
((CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.0.0)) OR
(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
)
set(flag_override_ -Wsuggest-override) # -Werror=suggest-override: Add again someday
endif()
set(GTSAM_COMPILE_OPTIONS_PRIVATE_COMMON set(GTSAM_COMPILE_OPTIONS_PRIVATE_COMMON
-Wall # Enable common warnings -Wall # Enable common warnings
-fPIC # ensure proper code generation for shared libraries -fPIC # ensure proper code generation for shared libraries
@ -112,7 +119,7 @@ else()
$<$<CXX_COMPILER_ID:Clang>:-Wreturn-stack-address -Werror=return-stack-address> # Error: return local address $<$<CXX_COMPILER_ID:Clang>:-Wreturn-stack-address -Werror=return-stack-address> # Error: return local address
-Wreturn-type -Werror=return-type # Error on missing return() -Wreturn-type -Werror=return-type # Error on missing return()
-Wformat -Werror=format-security # Error on wrong printf() arguments -Wformat -Werror=format-security # Error on wrong printf() arguments
$<$<COMPILE_LANGUAGE:CXX>:-Wsuggest-override -Werror=suggest-override> # Enforce the use of the override keyword $<$<COMPILE_LANGUAGE:CXX>:${flag_override_}> # Enforce the use of the override keyword
# #
CACHE STRING "(User editable) Private compiler flags for all configurations.") CACHE STRING "(User editable) Private compiler flags for all configurations.")
set(GTSAM_COMPILE_OPTIONS_PRIVATE_DEBUG -g -fno-inline CACHE STRING "(User editable) Private compiler flags for Debug configuration.") set(GTSAM_COMPILE_OPTIONS_PRIVATE_DEBUG -g -fno-inline CACHE STRING "(User editable) Private compiler flags for Debug configuration.")

View File

@ -89,7 +89,7 @@ void TimingOutline::print(const std::string& outline) const {
childOrder[child.second->myOrder_] = child.second; childOrder[child.second->myOrder_] = child.second;
} }
// Print children // Print children
for(const ChildOrder::value_type order_child: childOrder) { for(const ChildOrder::value_type& order_child: childOrder) {
std::string childOutline(outline); std::string childOutline(outline);
childOutline += "| "; childOutline += "| ";
order_child.second->print(childOutline); order_child.second->print(childOutline);

View File

@ -69,7 +69,7 @@ namespace gtsam {
for(Key j: f.keys()) cs[j] = f.cardinality(j); for(Key j: f.keys()) cs[j] = f.cardinality(j);
// Convert map into keys // Convert map into keys
DiscreteKeys keys; DiscreteKeys keys;
for(const DiscreteKey& key: cs) for(const std::pair<const Key,size_t>& key: cs)
keys.push_back(key); keys.push_back(key);
// apply operand // apply operand
ADT result = ADT::apply(f, op); ADT result = ADT::apply(f, op);

View File

@ -45,6 +45,7 @@ class GTSAM_EXPORT DiscreteBayesTreeClique
typedef boost::shared_ptr<This> shared_ptr; typedef boost::shared_ptr<This> shared_ptr;
typedef boost::weak_ptr<This> weak_ptr; typedef boost::weak_ptr<This> weak_ptr;
DiscreteBayesTreeClique() {} DiscreteBayesTreeClique() {}
virtual ~DiscreteBayesTreeClique() {}
DiscreteBayesTreeClique( DiscreteBayesTreeClique(
const boost::shared_ptr<DiscreteConditional>& conditional) const boost::shared_ptr<DiscreteConditional>& conditional)
: Base(conditional) {} : Base(conditional) {}

View File

@ -56,7 +56,7 @@ bool Potentials::equals(const Potentials& other, double tol) const {
/* ************************************************************************* */ /* ************************************************************************* */
void Potentials::print(const string& s, const KeyFormatter& formatter) const { void Potentials::print(const string& s, const KeyFormatter& formatter) const {
cout << s << "\n Cardinalities: {"; cout << s << "\n Cardinalities: {";
for (const DiscreteKey& key : cardinalities_) for (const std::pair<const Key,size_t>& key : cardinalities_)
cout << formatter(key.first) << ":" << key.second << ", "; cout << formatter(key.first) << ":" << key.second << ", ";
cout << "}" << endl; cout << "}" << endl;
ADT::print(" "); ADT::print(" ");

View File

@ -41,6 +41,7 @@ namespace gtsam {
typedef boost::shared_ptr<This> shared_ptr; typedef boost::shared_ptr<This> shared_ptr;
typedef boost::weak_ptr<This> weak_ptr; typedef boost::weak_ptr<This> weak_ptr;
GaussianBayesTreeClique() {} GaussianBayesTreeClique() {}
virtual ~GaussianBayesTreeClique() {}
GaussianBayesTreeClique(const boost::shared_ptr<GaussianConditional>& conditional) : Base(conditional) {} GaussianBayesTreeClique(const boost::shared_ptr<GaussianConditional>& conditional) : Base(conditional) {}
}; };

View File

@ -145,7 +145,7 @@ void BlockJacobiPreconditioner::build(
/* getting the block diagonals over the factors */ /* getting the block diagonals over the factors */
std::map<Key, Matrix> hessianMap =gfg.hessianBlockDiagonal(); std::map<Key, Matrix> hessianMap =gfg.hessianBlockDiagonal();
for ( const Matrix hessian: hessianMap | boost::adaptors::map_values) for (const Matrix& hessian: hessianMap | boost::adaptors::map_values)
blocks.push_back(hessian); blocks.push_back(hessian);
/* if necessary, allocating the memory for cacheing the factorization results */ /* if necessary, allocating the memory for cacheing the factorization results */

View File

@ -45,7 +45,7 @@ namespace gtsam {
/* ************************************************************************* */ /* ************************************************************************* */
VectorValues::VectorValues(const Vector& x, const Dims& dims) { VectorValues::VectorValues(const Vector& x, const Dims& dims) {
typedef pair<Key, size_t> Pair; using Pair = pair<const Key, size_t>;
size_t j = 0; size_t j = 0;
for (const Pair& v : dims) { for (const Pair& v : dims) {
Key key; Key key;

View File

@ -51,6 +51,7 @@ class GTSAM_EXPORT ISAM2Clique
/// Default constructor /// Default constructor
ISAM2Clique() : Base() {} ISAM2Clique() : Base() {}
virtual ~ISAM2Clique() = default;
/// Copy constructor, does *not* copy solution pointers as these are invalid /// Copy constructor, does *not* copy solution pointers as these are invalid
/// in different trees. /// in different trees.

View File

@ -73,8 +73,8 @@ string findExampleDataFile(const string& name) {
namesToSearch.push_back(name + ".xml"); namesToSearch.push_back(name + ".xml");
// Find first name that exists // Find first name that exists
for(const fs::path& root: rootsToSearch) { for(const fs::path root: rootsToSearch) {
for(const fs::path& name: namesToSearch) { for(const fs::path name: namesToSearch) {
if (fs::is_regular_file(root / name)) if (fs::is_regular_file(root / name))
return (root / name).string(); return (root / name).string();
} }

View File

@ -39,6 +39,7 @@ namespace gtsam {
typedef boost::shared_ptr<This> shared_ptr; typedef boost::shared_ptr<This> shared_ptr;
typedef boost::weak_ptr<This> weak_ptr; typedef boost::weak_ptr<This> weak_ptr;
SymbolicBayesTreeClique() {} SymbolicBayesTreeClique() {}
virtual ~SymbolicBayesTreeClique() {}
SymbolicBayesTreeClique(const boost::shared_ptr<SymbolicConditional>& conditional) : Base(conditional) {} SymbolicBayesTreeClique(const boost::shared_ptr<SymbolicConditional>& conditional) : Base(conditional) {}
}; };

View File

@ -248,7 +248,7 @@ void Module::parseMarkup(const std::string& data) {
// Create type attributes table and check validity // Create type attributes table and check validity
typeAttributes.addClasses(expandedClasses); typeAttributes.addClasses(expandedClasses);
typeAttributes.addForwardDeclarations(forward_declarations); typeAttributes.addForwardDeclarations(forward_declarations);
for (const TypedefPair p: typedefs) for (const TypedefPair& p: typedefs)
typeAttributes.addType(p.newType); typeAttributes.addType(p.newType);
// add Eigen types as template arguments are also checked ? // add Eigen types as template arguments are also checked ?
vector<ForwardDeclaration> eigen; vector<ForwardDeclaration> eigen;