@@ -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 ())
@@ -260,6 +264,8 @@ int main(int argc, char **argv) {
260
264
swift::serialization::ValidationInfo info;
261
265
swift::serialization::ExtendedValidationInfo extendedInfo;
262
266
for (auto &Module : Modules) {
267
+ info = {};
268
+ extendedInfo = {};
263
269
if (!validateModule (StringRef (Module.first , Module.second ), Verbose, info,
264
270
extendedInfo)) {
265
271
llvm::errs () << " Malformed module!\n " ;
@@ -277,7 +283,8 @@ int main(int argc, char **argv) {
277
283
reinterpret_cast <void *>(&anchorForGetMainExecutable)));
278
284
279
285
// Infer SDK and Target triple from the module.
280
- Invocation.setSDKPath (extendedInfo.getSDKPath ());
286
+ if (!extendedInfo.getSDKPath ().empty ())
287
+ Invocation.setSDKPath (extendedInfo.getSDKPath ());
281
288
Invocation.setTargetTriple (info.targetTriple );
282
289
283
290
Invocation.setModuleName (" lldbtest" );
@@ -289,13 +296,17 @@ int main(int argc, char **argv) {
289
296
Invocation.setRuntimeResourcePath (ResourceDir);
290
297
}
291
298
292
- if (CI.setup (Invocation))
299
+ if (CI.setup (Invocation)) {
300
+ llvm::errs () << " error: Failed setup invocation!\n " ;
293
301
return 1 ;
302
+ }
294
303
295
304
for (auto &Module : Modules)
296
305
if (!parseASTSection (*CI.getMemoryBufferSerializedModuleLoader (),
297
- StringRef (Module.first , Module.second ), modules))
306
+ StringRef (Module.first , Module.second ), modules)) {
307
+ llvm::errs () << " error: Failed to parse AST section!\n " ;
298
308
return 1 ;
309
+ }
299
310
300
311
// Attempt to import all modules we found.
301
312
for (auto path : modules) {
0 commit comments