@@ -945,6 +945,91 @@ void swift::serialization::diagnoseSerializedASTLoadFailure(
945
945
moduleDocBufferID);
946
946
break ;
947
947
948
+ case serialization::Status::MissingDependency:
949
+ case serialization::Status::CircularDependency:
950
+ case serialization::Status::MissingUnderlyingModule:
951
+ serialization::diagnoseSerializedASTLoadFailureTransitive (
952
+ Ctx, diagLoc, loadInfo.status ,
953
+ loadedModuleFile, ModuleName, /* forTestable*/ false );
954
+ break ;
955
+
956
+ case serialization::Status::FailedToLoadBridgingHeader:
957
+ // We already emitted a diagnostic about the bridging header. Just emit
958
+ // a generic message here.
959
+ Ctx.Diags .diagnose (diagLoc, diag::serialization_load_failed,
960
+ ModuleName.str ());
961
+ break ;
962
+
963
+ case serialization::Status::NameMismatch: {
964
+ // FIXME: This doesn't handle a non-debugger REPL, which should also treat
965
+ // this as a non-fatal error.
966
+ auto diagKind = diag::serialization_name_mismatch;
967
+ if (Ctx.LangOpts .DebuggerSupport )
968
+ diagKind = diag::serialization_name_mismatch_repl;
969
+ Ctx.Diags .diagnose (diagLoc, diagKind, loadInfo.name , ModuleName.str ());
970
+ break ;
971
+ }
972
+
973
+ case serialization::Status::TargetIncompatible: {
974
+ // FIXME: This doesn't handle a non-debugger REPL, which should also treat
975
+ // this as a non-fatal error.
976
+ auto diagKind = diag::serialization_target_incompatible;
977
+ if (Ctx.LangOpts .DebuggerSupport ||
978
+ Ctx.LangOpts .AllowModuleWithCompilerErrors )
979
+ diagKind = diag::serialization_target_incompatible_repl;
980
+ Ctx.Diags .diagnose (diagLoc, diagKind, ModuleName, loadInfo.targetTriple ,
981
+ moduleBufferID);
982
+ break ;
983
+ }
984
+
985
+ case serialization::Status::TargetTooNew: {
986
+ llvm::Triple moduleTarget (llvm::Triple::normalize (loadInfo.targetTriple ));
987
+
988
+ std::pair<StringRef, clang::VersionTuple> moduleOSInfo =
989
+ getOSAndVersionForDiagnostics (moduleTarget);
990
+ std::pair<StringRef, clang::VersionTuple> compilationOSInfo =
991
+ getOSAndVersionForDiagnostics (Ctx.LangOpts .Target );
992
+
993
+ // FIXME: This doesn't handle a non-debugger REPL, which should also treat
994
+ // this as a non-fatal error.
995
+ auto diagKind = diag::serialization_target_too_new;
996
+ if (Ctx.LangOpts .DebuggerSupport ||
997
+ Ctx.LangOpts .AllowModuleWithCompilerErrors )
998
+ diagKind = diag::serialization_target_too_new_repl;
999
+ Ctx.Diags .diagnose (diagLoc, diagKind, compilationOSInfo.first ,
1000
+ compilationOSInfo.second , ModuleName,
1001
+ moduleOSInfo.second , moduleBufferID);
1002
+ break ;
1003
+ }
1004
+
1005
+ case serialization::Status::SDKMismatch:
1006
+ auto currentSDK = Ctx.LangOpts .SDKName ;
1007
+ auto moduleSDK = loadInfo.sdkName ;
1008
+ Ctx.Diags .diagnose (diagLoc, diag::serialization_sdk_mismatch,
1009
+ ModuleName, moduleSDK, currentSDK, moduleBufferID);
1010
+ break ;
1011
+ }
1012
+ }
1013
+
1014
+ void swift::serialization::diagnoseSerializedASTLoadFailureTransitive (
1015
+ ASTContext &Ctx, SourceLoc diagLoc, const serialization::Status status,
1016
+ ModuleFile *loadedModuleFile, Identifier ModuleName, bool forTestable) {
1017
+ switch (status) {
1018
+ case serialization::Status::Valid:
1019
+ case serialization::Status::FormatTooNew:
1020
+ case serialization::Status::FormatTooOld:
1021
+ case serialization::Status::NotInOSSA:
1022
+ case serialization::Status::RevisionIncompatible:
1023
+ case serialization::Status::Malformed:
1024
+ case serialization::Status::MalformedDocumentation:
1025
+ case serialization::Status::FailedToLoadBridgingHeader:
1026
+ case serialization::Status::NameMismatch:
1027
+ case serialization::Status::TargetIncompatible:
1028
+ case serialization::Status::TargetTooNew:
1029
+ case serialization::Status::SDKMismatch:
1030
+ llvm_unreachable (" status not handled by "
1031
+ " diagnoseSerializedASTLoadFailureTransitive" );
1032
+
948
1033
case serialization::Status::MissingDependency: {
949
1034
// Figure out /which/ dependencies are missing.
950
1035
// FIXME: Dependencies should be de-duplicated at serialization time,
@@ -1023,62 +1108,6 @@ void swift::serialization::diagnoseSerializedASTLoadFailure(
1023
1108
}
1024
1109
break ;
1025
1110
}
1026
-
1027
- case serialization::Status::FailedToLoadBridgingHeader:
1028
- // We already emitted a diagnostic about the bridging header. Just emit
1029
- // a generic message here.
1030
- Ctx.Diags .diagnose (diagLoc, diag::serialization_load_failed,
1031
- ModuleName.str ());
1032
- break ;
1033
-
1034
- case serialization::Status::NameMismatch: {
1035
- // FIXME: This doesn't handle a non-debugger REPL, which should also treat
1036
- // this as a non-fatal error.
1037
- auto diagKind = diag::serialization_name_mismatch;
1038
- if (Ctx.LangOpts .DebuggerSupport )
1039
- diagKind = diag::serialization_name_mismatch_repl;
1040
- Ctx.Diags .diagnose (diagLoc, diagKind, loadInfo.name , ModuleName.str ());
1041
- break ;
1042
- }
1043
-
1044
- case serialization::Status::TargetIncompatible: {
1045
- // FIXME: This doesn't handle a non-debugger REPL, which should also treat
1046
- // this as a non-fatal error.
1047
- auto diagKind = diag::serialization_target_incompatible;
1048
- if (Ctx.LangOpts .DebuggerSupport ||
1049
- Ctx.LangOpts .AllowModuleWithCompilerErrors )
1050
- diagKind = diag::serialization_target_incompatible_repl;
1051
- Ctx.Diags .diagnose (diagLoc, diagKind, ModuleName, loadInfo.targetTriple ,
1052
- moduleBufferID);
1053
- break ;
1054
- }
1055
-
1056
- case serialization::Status::TargetTooNew: {
1057
- llvm::Triple moduleTarget (llvm::Triple::normalize (loadInfo.targetTriple ));
1058
-
1059
- std::pair<StringRef, clang::VersionTuple> moduleOSInfo =
1060
- getOSAndVersionForDiagnostics (moduleTarget);
1061
- std::pair<StringRef, clang::VersionTuple> compilationOSInfo =
1062
- getOSAndVersionForDiagnostics (Ctx.LangOpts .Target );
1063
-
1064
- // FIXME: This doesn't handle a non-debugger REPL, which should also treat
1065
- // this as a non-fatal error.
1066
- auto diagKind = diag::serialization_target_too_new;
1067
- if (Ctx.LangOpts .DebuggerSupport ||
1068
- Ctx.LangOpts .AllowModuleWithCompilerErrors )
1069
- diagKind = diag::serialization_target_too_new_repl;
1070
- Ctx.Diags .diagnose (diagLoc, diagKind, compilationOSInfo.first ,
1071
- compilationOSInfo.second , ModuleName,
1072
- moduleOSInfo.second , moduleBufferID);
1073
- break ;
1074
- }
1075
-
1076
- case serialization::Status::SDKMismatch:
1077
- auto currentSDK = Ctx.LangOpts .SDKName ;
1078
- auto moduleSDK = loadInfo.sdkName ;
1079
- Ctx.Diags .diagnose (diagLoc, diag::serialization_sdk_mismatch,
1080
- ModuleName, moduleSDK, currentSDK, moduleBufferID);
1081
- break ;
1082
1111
}
1083
1112
}
1084
1113
0 commit comments