}
// Target-dependent attributes:
case lltok::StringConstant: {
- std::string Attr = Lex.getStrVal();
- Lex.Lex();
- std::string Val;
- if (EatIfPresent(lltok::equal) &&
- ParseStringConstant(Val))
+ if (ParseStringAttribute(B))
return true;
-
- B.addAttribute(Attr, Val);
continue;
}
ParseToken(lltok::rparen, "expected ')' in address space");
}
+/// ParseStringAttribute
+/// := StringConstant
+/// := StringConstant '=' StringConstant
+bool LLParser::ParseStringAttribute(AttrBuilder &B) {
+ std::string Attr = Lex.getStrVal();
+ Lex.Lex();
+ std::string Val;
+ if (EatIfPresent(lltok::equal) && ParseStringConstant(Val))
+ return true;
+ B.addAttribute(Attr, Val);
+ return false;
+}
+
/// ParseOptionalParamAttrs - Parse a potentially empty list of parameter attributes.
bool LLParser::ParseOptionalParamAttrs(AttrBuilder &B) {
bool HaveError = false;
switch (Token) {
default: // End of attributes.
return HaveError;
+ case lltok::StringConstant: {
+ if (ParseStringAttribute(B))
+ return true;
+ continue;
+ }
case lltok::kw_align: {
unsigned Alignment;
if (ParseOptionalAlignment(Alignment))
switch (Token) {
default: // End of attributes.
return HaveError;
+ case lltok::StringConstant: {
+ if (ParseStringAttribute(B))
+ return true;
+ continue;
+ }
case lltok::kw_dereferenceable: {
uint64_t Bytes;
if (ParseOptionalDerefAttrBytes(lltok::kw_dereferenceable, Bytes))
ret void;
}
+; CHECK: define "string_attribute" void @f45(i32 "string_attribute")
+define "string_attribute" void @f45(i32 "string_attribute") {
+ ret void
+}
+
+; CHECK: define "string_attribute_with_value"="value" void @f46(i32 "string_attribute_with_value"="value")
+define "string_attribute_with_value"="value" void @f46(i32 "string_attribute_with_value"="value") {
+ ret void
+}
+
; CHECK: attributes #0 = { noreturn }
; CHECK: attributes #1 = { nounwind }
; CHECK: attributes #2 = { readnone }