Add fastcall/stdcall attribute support
Generate CallingConv::Fast when fastcall attribute is present
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48017 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/Sema.h b/Sema/Sema.h
index a3934c7..2fe54de 100644
--- a/Sema/Sema.h
+++ b/Sema/Sema.h
@@ -280,6 +280,8 @@
void HandleVisibilityAttribute(Decl *d, AttributeList *rawAttr);
void HandleNothrowAttribute(Decl *d, AttributeList *rawAttr);
void HandleFormatAttribute(Decl *d, AttributeList *rawAttr);
+ void HandleStdCallAttribute(Decl *d, AttributeList *rawAttr);
+ void HandleFastCallAttribute(Decl *d, AttributeList *rawAttr);
void WarnUndefinedMethod(SourceLocation ImpLoc, ObjCMethodDecl *method,
bool &IncompleteImpl);
@@ -501,7 +503,7 @@
SourceLocation *CommaLocs,
SourceLocation BuiltinLoc,
SourceLocation RParenLoc);
-
+
// __builtin_va_arg(expr, type)
virtual ExprResult ActOnVAArg(SourceLocation BuiltinLoc,
ExprTy *expr, TypeTy *type,
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp
index 60fe7ab..7307fc4 100644
--- a/Sema/SemaDecl.cpp
+++ b/Sema/SemaDecl.cpp
@@ -1811,6 +1811,12 @@
case AttributeList::AT_nothrow:
HandleNothrowAttribute(New, Attr);
break;
+ case AttributeList::AT_stdcall:
+ HandleStdCallAttribute(New, Attr);
+ break;
+ case AttributeList::AT_fastcall:
+ HandleFastCallAttribute(New, Attr);
+ break;
case AttributeList::AT_aligned:
HandleAlignedAttribute(New, Attr);
break;
@@ -2073,6 +2079,28 @@
d->addAttr(new DLLExportAttr());
}
+void Sema::HandleStdCallAttribute(Decl *d, AttributeList *rawAttr) {
+ // check the attribute arguments.
+ if (rawAttr->getNumArgs() != 0) {
+ Diag(rawAttr->getLoc(), diag::err_attribute_wrong_number_arguments,
+ std::string("0"));
+ return;
+ }
+
+ d->addAttr(new StdCallAttr());
+}
+
+void Sema::HandleFastCallAttribute(Decl *d, AttributeList *rawAttr) {
+ // check the attribute arguments.
+ if (rawAttr->getNumArgs() != 0) {
+ Diag(rawAttr->getLoc(), diag::err_attribute_wrong_number_arguments,
+ std::string("0"));
+ return;
+ }
+
+ d->addAttr(new FastCallAttr());
+}
+
void Sema::HandleNothrowAttribute(Decl *d, AttributeList *rawAttr) {
// check the attribute arguments.
if (rawAttr->getNumArgs() != 0) {