Skip to content
Snippets Groups Projects
Commit caebd000 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

fix some more clang-tidy errors

parent 22774581
No related branches found
No related tags found
1 merge request!95Many clang-tidy fixes
Pipeline #41837 passed
Showing
with 38 additions and 41 deletions
...@@ -68,7 +68,7 @@ private: ...@@ -68,7 +68,7 @@ private:
public: public:
bool inputsAttached ( ) const override { bool inputsAttached ( ) const override {
for ( const std::shared_ptr < abstraction::OperationAbstraction > & operation : m_abstractions ) for ( const std::shared_ptr < abstraction::OperationAbstraction > & operation : m_abstractions )
if ( operation->inputsAttached ( ) == false ) if ( ! operation->inputsAttached ( ) )
return false; return false;
   
return true; return true;
......
...@@ -83,7 +83,7 @@ private: ...@@ -83,7 +83,7 @@ private:
* @return the regular expression node representing the transitions between states @p from and @p to * @return the regular expression node representing the transitions between states @p from and @p to
*/ */
template < class SymbolType, class StateType > template < class SymbolType, class StateType >
static const regexp::UnboundedRegExpStructure < SymbolType > transitionsToRegExp ( const automaton::ExtendedNFA < SymbolType, StateType > & automaton, const StateType & from, const StateType & to ); static regexp::UnboundedRegExpStructure < SymbolType > transitionsToRegExp ( const automaton::ExtendedNFA < SymbolType, StateType > & automaton, const StateType & from, const StateType & to );
   
/** /**
* Helper function for the elimination of a single state according to the algorithm. * Helper function for the elimination of a single state according to the algorithm.
...@@ -148,7 +148,7 @@ automaton::ExtendedNFA < SymbolType, StateType > ToRegExpStateElimination::elimi ...@@ -148,7 +148,7 @@ automaton::ExtendedNFA < SymbolType, StateType > ToRegExpStateElimination::elimi
} }
   
template < class SymbolType, class StateType > template < class SymbolType, class StateType >
const regexp::UnboundedRegExpStructure < SymbolType > ToRegExpStateElimination::transitionsToRegExp ( const automaton::ExtendedNFA < SymbolType, StateType > & automaton, const StateType & from, const StateType & to ) { regexp::UnboundedRegExpStructure < SymbolType > ToRegExpStateElimination::transitionsToRegExp ( const automaton::ExtendedNFA < SymbolType, StateType > & automaton, const StateType & from, const StateType & to ) {
regexp::UnboundedRegExpStructure < SymbolType > ret ( regexp::UnboundedRegExpEmpty < SymbolType > { } ); regexp::UnboundedRegExpStructure < SymbolType > ret ( regexp::UnboundedRegExpEmpty < SymbolType > { } );
   
for ( const auto & transition: automaton.getTransitionsFromState ( from ) ) for ( const auto & transition: automaton.getTransitionsFromState ( from ) )
......
...@@ -83,11 +83,11 @@ private: ...@@ -83,11 +83,11 @@ private:
* @return state partitioning of undistinguishable states * @return state partitioning of undistinguishable states
*/ */
template < class StateType > template < class StateType >
static const ext::map < StateType, ext::set < StateType > > partitionMap ( const ext::set < ext::set < StateType > > & partitions ); static ext::map < StateType, ext::set < StateType > > partitionMap ( const ext::set < ext::set < StateType > > & partitions );
}; };
   
