• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

polserver / polserver / 21047054485

15 Jan 2026 09:31PM UTC coverage: 60.507% (-0.001%) from 60.508%
21047054485

push

github

web-flow
Clang Tidy default constructor  (#852)

* trigger clang tidy

* Automated clang-tidy change: modernize-use-equals-default

* compile test

---------

Co-authored-by: Clang Tidy <clang-tidy@users.noreply.github.com>

58 of 75 new or added lines in 41 files covered. (77.33%)

1 existing line in 1 file now uncovered.

44460 of 73479 relevant lines covered (60.51%)

507363.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.23
/pol-core/clib/Program/ProgramMain.cpp
1
#include "ProgramMain.h"
2

3
#include <stdlib.h>
4

5
#include <boost/stacktrace.hpp>
6

7
#include "../Debugging/ExceptionParser.h"
8
#include "../logfacility.h"
9
#include "ProgramConfig.h"
10
#include "pol_global_config.h"
11

12
#ifdef ENABLE_BENCHMARK
13
#include <benchmark/benchmark.h>
14
#endif
15

16
#ifdef _WIN32
17
#define WIN32_LEAN_AND_MEAN
18
#include "../Header_Windows.h"
19
#include <crtdbg.h>
20
#include <psapi.h>
21
#include <windows.h>  // for GetModuleFileName
22

23
#pragma comment( lib, "psapi.lib" )  // 32bit is a bit dumb..
24
#else
25
#endif
26
#include <clocale>
27
#include <cstdlib>
28
#include <exception>
29
#include <iostream>
30
#include <stdexcept>
31
#include <string>
32

33
namespace Pol
34
{
35
namespace Clib
36
{
37
using namespace std;
38

39

40
// last resort: print backtrace on terminate
41
void terminate_handler()
×
42
{
43
  try
44
  {
45
    std::cerr << "Terminate failure:\n" << boost::stacktrace::stacktrace() << std::endl;
×
46
  }
47
  catch ( ... )
×
48
  {
49
  }
×
50
  std::abort();
×
51
}
52

53
///////////////////////////////////////////////////////////////////////////////
54

55
ProgramMain::ProgramMain() = default;
4,959✔
NEW
56
ProgramMain::~ProgramMain() = default;
×
57
///////////////////////////////////////////////////////////////////////////////
58

59
void ProgramMain::start( int argc, char* argv[] )
4,959✔
60
{
61
  using namespace Pol;
62
  Clib::Logging::LogFacility logger;
4,959✔
63
  Clib::Logging::initLogging( &logger );
4,959✔
64
  Clib::ExceptionParser::initGlobalExceptionCatching();
4,959✔
65
  std::set_terminate( &terminate_handler );
4,959✔
66

67
  std::setlocale( LC_TIME, "" );
4,959✔
68
  std::setlocale( LC_CTYPE, "en_US.UTF-8" );  // unicode aware strings, unsure if english is enough,
4,959✔
69
                                              // or if it needs to be a user defined value
70

71
  int exitcode = 0;
4,959✔
72

73
  try
74
  {
75
// FIXME: 2008 Upgrades needed here? Make sure this still valid on 2008
76
#if defined( _WIN32 ) && defined( _DEBUG ) && _MSC_VER >= 1300
77
    // on VS.NET, disable obnoxious heap checking
78
    int flags = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
79
    flags &= 0x0000FFFF;  // set heap check frequency to 0
80
    _CrtSetDbgFlag( flags );
81
#endif
82

83
    /**********************************************
84
     * store program arguments
85
     **********************************************/
86
    m_programArguments.clear();
4,959✔
87
    for ( int i = 0; i < argc; i++ )
27,261✔
88
    {
89
      m_programArguments.push_back( std::string( argv[i] ) );
22,302✔
90
    }
91

92
    /**********************************************
93
     * determine and store the executable name
94
     **********************************************/
95
    std::string binaryPath = argv[0];
4,959✔
96
#ifdef WINDOWS
97
    char modulePath[_MAX_PATH];
98
    if ( GetModuleFileName( nullptr, modulePath, sizeof modulePath ) )
99
      binaryPath = modulePath;
100
#endif
101
    PROG_CONFIG::configureProgramEnvironment( binaryPath );
4,959✔
102

103
#ifdef ENABLE_BENCHMARK
104
    benchmark::Initialize( &argc, argv );
105
#endif
106

107
    /**********************************************
108
     * MAIN
109
     **********************************************/
110
    exitcode = main();
4,959✔
111
  }
4,959✔
112
  catch ( const char* msg )
309✔
113
  {
114
    ERROR_PRINTLN( "Execution aborted due to: {}", msg );
×
115
    exitcode = 1;
×
116
  }
×
117
  catch ( std::string& str )
×
118
  {
119
    ERROR_PRINTLN( "Execution aborted due to: {}", str );
×
120
    exitcode = 1;
×
NEW
121
  }  // egcs has some trouble realizing 'exception' should catch
×
122
  catch ( std::runtime_error& re )  // runtime_errors, so...
309✔
123
  {
124
    ERROR_PRINTLN( "Execution aborted due to: {}", re.what() );
309✔
125
    exitcode = 1;
309✔
126
  }
309✔
127
  catch ( std::exception& ex )
×
128
  {
129
    ERROR_PRINTLN( "Execution aborted due to: {}", ex.what() );
×
130
    exitcode = 1;
×
131
  }
×
132
  catch ( int xn )
×
133
  {
134
    // Something that throws an integer is responsible for printing
135
    // its own error message.
136
    // "throw 3" is meant as an alternative to exit(3).
137
    exitcode = xn;
×
138
  }
×
139
#ifndef _WIN32
140
  catch ( ... )
×
141
  {
142
    ERROR_PRINTLN( "Execution aborted due to generic exception." );
×
143
    exitcode = 2;
×
144
  }
×
145
#endif
146
  Clib::Logging::global_logger->wait_for_empty_queue();
4,959✔
147

148
  exit( exitcode );
4,959✔
149
}
×
150

151
const std::vector<std::string>& ProgramMain::programArgs() const
14,968✔
152
{
153
  return m_programArguments;
14,968✔
154
}
155

156
bool ProgramMain::programArgsFind( const std::string& filter, std::string* rest ) const
7,943✔
157
{
158
  const std::vector<std::string>& binArgs = programArgs();
7,943✔
159
  for ( size_t i = 1; i < binArgs.size(); i++ )
19,853✔
160
  {
161
    const std::string& param = binArgs[i];
13,896✔
162
    switch ( param[0] )
13,896✔
163
    {
164
    case '/':
7,941✔
165
    case '-':
166
      if ( param.substr( 1, filter.size() ) == filter )
7,941✔
167
      {
168
        if ( rest != nullptr )
1,986✔
169
          *rest = param.substr( 1 + filter.size(), param.size() - ( 1 + filter.size() ) );
×
170
        return true;
1,986✔
171
      }
172
      break;
5,955✔
173
    default:
5,955✔
174
      break;
5,955✔
175
    }
176
  }
177
  return false;
5,957✔
178
}
179

180
std::string ProgramMain::programArgsFindEquals( const std::string& filter,
84✔
181
                                                std::string defaultVal ) const
182
{
183
  const std::vector<std::string>& binArgs = programArgs();
84✔
184
  for ( size_t i = 1; i < binArgs.size(); i++ )
361✔
185
  {
186
    const std::string& param = binArgs[i];
325✔
187
    if ( param.substr( 0, filter.size() ) == filter )
325✔
188
      return param.substr( filter.size(), param.size() - ( filter.size() ) );
48✔
189
  }
190
  return defaultVal;
36✔
191
}
192

193
int ProgramMain::programArgsFindEquals( const std::string& filter, int defaultVal,
58✔
194
                                        bool hexVal ) const
195
{
196
  std::string val = programArgsFindEquals( filter, "" );
58✔
197
  if ( val.empty() )
58✔
198
    return defaultVal;
36✔
199
  return strtoul( val.c_str(), nullptr, hexVal ? 16 : 10 );
22✔
200
}
58✔
201
}  // namespace Clib
202
}  // namespace Pol
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc