File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -155,6 +155,8 @@ const char DeclAttributesDidNotMatch::ID = '\0';
155
155
void DeclAttributesDidNotMatch::anchor () {}
156
156
const char InvalidRecordKindError::ID = ' \0 ' ;
157
157
void InvalidRecordKindError::anchor () {}
158
+ const char UnsafeDeserializationError::ID = ' \0 ' ;
159
+ void UnsafeDeserializationError::anchor () {}
158
160
159
161
// / Skips a single record in the bitstream.
160
162
// /
@@ -5414,6 +5416,14 @@ llvm::Error DeclDeserializer::deserializeDeclCommon() {
5414
5416
} else if (recordID == decls_block::DESERIALIZATION_SAFETY) {
5415
5417
IdentifierID declID;
5416
5418
decls_block::DeserializationSafetyLayout::readRecord (scratch, declID);
5419
+
5420
+ if (MF.getResilienceStrategy () == ResilienceStrategy::Resilient &&
5421
+ MF.getContext ().LangOpts .EnableDeserializationSafety ) {
5422
+ auto name = MF.getIdentifier (declID);
5423
+ LLVM_DEBUG (llvm::dbgs () << " Skipping unsafe deserialization: '"
5424
+ << name << " '\n " );
5425
+ return llvm::make_error<UnsafeDeserializationError>(name);
5426
+ }
5417
5427
} else {
5418
5428
return llvm::Error::success ();
5419
5429
}
Original file line number Diff line number Diff line change @@ -494,6 +494,27 @@ class InvalidRecordKindError :
494
494
}
495
495
};
496
496
497
+ // Decl was not deserialized because it's an internal detail maked as unsafe
498
+ // at serialization.
499
+ class UnsafeDeserializationError : public llvm ::ErrorInfo<UnsafeDeserializationError, DeclDeserializationError> {
500
+ friend ErrorInfo;
501
+ static const char ID;
502
+ void anchor () override ;
503
+
504
+ public:
505
+ UnsafeDeserializationError (Identifier name) {
506
+ this ->name = name;
507
+ }
508
+
509
+ void log (raw_ostream &OS) const override {
510
+ OS << " Decl '" << name << " ' is unsafe to deserialize" ;
511
+ }
512
+
513
+ std::error_code convertToErrorCode () const override {
514
+ return llvm::inconvertibleErrorCode ();
515
+ }
516
+ };
517
+
497
518
LLVM_NODISCARD
498
519
static inline std::unique_ptr<llvm::ErrorInfoBase>
499
520
takeErrorInfo (llvm::Error error) {
You can’t perform that action at this time.
0 commit comments