Permalink
Browse files

Added cmake option to run clang-tidy

used everywhere nullptr
  • Loading branch information...
turleypol committed Oct 9, 2018
1 parent 0a39af1 commit a5e62061647f3ffa3eb1e0fac5bafb26604b2a28
Showing with 439 additions and 390 deletions.
  1. +24 −0 CMakeLists.txt
  2. +9 −0 cmake/compile_defs.cmake
  3. +1 −0 pol-core/bscript/CMakeLists.txt
  4. +2 −2 pol-core/bscript/bobject.h
  5. +12 −12 pol-core/bscript/bstruct.cpp
  6. +1 −1 pol-core/bscript/compctx.cpp
  7. +42 −42 pol-core/bscript/compiler.cpp
  8. +6 −6 pol-core/bscript/compiler.h
  9. +11 −11 pol-core/bscript/dict.cpp
  10. +1 −1 pol-core/bscript/eprog.cpp
  11. +5 −5 pol-core/bscript/eprog2.cpp
  12. +5 −5 pol-core/bscript/eprog_read.cpp
  13. +7 −7 pol-core/bscript/escrutil.cpp
  14. +36 −36 pol-core/bscript/executor.cpp
  15. +1 −1 pol-core/bscript/fmodule.cpp
  16. +1 −1 pol-core/bscript/fmodule.h
  17. +19 −19 pol-core/bscript/object.cpp
  18. +7 −7 pol-core/bscript/parser.cpp
  19. +3 −3 pol-core/bscript/parser.h
  20. +5 −5 pol-core/bscript/str.cpp
  21. +5 −5 pol-core/bscript/symcont.cpp
  22. +3 −3 pol-core/bscript/symcont.h
  23. +2 −2 pol-core/bscript/tkn_strm.cpp
  24. +11 −11 pol-core/bscript/token.cpp
  25. +1 −1 pol-core/bscript/userfunc.cpp
  26. +1 −0 pol-core/clib/CMakeLists.txt
  27. +14 −14 pol-core/clib/Debugging/ExceptionParser.cpp
  28. +19 −19 pol-core/clib/NTService.cpp
  29. +2 −2 pol-core/clib/NTService.h
  30. +2 −2 pol-core/clib/Program/ProgramMain.cpp
  31. +21 −21 pol-core/clib/cfgfile.cpp
  32. +4 −4 pol-core/clib/cfgfile.h
  33. +6 −6 pol-core/clib/clib_MD5.cpp
  34. +6 −6 pol-core/clib/dirfunc.cpp
  35. +9 −9 pol-core/clib/dirlist.cpp
  36. +1 −1 pol-core/clib/filecont.cpp
  37. +2 −2 pol-core/clib/fileutil.cpp
  38. +3 −3 pol-core/clib/fixalloc.h
  39. +1 −1 pol-core/clib/forspcnt.cpp
  40. +9 −9 pol-core/clib/mdump.cpp
  41. +8 −8 pol-core/clib/threadhelp.cpp
  42. +6 −6 pol-core/clib/wnsckt.cpp
  43. +2 −2 pol-core/clib/xmain.cpp
  44. +2 −0 pol-core/ecompile/CMakeLists.txt
  45. +2 −0 pol-core/plib/CMakeLists.txt
  46. +1 −1 pol-core/plib/RawMap.cpp
  47. +12 −12 pol-core/plib/fsa.h
  48. +1 −1 pol-core/plib/mapserver.cpp
  49. +16 −16 pol-core/plib/pkg.cpp
  50. +13 −13 pol-core/plib/stlastar.h
  51. +2 −0 pol-core/pol/CMakeLists.txt
  52. +6 −6 pol-core/pol/cfgrepos.cpp
  53. +1 −1 pol-core/pol/containr.cpp
  54. +3 −3 pol-core/pol/create.cpp
  55. +2 −2 pol-core/pol/guardrgn.cpp
  56. +1 −1 pol-core/pol/module/sqlmod.cpp
  57. +1 −1 pol-core/pol/module/uomod2.cpp
  58. +1 −1 pol-core/pol/multi/customhouses.cpp
  59. +1 −1 pol-core/pol/npctmpl.cpp
  60. +6 −6 pol-core/pol/poldbg.cpp
  61. +2 −2 pol-core/pol/scrstore.cpp
  62. +1 −1 pol-core/pol/spells.cpp
  63. +5 −5 pol-core/pol/sqlscrobj.cpp
  64. +1 −1 pol-core/pol/uofile00.cpp
  65. +1 −1 pol-core/pol/uofile01.cpp
  66. +1 −1 pol-core/pol/uofile02.cpp
  67. +2 −0 pol-core/poltool/CMakeLists.txt
  68. +1 −1 pol-core/poltool/PolToolMain.cpp
  69. +2 −0 pol-core/runecl/CMakeLists.txt
  70. +2 −0 pol-core/uoconvert/CMakeLists.txt
  71. +5 −5 pol-core/uoconvert/UoConvertMain.cpp
  72. +2 −0 pol-core/uotool/CMakeLists.txt
  73. +7 −7 pol-core/uotool/UoToolMain.cpp
