@@ -49,12 +49,16 @@ validateModule(llvm::StringRef data, bool Verbose,
49
49
swift::serialization::ValidationInfo &info,
50
50
swift::serialization::ExtendedValidationInfo &extendedInfo) {
51
51
info = swift::serialization::validateSerializedAST (data, &extendedInfo);
52
- if (info.status != swift::serialization::Status::Valid)
52
+ if (info.status != swift::serialization::Status::Valid) {
53
+ llvm::outs () << " error: validateSerializedAST() failed\n " ;
53
54
return false ;
55
+ }
54
56
55
57
swift::CompilerInvocation CI;
56
- if (CI.loadFromSerializedAST (data) != swift::serialization::Status::Valid)
58
+ if (CI.loadFromSerializedAST (data) != swift::serialization::Status::Valid) {
59
+ llvm::outs () << " error: loadFromSerializedAST() failed\n " ;
57
60
return false ;
61
+ }
58
62
59
63
if (Verbose) {
60
64
if (!info.shortVersion .empty ())
@@ -265,6 +269,8 @@ int main(int argc, char **argv) {
265
269
swift::serialization::ValidationInfo info;
266
270
swift::serialization::ExtendedValidationInfo extendedInfo;
267
271
for (auto &Module : Modules) {
272
+ info = {};
273
+ extendedInfo = {};
268
274
if (!validateModule (StringRef (Module.first , Module.second ), Verbose, info,
269
275
extendedInfo)) {
270
276
llvm::errs () << " Malformed module!\n " ;
@@ -282,7 +288,8 @@ int main(int argc, char **argv) {
282
288
reinterpret_cast <void *>(&anchorForGetMainExecutable)));
283
289
284
290
// Infer SDK and Target triple from the module.
285
- Invocation.setSDKPath (extendedInfo.getSDKPath ());
291
+ if (!extendedInfo.getSDKPath ().empty ())
292
+ Invocation.setSDKPath (extendedInfo.getSDKPath ());
286
293
Invocation.setTargetTriple (info.targetTriple );
287
294
288
295
Invocation.setModuleName (" lldbtest" );
@@ -294,13 +301,17 @@ int main(int argc, char **argv) {
294
301
Invocation.setRuntimeResourcePath (ResourceDir);
295
302
}
296
303
297
- if (CI.setup (Invocation))
304
+ if (CI.setup (Invocation)) {
305
+ llvm::errs () << " error: Failed setup invocation!\n " ;
298
306
return 1 ;
307
+ }
299
308
300
309
for (auto &Module : Modules)
301
310
if (!parseASTSection (*CI.getMemoryBufferSerializedModuleLoader (),
302
- StringRef (Module.first , Module.second ), modules))
311
+ StringRef (Module.first , Module.second ), modules)) {
312
+ llvm::errs () << " error: Failed to parse AST section!\n " ;
303
313
return 1 ;
314
+ }
304
315
305
316
// Attempt to import all modules we found.
306
317
for (auto path : modules) {
0 commit comments