r190710 - Updated the PCS calling convention to use the new checkStringLiteralArgument helper function.
Aaron Ballman
aaron at aaronballman.com
Fri Sep 13 10:48:25 PDT 2013
Author: aaronballman
Date: Fri Sep 13 12:48:25 2013
New Revision: 190710
URL: http://llvm.org/viewvc/llvm-project?rev=190710&view=rev
Log:
Updated the PCS calling convention to use the new checkStringLiteralArgument helper function.
Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/Sema/callingconv.c
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=190710&r1=190709&r2=190710&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Sep 13 12:48:25 2013
@@ -3869,18 +3869,11 @@ bool Sema::CheckCallingConvAttr(const At
CC_C;
break;
case AttributeList::AT_Pcs: {
- StringLiteral *Str = 0;
- if (attr.isArgExpr(0))
- Str = dyn_cast<StringLiteral>(attr.getArgAsExpr(0));
-
- if (!Str || !Str->isAscii()) {
- Diag(attr.getLoc(), diag::err_attribute_argument_type) << attr.getName()
- << AANT_ArgumentString;
+ StringRef StrRef;
+ if (!checkStringLiteralArgument(*this, StrRef, attr, 0)) {
attr.setInvalid();
return true;
}
-
- StringRef StrRef = Str->getString();
if (StrRef == "aapcs") {
CC = CC_AAPCS;
break;
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=190710&r1=190709&r2=190710&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Fri Sep 13 12:48:25 2013
@@ -4371,9 +4371,15 @@ static AttributedType::Kind getCCTypeAtt
case AttributeList::AT_Pascal:
return AttributedType::attr_pascal;
case AttributeList::AT_Pcs: {
- // We know attr is valid so it can only have one of two strings args.
- StringLiteral *Str = cast<StringLiteral>(Attr.getArgAsExpr(0));
- return llvm::StringSwitch<AttributedType::Kind>(Str->getString())
+ // The attribute may have had a fixit applied where we treated an
+ // identifier as a string literal. The contents of the string are valid,
+ // but the form may not be.
+ StringRef Str;
+ if (Attr.isArgExpr(0))
+ Str = cast<StringLiteral>(Attr.getArgAsExpr(0))->getString();
+ else
+ Str = Attr.getArgAsIdent(0)->Ident->getName();
+ return llvm::StringSwitch<AttributedType::Kind>(Str)
.Case("aapcs", AttributedType::attr_pcs)
.Case("aapcs-vfp", AttributedType::attr_pcs_vfp);
}
Modified: cfe/trunk/test/Sema/callingconv.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/callingconv.c?rev=190710&r1=190709&r2=190710&view=diff
==============================================================================
--- cfe/trunk/test/Sema/callingconv.c (original)
+++ cfe/trunk/test/Sema/callingconv.c Fri Sep 13 12:48:25 2013
@@ -38,7 +38,8 @@ Handler H = foo;
int __attribute__((pcs("aapcs", "aapcs"))) pcs1(void); // expected-error {{'pcs' attribute takes one argument}}
int __attribute__((pcs())) pcs2(void); // expected-error {{'pcs' attribute takes one argument}}
-int __attribute__((pcs(pcs1))) pcs3(void); // expected-error {{'pcs' attribute requires a string}}
+int __attribute__((pcs(pcs1))) pcs3(void); // expected-error {{'pcs' attribute requires a string}} \
+ // expected-error {{invalid PCS type}}
int __attribute__((pcs(0))) pcs4(void); // expected-error {{'pcs' attribute requires a string}}
/* These are ignored because the target is i386 and not ARM */
int __attribute__((pcs("aapcs"))) pcs5(void); // expected-warning {{calling convention 'pcs' ignored for this target}}
More information about the cfe-commits
mailing list