template < class StateType > template < class StateType >
const ext::map < StateType, ext::set < StateType > > MinimizeDistinguishableStates::partitionMap ( const ext::set < ext::set < StateType > > & partitions ) { ext::map < StateType, ext::set < StateType > > MinimizeDistinguishableStates::partitionMap ( const ext::set < ext::set < StateType > > & partitions ) {
ext::map < StateType, ext::set < StateType > > res; ext::map < StateType, ext::set < StateType > > res;
   
for ( const auto & partition : partitions ) for ( const auto & partition : partitions )
......
...@@ -17,7 +17,7 @@ public: ...@@ -17,7 +17,7 @@ public:
throw std::invalid_argument ( "Statement list can't be empty" ); throw std::invalid_argument ( "Statement list can't be empty" );
   
std::shared_ptr < abstraction::OperationAbstraction > next = m_statements [ 0 ]->translateAndEval ( nullptr, environment ); std::shared_ptr < abstraction::OperationAbstraction > next = m_statements [ 0 ]->translateAndEval ( nullptr, environment );
for ( unsigned i = 1; i < m_statements.size ( ); ++ i ) for ( size_t i = 1; i < m_statements.size ( ); ++ i )
next = m_statements [ i ]->translateAndEval ( next, environment ); next = m_statements [ i ]->translateAndEval ( next, environment );
   
return next; return next;
......
...@@ -11,7 +11,7 @@ class ExecuteCommand : public Command { ...@@ -11,7 +11,7 @@ class ExecuteCommand : public Command {
std::shared_ptr < Statement > m_command; std::shared_ptr < Statement > m_command;
   
public: public:
ExecuteCommand ( std::shared_ptr < StatementList > command ) : m_command ( command ) { ExecuteCommand ( std::shared_ptr < StatementList > command ) : m_command ( std::move ( command ) ) {
} }
   
Command::Result run ( Environment & environment ) const override { Command::Result run ( Environment & environment ) const override {
......
...@@ -43,7 +43,7 @@ public: ...@@ -43,7 +43,7 @@ public:
common::Streams::out << " &&"; common::Streams::out << " &&";
} }
common::Streams::out << " ("; common::Streams::out << " (";
for ( unsigned i = 0; i < std::get < 0 > ( overload ).getParams ( ).size ( ); ++ i ) { for ( size_t i = 0; i < std::get < 0 > ( overload ).getParams ( ).size ( ); ++ i ) {
const ext::tuple < std::string, ext::set < abstraction::ParamQualifiers::ParamQualifier > > & parameter = std::get < 0 > ( overload ).getParams ( ) [ i ]; const ext::tuple < std::string, ext::set < abstraction::ParamQualifiers::ParamQualifier > > & parameter = std::get < 0 > ( overload ).getParams ( ) [ i ];
const std::string & name = std::get < 0 > ( overload ).getParamNames ( ) [ i ]; const std::string & name = std::get < 0 > ( overload ).getParamNames ( ) [ i ];
if ( i != 0 ) if ( i != 0 )
......
...@@ -19,7 +19,7 @@ class LibraryLoader { ...@@ -19,7 +19,7 @@ class LibraryLoader {
void * m_handle; void * m_handle;
   
public: public:
Library ( const std::string & path ) : m_path ( path ), m_handle ( nullptr ) { Library ( std::string path ) : m_path ( std::move ( path ) ), m_handle ( nullptr ) {
load ( ); load ( );
} }
   
......
...@@ -60,26 +60,26 @@ private: ...@@ -60,26 +60,26 @@ private:
   
void packData ( ) { void packData ( ) {
size_t sizeWithin = m_Size % ( sizeof ( unsigned ) * BITS_IN_BYTE ); size_t sizeWithin = m_Size % ( sizeof ( unsigned ) * BITS_IN_BYTE );
long long sizeBlocks = m_Size / ( sizeof ( unsigned ) * BITS_IN_BYTE ) + static_cast < unsigned > ( sizeWithin != 0 ); unsigned long long sizeBlocks = m_Size / ( sizeof ( unsigned ) * BITS_IN_BYTE ) + static_cast < unsigned > ( sizeWithin != 0 );
unsigned mask = getMask ( sizeWithin ); unsigned mask = getMask ( sizeWithin );
   
// crop by size // crop by size
ext::list < element >::iterator elementIter; ext::list < element >::iterator elementIter = m_Data.begin ( );
for ( elementIter = m_Data.begin ( ); elementIter != m_Data.end ( ); ++ elementIter ) { for ( ; elementIter != m_Data.end ( ); ++ elementIter ) {
sizeBlocks -= elementIter->run + 1; if ( sizeBlocks <= elementIter->run + 1 )
if ( sizeBlocks <= 0 )
break; break;
sizeBlocks -= elementIter->run + 1;
} }
   
if ( sizeBlocks == 0 ) { // sizeBlocks is negative or 0 // sizeBlocks is smaller or equal to elementIter->run + 1
if ( sizeBlocks == elementIter->run + 1 ) {
if ( mask != 0 ) if ( mask != 0 )
elementIter->word &= mask; elementIter->word &= mask;
++ elementIter;
} else { } else {
elementIter->run += sizeBlocks; //sizeBlocks is negative elementIter->run = sizeBlocks - 1;
elementIter->word = 0; elementIter->word = 0;
++ elementIter;
} }
++ elementIter;
   
for ( ; elementIter != m_Data.end ( ); ) { for ( ; elementIter != m_Data.end ( ); ) {
elementIter = m_Data.erase ( elementIter ); elementIter = m_Data.erase ( elementIter );
......
...@@ -12,7 +12,7 @@ public: ...@@ -12,7 +12,7 @@ public:
   
std::string getName() const override; std::string getName() const override;
   
const std::shared_ptr<abstraction::OperationAbstraction> getAutomaton() const { return this->result; } std::shared_ptr<abstraction::OperationAbstraction> getAutomaton() const { return this->result; }
void setAutomaton(std::shared_ptr<abstraction::OperationAbstraction> automaton) { this->result = std::move(automaton); } void setAutomaton(std::shared_ptr<abstraction::OperationAbstraction> automaton) { this->result = std::move(automaton); }
}; };
   
......
...@@ -19,7 +19,7 @@ std::string to_string ( int value ) { ...@@ -19,7 +19,7 @@ std::string to_string ( int value ) {
} }
   
std::string to_string ( bool value ) { std::string to_string ( bool value ) {
return std::to_string ( value ); return std::to_string ( static_cast < int > ( value ) );
} }
   
std::string to_string ( long value ) { std::string to_string ( long value ) {
...@@ -64,45 +64,42 @@ std::string from_string ( const std::string & value ) { ...@@ -64,45 +64,42 @@ std::string from_string ( const std::string & value ) {
   
template < > template < >
int from_string ( const std::string & value ) { int from_string ( const std::string & value ) {
return std::stoi ( value.c_str() ); return std::stoi ( value );
} }
   
template < > template < >
bool from_string ( const std::string & value ) { bool from_string ( const std::string & value ) {
if ( value == "true" || value == "1" ) return value == "true" || value == "1";
return true;
else
return false;
} }
   
template < > template < >
long from_string ( const std::string & value ) { long from_string ( const std::string & value ) {
return std::stol ( value.c_str() ); return std::stol ( value );
} }
   
template < > template < >
long long from_string ( const std::string & value ) { long long from_string ( const std::string & value ) {
return std::stoll ( value.c_str() ); return std::stoll ( value );
} }
   
template < > template < >
unsigned from_string ( const std::string & value ) { unsigned from_string ( const std::string & value ) {
return std::stoul ( value.c_str() ); return std::stoul ( value );
} }
   
template < > template < >
unsigned long from_string ( const std::string & value ) { unsigned long from_string ( const std::string & value ) {
return std::stoul ( value.c_str() ); return std::stoul ( value );
} }
   
template < > template < >
unsigned long long from_string ( const std::string & value ) { unsigned long long from_string ( const std::string & value ) {
return std::stoull ( value.c_str() ); return std::stoull ( value );
} }
   
template < > template < >
double from_string ( const std::string & value ) { double from_string ( const std::string & value ) {
return std::stod ( value.c_str() ); return std::stod ( value );
} }
   
ext::vector < std::string > explode ( const std::string & source, const std::string & delimiter ) { ext::vector < std::string > explode ( const std::string & source, const std::string & delimiter ) {
......
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
   
namespace ext { namespace ext {
   
unsigned fromBase26( std::string rep ) { unsigned fromBase26( const std::string & rep ) {
unsigned n = 0; unsigned n = 0;
for(char repSymbol : rep ) { for ( char repSymbol : rep ) {
unsigned remainder = repSymbol - 'A'; unsigned remainder = repSymbol - 'A';
if(remainder > 26) if(remainder > 26)
throw std::invalid_argument(rep); throw std::invalid_argument(rep);
...@@ -32,9 +32,9 @@ std::string toBase26( unsigned n ) { ...@@ -32,9 +32,9 @@ std::string toBase26( unsigned n ) {
return std::string( name.rbegin( ), name.rend( ) ); return std::string( name.rbegin( ), name.rend( ) );
} }
   
unsigned bijectiveFromBase26 ( std::string rep ) { unsigned bijectiveFromBase26 ( const std::string & rep ) {
unsigned n = 0; unsigned n = 0;
for (char repSymbol : rep ) { for ( char repSymbol : rep ) {
unsigned remainder = repSymbol - 'A'; unsigned remainder = repSymbol - 'A';
if(remainder > 26) if(remainder > 26)
throw std::invalid_argument(rep); throw std::invalid_argument(rep);
......
...@@ -56,7 +56,7 @@ std::string toBase26( unsigned n ); ...@@ -56,7 +56,7 @@ std::string toBase26( unsigned n );
* *
* \return the number corresponding to the value in \p rep * \return the number corresponding to the value in \p rep
*/ */
unsigned fromBase26( std::string rep ); unsigned fromBase26( const std::string & rep );
   
/** /**
* \brief * \brief
...@@ -86,7 +86,7 @@ std::string bijectiveToBase26( unsigned n ); ...@@ -86,7 +86,7 @@ std::string bijectiveToBase26( unsigned n );
* *
* \return the number corresponding to the value in \p rep * \return the number corresponding to the value in \p rep
*/ */
unsigned bijectiveFromBase26( std::string rep ); unsigned bijectiveFromBase26( const std::string & rep );
   
} /* namespace ext */ } /* namespace ext */
   
......
...@@ -20,7 +20,7 @@ std::ostream & operator << ( std::ostream & os, const ext::type_index & type ) { ...@@ -20,7 +20,7 @@ std::ostream & operator << ( std::ostream & os, const ext::type_index & type ) {
std::string to_string ( const ext::type_index & type ) { std::string to_string ( const ext::type_index & type ) {
int status; int status;
   
char* demangled = abi::__cxa_demangle(type.name(), 0, 0, &status); char* demangled = abi::__cxa_demangle(type.name(), nullptr, nullptr, &status);
std::string res ( demangled ); std::string res ( demangled );
free ( demangled ); free ( demangled );
return res; return res;
......
...@@ -47,9 +47,9 @@ bool is_same_type ( const std::string & first, const std::string & second ) { ...@@ -47,9 +47,9 @@ bool is_same_type ( const std::string & first, const std::string & second ) {
if ( explodedFirst.size ( ) > explodedSecond.size ( ) ) if ( explodedFirst.size ( ) > explodedSecond.size ( ) )
return false; return false;
   
unsigned offset = explodedSecond.size ( ) - explodedFirst.size ( ); size_t offset = explodedSecond.size ( ) - explodedFirst.size ( );
   
for ( unsigned index = 0; index < explodedFirst.size ( ); ++ index ) { for ( size_t index = 0; index < explodedFirst.size ( ); ++ index ) {
if ( explodedFirst [ index ].empty ( ) ) if ( explodedFirst [ index ].empty ( ) )
continue; continue;
   
......
...@@ -14,7 +14,7 @@ template < class T, class U > ...@@ -14,7 +14,7 @@ template < class T, class U >
std::istream& operator>> ( std::istream & in, std::pair < T, U > & value ) { std::istream& operator>> ( std::istream & in, std::pair < T, U > & value ) {
std::string tmp; std::string tmp;
in >> tmp; in >> tmp;
size_t posEqual = tmp.find ( "=" ); size_t posEqual = tmp.find ( '=' );
   
if ( posEqual == std::string::npos ) if ( posEqual == std::string::npos )
in.setstate(std::ios_base::failbit); in.setstate(std::ios_base::failbit);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment