forked from qt-creator/qt-creator
C++: Avoid printing to stderr and calling exit()
We are not a compiler. Change-Id: I57d8283759d2587b890ff9bc1ca0c173cd910683 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
38
src/libs/3rdparty/cplusplus/TranslationUnit.cpp
vendored
38
src/libs/3rdparty/cplusplus/TranslationUnit.cpp
vendored
@@ -446,25 +446,8 @@ void TranslationUnit::message(DiagnosticClient::Level level, unsigned index, con
|
||||
const StringLiteral *fileName = 0;
|
||||
getTokenPosition(index, &line, &column, &fileName);
|
||||
|
||||
if (DiagnosticClient *client = control()->diagnosticClient()) {
|
||||
if (DiagnosticClient *client = control()->diagnosticClient())
|
||||
client->report(level, fileName, line, column, format, args);
|
||||
} else {
|
||||
fprintf(stderr, "%s:%u: ", fileName->chars(), line);
|
||||
const char *l = "error";
|
||||
if (level == DiagnosticClient::Warning)
|
||||
l = "warning";
|
||||
else if (level == DiagnosticClient::Fatal)
|
||||
l = "fatal";
|
||||
fprintf(stderr, "%s: ", l);
|
||||
|
||||
vfprintf(stderr, format, args);
|
||||
fputc('\n', stderr);
|
||||
|
||||
showErrorLine(index, column, stderr);
|
||||
}
|
||||
|
||||
if (level == DiagnosticClient::Fatal)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
void TranslationUnit::warning(unsigned index, const char *format, ...)
|
||||
@@ -553,25 +536,6 @@ void TranslationUnit::releaseTokensAndComments()
|
||||
_comments = 0;
|
||||
}
|
||||
|
||||
void TranslationUnit::showErrorLine(unsigned index, unsigned column, FILE *out)
|
||||
{
|
||||
unsigned lineOffset = _lineOffsets[findLineNumber(tokenAt(index).utf16charsBegin())];
|
||||
for (const char *cp = _firstSourceChar + lineOffset + 1; *cp && *cp != '\n'; ++cp) {
|
||||
fputc(*cp, out);
|
||||
}
|
||||
fputc('\n', out);
|
||||
|
||||
const char *end = _firstSourceChar + lineOffset + 1 + column - 1;
|
||||
for (const char *cp = _firstSourceChar + lineOffset + 1; cp != end; ++cp) {
|
||||
if (*cp != '\t')
|
||||
fputc(' ', out);
|
||||
else
|
||||
fputc('\t', out);
|
||||
}
|
||||
fputc('^', out);
|
||||
fputc('\n', out);
|
||||
}
|
||||
|
||||
void TranslationUnit::resetAST()
|
||||
{
|
||||
delete _pool;
|
||||
|
||||
@@ -174,7 +174,6 @@ private:
|
||||
unsigned findLineNumber(unsigned utf16charOffset) const;
|
||||
unsigned findColumnNumber(unsigned utf16CharOffset, unsigned lineNumber) const;
|
||||
PPLine findPreprocessorLine(unsigned utf16charOffset) const;
|
||||
void showErrorLine(unsigned index, unsigned column, FILE *out);
|
||||
|
||||
static const Token nullToken;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user