Skip to content

Commit d464de3

Browse files
committed
Catch exception raised when parsing
It seems Clang can arbitrarily raise errors (transient NULL-byte reads from files that exist). Handle those errors by retrying the parsing step 3 times, just in case it goes away.
1 parent a92cbf8 commit d464de3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/docurium/docparser.rb

+12-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,18 @@ def parse_file(orig_filename, opts = {})
7070
args = includes.map { |path| "-I#{path}" }
7171
args << '-ferror-limit=1'
7272

73-
tu = Index.new(true, true).parse_translation_unit(filename, args, @unsaved, {:detailed_preprocessing_record => 1})
73+
attempts = 1
74+
begin
75+
tu = Index.new(true, true).parse_translation_unit(filename, args, @unsaved, {:detailed_preprocessing_record => 1})
76+
rescue Exception => e
77+
attempts += 1
78+
if attempts <= 3
79+
debug "parsing failed: #{e.inspect}, retrying..."
80+
retry
81+
end
82+
puts "Exception raised while parsing #{filename}: #{e.inspect}"
83+
return []
84+
end
7485

7586
recs = []
7687

0 commit comments

Comments
 (0)