@@ -194,6 +194,20 @@ class Driver::InputInfoMap
194
194
};
195
195
using InputInfoMap = Driver::InputInfoMap;
196
196
197
+ static bool failedToReadOutOfDateMap (bool ShowIncrementalBuildDecisions,
198
+ StringRef buildRecordPath,
199
+ StringRef reason = " " ) {
200
+ if (ShowIncrementalBuildDecisions) {
201
+ llvm::outs () << " Incremental compilation has been disabled due to "
202
+ << " malformed build record file '" << buildRecordPath << " '." ;
203
+ if (!reason.empty ()) {
204
+ llvm::outs () << " " << reason;
205
+ }
206
+ llvm::outs () << " \n " ;
207
+ }
208
+ return true ;
209
+ }
210
+
197
211
static bool populateOutOfDateMap (InputInfoMap &map, StringRef argsHashStr,
198
212
const InputFileList &inputs,
199
213
StringRef buildRecordPath,
@@ -211,11 +225,13 @@ static bool populateOutOfDateMap(InputInfoMap &map, StringRef argsHashStr,
211
225
212
226
auto I = stream.begin ();
213
227
if (I == stream.end () || !I->getRoot ())
214
- return true ;
228
+ return failedToReadOutOfDateMap (ShowIncrementalBuildDecisions,
229
+ buildRecordPath);
215
230
216
231
auto *topLevelMap = dyn_cast<yaml::MappingNode>(I->getRoot ());
217
232
if (!topLevelMap)
218
- return true ;
233
+ return failedToReadOutOfDateMap (ShowIncrementalBuildDecisions,
234
+ buildRecordPath);
219
235
SmallString<64 > scratch;
220
236
221
237
llvm::StringMap<InputInfo> previousInputs;
@@ -269,8 +285,12 @@ static bool populateOutOfDateMap(InputInfoMap &map, StringRef argsHashStr,
269
285
using compilation_record::TopLevelKey;
270
286
if (keyStr == compilation_record::getName (TopLevelKey::Version)) {
271
287
auto *value = dyn_cast<yaml::ScalarNode>(i->getValue ());
272
- if (!value)
273
- return true ;
288
+ if (!value) {
289
+ auto reason = (" Malformed value for key '" + keyStr + " '." )
290
+ .toStringRef (scratch);
291
+ return failedToReadOutOfDateMap (ShowIncrementalBuildDecisions,
292
+ buildRecordPath, reason);
293
+ }
274
294
275
295
// NB: We check against
276
296
// swift::version::Version::getCurrentLanguageVersion() here because any
@@ -289,17 +309,25 @@ static bool populateOutOfDateMap(InputInfoMap &map, StringRef argsHashStr,
289
309
290
310
} else if (keyStr == compilation_record::getName (TopLevelKey::BuildTime)) {
291
311
auto *value = dyn_cast<yaml::SequenceNode>(i->getValue ());
292
- if (!value)
293
- return true ;
312
+ if (!value) {
313
+ auto reason = (" Malformed value for key '" + keyStr + " '." )
314
+ .toStringRef (scratch);
315
+ return failedToReadOutOfDateMap (ShowIncrementalBuildDecisions,
316
+ buildRecordPath, reason);
317
+ }
294
318
llvm::sys::TimeValue timeVal;
295
319
if (readTimeValue (i->getValue (), timeVal))
296
320
return true ;
297
321
map[nullptr ] = { InputInfo::NeedsCascadingBuild, timeVal };
298
322
299
323
} else if (keyStr == compilation_record::getName (TopLevelKey::Inputs)) {
300
324
auto *inputMap = dyn_cast<yaml::MappingNode>(i->getValue ());
301
- if (!inputMap)
302
- return true ;
325
+ if (!inputMap) {
326
+ auto reason = (" Malformed value for key '" + keyStr + " '." )
327
+ .toStringRef (scratch);
328
+ return failedToReadOutOfDateMap (ShowIncrementalBuildDecisions,
329
+ buildRecordPath, reason);
330
+ }
303
331
304
332
// FIXME: LLVM's YAML support does incremental parsing in such a way that
305
333
// for-range loops break.
0 commit comments