Add type attributes to LLVM C API · llvm/llvm-project@528f6f7 (original) (raw)
2 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -604,6 +604,17 @@ unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A); | ||
604 | 604 | */ |
605 | 605 | uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A); |
606 | 606 | |
607 | +/** | |
608 | + * Create a type attribute | |
609 | + */ | |
610 | +LLVMAttributeRef LLVMCreateTypeAttribute(LLVMContextRef C, unsigned KindID, | |
611 | +LLVMTypeRef type_ref); | |
612 | + | |
613 | +/** | |
614 | + * Get the type attribute's value. | |
615 | + */ | |
616 | +LLVMTypeRef LLVMGetTypeAttributeValue(LLVMAttributeRef A); | |
617 | + | |
607 | 618 | /** |
608 | 619 | * Create a string attribute. |
609 | 620 | */ |
@@ -626,6 +637,7 @@ const char *LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length); | ||
626 | 637 | */ |
627 | 638 | LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A); |
628 | 639 | LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A); |
640 | +LLVMBool LLVMIsTypeAttribute(LLVMAttributeRef A); | |
629 | 641 | |
630 | 642 | /** |
631 | 643 | * Obtain a Type from a context by its registered name. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -164,6 +164,18 @@ uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A) { | ||
164 | 164 | return Attr.getValueAsInt(); |
165 | 165 | } |
166 | 166 | |
167 | +LLVMAttributeRef LLVMCreateTypeAttribute(LLVMContextRef C, unsigned KindID, | |
168 | + LLVMTypeRef type_ref) { | |
169 | +auto &Ctx = *unwrap(C); | |
170 | +auto AttrKind = (Attribute::AttrKind)KindID; | |
171 | +return wrap(Attribute::get(Ctx, AttrKind, unwrap(type_ref))); | |
172 | +} | |
173 | + | |
174 | +LLVMTypeRef LLVMGetTypeAttributeValue(LLVMAttributeRef A) { | |
175 | +auto Attr = unwrap(A); | |
176 | +return wrap(Attr.getValueAsType()); | |
177 | +} | |
178 | + | |
167 | 179 | LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C, |
168 | 180 | const char *K, unsigned KLength, |
169 | 181 | const char *V, unsigned VLength) { |
@@ -194,6 +206,10 @@ LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A) { | ||
194 | 206 | return unwrap(A).isStringAttribute(); |
195 | 207 | } |
196 | 208 | |
209 | +LLVMBool LLVMIsTypeAttribute(LLVMAttributeRef A) { | |
210 | +return unwrap(A).isTypeAttribute(); | |
211 | +} | |
212 | + | |
197 | 213 | char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI) { |
198 | 214 | std::string MsgStorage; |
199 | 215 | raw_string_ostream Stream(MsgStorage); |