Clang: Avoid parse loop if libclang crashed or file vanished

Remember whether clang_parseTranslationUnit() or
clang_reparseTranslationUnit() failed the last time and do not trigger
parse/reparse again.

Also, check whether the main file exists before reparsing.

Task-number: QTCREATORBUG-16051
Task-number: QTCREATORBUG-16140
Change-Id: Ied39e66a18032854911229898573941fe2ada35b
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
This commit is contained in:
Nikolai Kosjar
2016-04-22 15:31:49 +02:00
parent 66e9cb0a54
commit 7b7b1823cb
9 changed files with 251 additions and 27 deletions

View File

@@ -91,6 +91,8 @@ public:
void reset();
void reparse() const;
bool isIntact() const;
CXIndex index() const;
CXTranslationUnit cxTranslationUnit() const;
CXTranslationUnit cxTranslationUnitWithoutReparsing() const;
@@ -150,10 +152,14 @@ private:
bool projectPartIsOutdated() const;
bool isMainFileAndExistsOrIsOtherFile(const Utf8String &filePath) const;
void createTranslationUnitIfNeeded() const;
void checkTranslationUnitErrorCode(CXErrorCode errorCode) const;
void checkParseErrorCode() const;
void checkReparseErrorCode() const;
void reparseTranslationUnit() const;
void reparseTranslationUnitIfFilesAreChanged() const;
bool parseWasSuccessful() const;
bool reparseWasSuccessful() const;
void updateIncludeFilePaths() const;
bool fileExists() const;
static void includeCallback(CXFile included_file,
CXSourceLocation * /*inclusion_stack*/,
unsigned /*include_len*/,