Skip to content

Commit 29f5294

Browse files
authored
Merge branch 'master' into cpp_imsvc_support
2 parents be0b861 + 9ce9158 commit 29f5294

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

cpp/ycm/ClangCompleter/TranslationUnit.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,21 @@ void TranslationUnit::UpdateLatestDiagnostics() {
482482
clang_disposeDiagnostic ),
483483
clang_translation_unit_ );
484484

485-
if ( diagnostic.kind_ != DiagnosticKind::INFORMATION ) {
486-
latest_diagnostics_.push_back( diagnostic );
485+
if ( diagnostic.kind_ == DiagnosticKind::INFORMATION ) {
486+
continue;
487487
}
488+
489+
// Sometimes libclang returns invalid ranges causing ycm in trouble
490+
// Specially editing incomplete macros
491+
diagnostic.ranges_.erase( std::remove_if( diagnostic.ranges_.begin(),
492+
diagnostic.ranges_.end(),
493+
[]( const auto &range ) -> bool {
494+
return range.start_.line_number_ == 0 ||
495+
range.start_.column_number_ == 0 ||
496+
range.end_.line_number_ == 0 ||
497+
range.end_.column_number_ == 0;
498+
} ), diagnostic.ranges_.end() );
499+
latest_diagnostics_.push_back( diagnostic );
488500
}
489501
}
490502

ycmd/tests/clang/diagnostics_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,6 @@ def test_Diagnostics_LocationExtent_MissingSemicolon( self, app ):
265265
'location': LocationMatcher( filepath, 8, 7 ),
266266
'location_extent': RangeMatcher( filepath, ( 8, 7 ), ( 8, 11 ) ),
267267
'ranges': contains_exactly(
268-
# FIXME: empty ranges from libclang should be ignored.
269-
RangeMatcher( '', ( 0, 0 ), ( 0, 0 ) ),
270268
RangeMatcher( filepath, ( 8, 7 ), ( 8, 11 ) )
271269
),
272270
'text': equal_to( 'constructor cannot have a return type' ),

0 commit comments

Comments
 (0)