Clang: Filter out invalid diagnostic ranges

Apparently libclang might return invalid ranges.

Now we discard the invalid ranges. Since there is a diagnostic location
(in addition to ranges) the editor will still display an indication for
the user.

Task-number: QTCREATORBUG-15272
Change-Id: I351e136b9925a53fb2273a394e17873c5533798d
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
This commit is contained in:
Nikolai Kosjar
2015-11-02 10:39:08 +01:00
parent 8f2ad8d246
commit 08fcb7f317
5 changed files with 45 additions and 4 deletions

View File

@@ -39,6 +39,16 @@ SourceRange::SourceRange()
{
}
bool SourceRange::isNull() const
{
return clang_Range_isNull(cxSourceRange);
}
bool SourceRange::isValid() const
{
return !isNull() && start().offset() < end().offset();
}
SourceLocation SourceRange::start() const
{
return SourceLocation(clang_getRangeStart(cxSourceRange));