View
@@ -38,9 +38,17 @@ option(ENABLE_USAN "Enables Undefined sanitizer" OFF)
option(ENABLE_MSAN "Enables Memory sanitizer" OFF)
option(ENABLE_TSAN "Enables Thread sanitizer" OFF)
option(ENABLE_TIDY "Enables clang tidy check" OFF)
# e.g "-fix;-checks=modernize-use-nullptr")
set(TIDY_ARGS "" CACHE STRING "clang tidy arguments")
if(${ONLY_ECOMPILE} OR ${ONLY_RUNECL} OR ${ONLY_POL} OR ${ONLY_POLTOOL} OR ${ONLY_UOCONVERT} OR ${ONLY_UOTOOL})
set(BUILD_ALL OFF)
endif()
if(${ENABLE_TIDY})
set(NO_PCH ON)
endif()
include(cmake/init.cmake)
@@ -56,6 +64,22 @@ message("## Output Dir: ${output_bin_dir}")
if (NO_PCH)
message("## No precompiled header")
endif()
if (ENABLE_TIDY)
find_program(
CLANG_TIDY_EXE
NAMES "clang-tidy"
DOC "Path to clang-tidy executable"
)
if(NOT CLANG_TIDY_EXE)
message(ERROR "clang-tidy not found.")
else()
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
message(STATUS "clang-tidy args: ${TIDY_ARGS}")
set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}" "${TIDY_ARGS}")
endif()
endif()
message("")
include(CheckIncludeFiles)
View
@@ -237,3 +237,12 @@ function(warning_suppression target)
>
)
endfunction()
function(use_tidy target)
if (ENABLE_TIDY)
set_target_properties(
${target} PROPERTIES
CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
)
endif()
endfunction()
@@ -19,3 +19,4 @@ if (${linux})
)
endif()
use_tidy(${lib_name})
@@ -451,7 +451,7 @@ inline void BObject::setimp( BObjectImp* imp )
class BObjectRef : public ref_ptr<BObject>
{
public:
explicit BObjectRef( BObject* pobj = NULL ) : ref_ptr<BObject>( pobj ) {}
explicit BObjectRef( BObject* pobj = nullptr ) : ref_ptr<BObject>( pobj ) {}
explicit BObjectRef( BObjectImp* pimp ) : ref_ptr<BObject>( new BObject( pimp ) ) {}
void set( BObject* obj ) { ref_ptr<BObject>::set( obj ); }
size_t sizeEstimate() const;
@@ -483,7 +483,7 @@ class UninitObject final : public BObjectImp
static void ReleaseSharedInstance()
{
SharedInstanceOwner.clear();
SharedInstance = NULL;
SharedInstance = nullptr;
}
};
extern Clib::fixed_allocator<sizeof( UninitObject ), 256> uninit_alloc;
@@ -47,7 +47,7 @@ BStruct::BStruct( std::istream& is, unsigned size, BObjectType type )
{
BObjectImp* keyimp = BObjectImp::unpack( is );
BObjectImp* valimp = BObjectImp::unpack( is );
if ( keyimp != NULL && valimp != NULL && keyimp->isa( OTString ) )
if ( keyimp != nullptr && valimp != nullptr && keyimp->isa( OTString ) )
{
String* str = static_cast<String*>( keyimp );
@@ -144,7 +144,7 @@ BObject* BStructIterator::step()
{
auto itr = m_pStruct->contents_.begin();
if ( itr == m_pStruct->contents_.end() )
return NULL;
return nullptr;
m_First = false;
key = ( *itr ).first;
@@ -157,10 +157,10 @@ BObject* BStructIterator::step()
{
auto itr = m_pStruct->contents_.find( key );
if ( itr == m_pStruct->contents_.end() )
return NULL;
return nullptr;
++itr;
if ( itr == m_pStruct->contents_.end() )
return NULL;
return nullptr;
key = ( *itr ).first;
m_IterVal->setimp( new String( key ) );
@@ -224,7 +224,7 @@ const BObjectImp* BStruct::FindMember( const char* name )
}
else
{
return NULL;
return nullptr;
}
}
@@ -327,7 +327,7 @@ BObjectImp* BStruct::call_method_id( const int id, Executor& ex, bool /*forcebui
return new BError( "struct.size() doesn't take parameters." );
case MTH_ERASE:
if ( ex.numParams() == 1 && ( keyobj = ex.getParamObj( 0 ) ) != NULL )
if ( ex.numParams() == 1 && ( keyobj = ex.getParamObj( 0 ) ) != nullptr )
{
if ( !keyobj->isa( OTString ) )
return new BError( "Struct keys must be strings" );
@@ -341,8 +341,8 @@ BObjectImp* BStruct::call_method_id( const int id, Executor& ex, bool /*forcebui
}
break;
case MTH_INSERT:
if ( ex.numParams() == 2 && ( keyobj = ex.getParamObj( 0 ) ) != NULL &&
( valobj = ex.getParamObj( 1 ) ) != NULL )
if ( ex.numParams() == 2 && ( keyobj = ex.getParamObj( 0 ) ) != nullptr &&
( valobj = ex.getParamObj( 1 ) ) != nullptr )
{
if ( !keyobj->isa( OTString ) )
return new BError( "Struct keys must be strings" );
@@ -356,7 +356,7 @@ BObjectImp* BStruct::call_method_id( const int id, Executor& ex, bool /*forcebui
}
break;
case MTH_EXISTS:
if ( ex.numParams() == 1 && ( keyobj = ex.getParamObj( 0 ) ) != NULL )
if ( ex.numParams() == 1 && ( keyobj = ex.getParamObj( 0 ) ) != nullptr )
{
if ( !keyobj->isa( OTString ) )
return new BError( "Struct keys must be strings" );
@@ -383,17 +383,17 @@ BObjectImp* BStruct::call_method_id( const int id, Executor& ex, bool /*forcebui
return new BError( "struct.keys() doesn't take parameters." );
break;
default:
return NULL;
return nullptr;
}
}
BObjectImp* BStruct::call_method( const char* methodname, Executor& ex )
{
ObjMethod* objmethod = getKnownObjMethod( methodname );
if ( objmethod != NULL )
if ( objmethod != nullptr )
return this->call_method_id( objmethod->id, ex );
else
return NULL;
return nullptr;
}
void BStruct::packonto( std::ostream& os ) const
@@ -70,7 +70,7 @@ int eatToCommentEnd( CompilerContext& ctx )
} // namespace
CompilerContext::CompilerContext()
: s( NULL ), line( 1 ), filename( "" ), s_begin( NULL ), dbg_filenum( 0 )
: s( nullptr ), line( 1 ), filename( "" ), s_begin( nullptr ), dbg_filenum( 0 )
{
}
Oops, something went wrong.

0 comments on commit a5e6206

Please sign in to comment.