[Macros] Serialization and printing for @attached.

This commit is contained in:
Doug Gregor
2023-01-14 21:46:22 -08:00
parent de16b47875
commit 43cadcad3a
8 changed files with 120 additions and 17 deletions

View File

@@ -5447,6 +5447,30 @@ llvm::Error DeclDeserializer::deserializeDeclCommon() {
break;
}
case decls_block::Attached_DECL_ATTR: {
bool isImplicit;
uint8_t rawMacroRole;
uint64_t numNames;
ArrayRef<uint64_t> introducedDeclNames;
serialization::decls_block::AttachedDeclAttrLayout::
readRecord(scratch, isImplicit, rawMacroRole, numNames,
introducedDeclNames);
auto role = *getActualMacroRole(rawMacroRole);
if (introducedDeclNames.size() != numNames * 2)
return MF.diagnoseFatal();
SmallVector<MacroIntroducedDeclName, 1> names;
for (unsigned i = 0; i < introducedDeclNames.size(); i += 2) {
auto kind = getActualMacroIntroducedDeclNameKind(
(uint8_t)introducedDeclNames[i]);
auto identifier =
MF.getIdentifier(IdentifierID(introducedDeclNames[i + 1]));
names.push_back(MacroIntroducedDeclName(*kind, identifier));
}
Attr = AttachedAttr::create(
ctx, SourceLoc(), SourceRange(), role, names, isImplicit);
break;
}
#define SIMPLE_DECL_ATTR(NAME, CLASS, ...) \
case decls_block::CLASS##_DECL_ATTR: { \
bool isImplicit; \