16
16
// along with ycmd. If not, see <http://www.gnu.org/licenses/>.
17
17
18
18
#include " ClangCompleter.h"
19
- #include " exceptions.h"
20
19
#include " Result.h"
21
20
#include " Candidate.h"
22
21
#include " TranslationUnit.h"
@@ -83,21 +82,15 @@ std::vector< Diagnostic > ClangCompleter::UpdateTranslationUnit(
83
82
flags,
84
83
translation_unit_created );
85
84
86
- if ( !unit )
87
- return std::vector< Diagnostic >();
88
-
89
85
try {
90
86
return unit->Reparse ( unsaved_files );
91
- }
92
-
93
- catch ( ClangParseError & ) {
87
+ } catch ( const ClangParseError & ) {
94
88
// If unit->Reparse fails, then the underlying TranslationUnit object is not
95
89
// valid anymore and needs to be destroyed and removed from the filename ->
96
90
// TU map.
97
91
translation_unit_store_.Remove ( filename );
92
+ throw ;
98
93
}
99
-
100
- return std::vector< Diagnostic >();
101
94
}
102
95
103
96
@@ -112,9 +105,6 @@ ClangCompleter::CandidatesForLocationInFile(
112
105
shared_ptr< TranslationUnit > unit =
113
106
translation_unit_store_.GetOrCreate ( filename, unsaved_files, flags );
114
107
115
- if ( !unit )
116
- return std::vector< CompletionData >();
117
-
118
108
return unit->CandidatesForLocation ( line,
119
109
column,
120
110
unsaved_files );
@@ -132,10 +122,6 @@ Location ClangCompleter::GetDeclarationLocation(
132
122
shared_ptr< TranslationUnit > unit =
133
123
translation_unit_store_.GetOrCreate ( filename, unsaved_files, flags );
134
124
135
- if ( !unit ) {
136
- return Location ();
137
- }
138
-
139
125
return unit->GetDeclarationLocation ( line, column, unsaved_files, reparse );
140
126
}
141
127
@@ -151,10 +137,6 @@ Location ClangCompleter::GetDefinitionLocation(
151
137
shared_ptr< TranslationUnit > unit =
152
138
translation_unit_store_.GetOrCreate ( filename, unsaved_files, flags );
153
139
154
- if ( !unit ) {
155
- return Location ();
156
- }
157
-
158
140
return unit->GetDefinitionLocation ( line, column, unsaved_files, reparse );
159
141
}
160
142
@@ -170,10 +152,6 @@ std::string ClangCompleter::GetTypeAtLocation(
170
152
shared_ptr< TranslationUnit > unit =
171
153
translation_unit_store_.GetOrCreate ( filename, unsaved_files, flags );
172
154
173
- if ( !unit ) {
174
- return " no unit" ;
175
- }
176
-
177
155
return unit->GetTypeAtLocation ( line, column, unsaved_files, reparse );
178
156
}
179
157
@@ -189,10 +167,6 @@ std::string ClangCompleter::GetEnclosingFunctionAtLocation(
189
167
shared_ptr< TranslationUnit > unit =
190
168
translation_unit_store_.GetOrCreate ( filename, unsaved_files, flags );
191
169
192
- if ( !unit ) {
193
- return " no unit" ;
194
- }
195
-
196
170
return unit->GetEnclosingFunctionAtLocation ( line,
197
171
column,
198
172
unsaved_files,
@@ -213,10 +187,6 @@ ClangCompleter::GetFixItsForLocationInFile(
213
187
shared_ptr< TranslationUnit > unit =
214
188
translation_unit_store_.GetOrCreate ( filename, unsaved_files, flags );
215
189
216
- if ( !unit ) {
217
- return std::vector< FixIt >();
218
- }
219
-
220
190
return unit->GetFixItsForLocationInFile ( line,
221
191
column,
222
192
unsaved_files,
@@ -237,10 +207,6 @@ DocumentationData ClangCompleter::GetDocsForLocationInFile(
237
207
shared_ptr< TranslationUnit > unit =
238
208
translation_unit_store_.GetOrCreate ( filename, unsaved_files, flags );
239
209
240
- if ( !unit ) {
241
- return DocumentationData ();
242
- }
243
-
244
210
return unit->GetDocsForLocationInFile ( line,
245
211
column,
246
212
unsaved_files,
0 commit comments