diff --git a/include/revng-c/Support/PTMLC.h b/include/revng-c/Support/PTMLC.h index ebf73a7ea..3d446eba3 100644 --- a/include/revng-c/Support/PTMLC.h +++ b/include/revng-c/Support/PTMLC.h @@ -443,6 +443,8 @@ public: std::string getPackedAttribute() { return "_PACKED"; } + std::string getCanContainCodeAttribute() { return "_CAN_CONTAIN_CODE"; } + Tag getNameTag(const model::TypeDefinition &T) const { return ptml::PTMLBuilder::tokenTag(T.name().str().str(), ptml::c::tokens::Type); diff --git a/lib/TypeNames/ModelToPTMLTypeHelpers.cpp b/lib/TypeNames/ModelToPTMLTypeHelpers.cpp index e10f70d11..e82d3bb89 100644 --- a/lib/TypeNames/ModelToPTMLTypeHelpers.cpp +++ b/lib/TypeNames/ModelToPTMLTypeHelpers.cpp @@ -328,6 +328,9 @@ static void printDefinition(Logger<> &Log, << B.getKeyword(ptml::PTMLCBuilder::Keyword::Struct) << " " << B.getPackedAttribute() << " "; + if (S.CanContainCode()) + Header << B.getCanContainCodeAttribute() << " "; + if (ForEditing) Header << B.getSizeAnnotation(S.Size()) << " "; diff --git a/share/revng-c/include/attributes.h b/share/revng-c/include/attributes.h index 36e5fc342..6d4a9d89e 100644 --- a/share/revng-c/include/attributes.h +++ b/share/revng-c/include/attributes.h @@ -21,5 +21,6 @@ #define _ENUM_UNDERLYING(x) __attribute__((annotate(ENUM_ATTRIBUTE_STRING(x)))) #define _PACKED __attribute__((packed)) +#define _CAN_CONTAIN_CODE __attribute__((annotate("can_contain_code"))) #define _START_AT(x) __attribute__((annotate(FIELD_START_ATTRIBUTE_STRING(x)))) #define _SIZE(x) __attribute__((annotate(STRUCT_SIZE_ATTRIBUTE_STRING(x))))