Clang: Clean up exceptions

* Extract common stuff into the base class ClangException
* Remove unused exceptions TranslationUnitParseErrorException and
  TranslationUnitReparseErrorException
* Do not send error messages to the Qt Creator side. The messages were
  only generated when the backend crashed and while it was not yet fully
  re-initialized (e.g. do code completion right after crash where the
  document was not yet registered at the backend).

Change-Id: I91d98d5ef681ad487f7a2fd66f78fa7cd1e958df
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Nikolai Kosjar
2016-09-09 15:18:25 +02:00
parent 26cb17bb65
commit cb0e730bb5
8 changed files with 73 additions and 385 deletions

View File

@@ -83,6 +83,21 @@ void TranslationUnitUpdater::removeTranslationUnitIfProjectPartWasChanged()
}
}
#define RETURN_TEXT_FOR_CASE(enumValue) case enumValue: return #enumValue
static const char *errorCodeToText(CXErrorCode errorCode)
{
switch (errorCode) {
RETURN_TEXT_FOR_CASE(CXError_Success);
RETURN_TEXT_FOR_CASE(CXError_Failure);
RETURN_TEXT_FOR_CASE(CXError_Crashed);
RETURN_TEXT_FOR_CASE(CXError_InvalidArguments);
RETURN_TEXT_FOR_CASE(CXError_ASTReadError);
}
return "UnknownCXErrorCode";
}
#undef RETURN_TEXT_FOR_CASE
void TranslationUnitUpdater::createTranslationUnitIfNeeded()
{
if (!m_cxTranslationUnit) {
@@ -109,7 +124,8 @@ void TranslationUnitUpdater::createTranslationUnitIfNeeded()
updateIncludeFilePaths();
updateLastProjectPartChangeTimePoint();
} else {
qWarning() << "Parsing" << m_in.filePath << "failed:" << m_parseErrorCode;
qWarning() << "Parsing" << m_in.filePath << "failed:"
<< errorCodeToText(m_parseErrorCode);
m_out.hasParseOrReparseFailed = true;
}
}