X Tutup
Skip to content

Commit 7da155c

Browse files
acm4mePKEuS
authored andcommitted
Support for Sun Studio C++ compiler
1 parent bfb82fe commit 7da155c

File tree

12 files changed

+103
-93
lines changed

12 files changed

+103
-93
lines changed

cli/cmdlineparser.cpp

Lines changed: 57 additions & 57 deletions
Large diffs are not rendered by default.

cli/threadexecutor.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
#include <errno.h>
4141
#endif
4242

43+
// required for FD_ZERO
44+
using std::memset;
45+
4346
ThreadExecutor::ThreadExecutor(const std::map<std::string, std::size_t> &files, Settings &settings, ErrorLogger &errorLogger)
4447
: _files(files), _settings(settings), _errorLogger(errorLogger), _fileCount(0)
4548
{
@@ -82,19 +85,19 @@ int ThreadExecutor::handleRead(int rpipe, unsigned int &result)
8285

8386
if (type != REPORT_OUT && type != REPORT_ERROR && type != REPORT_INFO && type != CHILD_END) {
8487
std::cerr << "#### You found a bug from cppcheck.\nThreadExecutor::handleRead error, type was:" << type << std::endl;
85-
exit(0);
88+
std::exit(0);
8689
}
8790

8891
unsigned int len = 0;
8992
if (read(rpipe, &len, sizeof(len)) <= 0) {
9093
std::cerr << "#### You found a bug from cppcheck.\nThreadExecutor::handleRead error, type was:" << type << std::endl;
91-
exit(0);
94+
std::exit(0);
9295
}
9396

9497
char *buf = new char[len];
9598
if (read(rpipe, buf, len) <= 0) {
9699
std::cerr << "#### You found a bug from cppcheck.\nThreadExecutor::handleRead error, type was:" << type << std::endl;
97-
exit(0);
100+
std::exit(0);
98101
}
99102

100103
if (type == REPORT_OUT) {
@@ -154,26 +157,26 @@ unsigned int ThreadExecutor::check()
154157
if (i != _files.end() && rpipes.size() < _settings._jobs) {
155158
int pipes[2];
156159
if (pipe(pipes) == -1) {
157-
std::cerr << "pipe() failed: "<< strerror(errno) << std::endl;
158-
exit(EXIT_FAILURE);
160+
std::cerr << "pipe() failed: "<< std::strerror(errno) << std::endl;
161+
std::exit(EXIT_FAILURE);
159162
}
160163

161164
int flags = 0;
162165
if ((flags = fcntl(pipes[0], F_GETFL, 0)) < 0) {
163-
std::cerr << "fcntl(F_GETFL) failed: "<< strerror(errno) << std::endl;
164-
exit(EXIT_FAILURE);
166+
std::cerr << "fcntl(F_GETFL) failed: "<< std::strerror(errno) << std::endl;
167+
std::exit(EXIT_FAILURE);
165168
}
166169

167170
if (fcntl(pipes[0], F_SETFL, flags | O_NONBLOCK) < 0) {
168-
std::cerr << "fcntl(F_SETFL) failed: "<< strerror(errno) << std::endl;
169-
exit(EXIT_FAILURE);
171+
std::cerr << "fcntl(F_SETFL) failed: "<< std::strerror(errno) << std::endl;
172+
std::exit(EXIT_FAILURE);
170173
}
171174

172175
pid_t pid = fork();
173176
if (pid < 0) {
174177
// Error
175-
std::cerr << "Failed to create child process: "<< strerror(errno) << std::endl;
176-
exit(EXIT_FAILURE);
178+
std::cerr << "Failed to create child process: "<< std::strerror(errno) << std::endl;
179+
std::exit(EXIT_FAILURE);
177180
} else if (pid == 0) {
178181
close(pipes[0]);
179182
_wpipe = pipes[1];
@@ -193,7 +196,7 @@ unsigned int ThreadExecutor::check()
193196
std::ostringstream oss;
194197
oss << resultOfCheck;
195198
writeToPipe(CHILD_END, oss.str());
196-
exit(0);
199+
std::exit(0);
197200
}
198201

199202
close(pipes[1]);
@@ -288,7 +291,7 @@ void ThreadExecutor::writeToPipe(PipeSignal type, const std::string &data)
288291
delete [] out;
289292
out = 0;
290293
std::cerr << "#### ThreadExecutor::writeToPipe, Failed to write to pipe" << std::endl;
291-
exit(0);
294+
std::exit(0);
292295
}
293296

294297
delete [] out;

lib/checkmemoryleak.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static const char * const call_func_white_list[] = {
9494

9595
static int call_func_white_list_compare(const void *a, const void *b)
9696
{
97-
return strcmp((const char *)a, *(const char * const *)b);
97+
return std::strcmp((const char *)a, *(const char * const *)b);
9898
}
9999

100100
//---------------------------------------------------------------------------

lib/checkuninitvar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ std::set<std::string> UninitVar::uvarFunctions;
10151015
/// @}
10161016

10171017

1018-
void CheckUninitVar::analyse(const Token * const tokens, std::set<std::string> &func) const
1018+
void CheckUninitVar::analyse(const Token * tokens, std::set<std::string> &func) const
10191019
{
10201020
UninitVar::analyseFunctions(tokens, func);
10211021
}

lib/checkunusedvar.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -750,9 +750,9 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
750750
// bailout when for_each is used
751751
if (Token::Match(tok,"%var% (") && Token::simpleMatch(tok->linkAt(1),") {")) {
752752
// does the name contain "for_each" or "foreach"?
753-
std::string name(tok->str());
754-
std::transform(name.begin(),name.end(),name.begin(),static_cast<int(*)(int)>(std::tolower));
755-
if (name.find("foreach") != std::string::npos || name.find("for_each") != std::string::npos) {
753+
std::string nameTok(tok->str());
754+
std::transform(nameTok.begin(),nameTok.end(),nameTok.begin(),::tolower);
755+
if (nameTok.find("foreach") != std::string::npos || nameTok.find("for_each") != std::string::npos) {
756756
// bailout all variables in the body that are used more than once.
757757
// TODO: there is no need to bailout if variable is only read or only written
758758
std::set<unsigned int> varid;

lib/mathlib.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ std::string MathLib::mod(const std::string &first, const std::string &second)
304304
throw InternalError(0, "Internal Error: Division by zero");
305305
return longToString(toLongNumber(first) % b);
306306
}
307-
return doubleToString(fmod(toDoubleNumber(first),toDoubleNumber(second)));
307+
return doubleToString(std::fmod(toDoubleNumber(first),toDoubleNumber(second)));
308308
}
309309

310310
std::string MathLib::calculate(const std::string &first, const std::string &second, char action)

lib/path.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ std::string Path::fromNativeSeparators(std::string path)
5858
std::string Path::simplifyPath(const char *originalPath)
5959
{
6060
// Skip ./ at the beginning
61-
if (strlen(originalPath) > 2 && originalPath[0] == '.' &&
61+
if (std::strlen(originalPath) > 2 && originalPath[0] == '.' &&
6262
originalPath[1] == '/') {
6363
originalPath += 2;
6464
}

lib/symboldatabase.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@
3535
#define LLONG_MAX LONG_MAX
3636
#endif
3737

38+
// Define ULLONG_MAX and LLONG_MAX for SunCC on non-Solaris systems
39+
#if (defined(__SUNPRO_C) || defined(__SUNPRO_CC)) && \
40+
!(defined (__sun) || defined (__sun__))
41+
#define ULLONG_MAX ULONG_MAX
42+
#define LLONG_MAX LONG_MAX
43+
#endif
44+
3845
//---------------------------------------------------------------------------
3946

4047
SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)

lib/token.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ const std::string &Token::strAt(int index) const
322322
static bool strisop(const char str[])
323323
{
324324
if (str[1] == 0) {
325-
if (strchr("+-*/%&|^~!<>", *str))
325+
if (std::strchr("+-*/%&|^~!<>", *str))
326326
return true;
327327
} else if (str[2] == 0) {
328328
if ((str[0] == '&' && str[1] == '&') ||
@@ -469,21 +469,21 @@ bool Token::simpleMatch(const Token *tok, const char pattern[])
469469
const char *current, *next;
470470

471471
current = pattern;
472-
next = strchr(pattern, ' ');
472+
next = std::strchr(pattern, ' ');
473473
if (!next)
474-
next = pattern + strlen(pattern);
474+
next = pattern + std::strlen(pattern);
475475

476476
while (*current) {
477477
std::size_t length = static_cast<std::size_t>(next - current);
478478

479-
if (!tok || length != tok->_str.length() || strncmp(current, tok->_str.c_str(), length))
479+
if (!tok || length != tok->_str.length() || std::strncmp(current, tok->_str.c_str(), length))
480480
return false;
481481

482482
current = next;
483483
if (*next) {
484-
next = strchr(++current, ' ');
484+
next = std::strchr(++current, ' ');
485485
if (!next)
486-
next = current + strlen(current);
486+
next = current + std::strlen(current);
487487
}
488488
tok = tok->next();
489489
}
@@ -691,7 +691,7 @@ bool Token::Match(const Token *tok, const char pattern[], unsigned int varid)
691691
break;
692692
default:
693693
//unknown %cmd%, abort
694-
abort();
694+
std::abort();
695695
}
696696
}
697697

lib/token.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ class CPPCHECKLIB Token {
306306
* @param prepend Insert the new token before this token when it's not
307307
* the first one on the tokens list.
308308
*/
309-
void insertToken(const std::string &tokenStr, const bool prepend=false);
309+
void insertToken(const std::string &tokenStr, bool prepend=false);
310310

311311
Token *previous() const {
312312
return _previous;

0 commit comments

Comments
 (0)
X Tutup