Skip to content
Snippets Groups Projects
Commit f43ed02c authored by Aaron Ballman's avatar Aaron Ballman
Browse files

Common functionality is already checked within SemaDeclAttr.cpp and so it does...

Common functionality is already checked within SemaDeclAttr.cpp and so it does not need to be re-checked for each target.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196428 91177308-0d34-0410-b5e6-96231b3b80d8
parent 668e1141
No related branches found
No related tags found
No related merge requests found
...@@ -72,13 +72,6 @@ namespace { ...@@ -72,13 +72,6 @@ namespace {
static void HandleMSP430InterruptAttr(Decl *d, static void HandleMSP430InterruptAttr(Decl *d,
const AttributeList &Attr, Sema &S) { const AttributeList &Attr, Sema &S) {
// Check the attribute arguments.
if (Attr.getNumArgs() != 1) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
<< Attr.getName() << 1;
return;
}
// FIXME: Check for decl - it should be void ()(void). // FIXME: Check for decl - it should be void ()(void).
Expr *NumParamsExpr = static_cast<Expr *>(Attr.getArgAsExpr(0)); Expr *NumParamsExpr = static_cast<Expr *>(Attr.getArgAsExpr(0));
...@@ -122,13 +115,6 @@ namespace { ...@@ -122,13 +115,6 @@ namespace {
static void HandleX86ForceAlignArgPointerAttr(Decl *D, static void HandleX86ForceAlignArgPointerAttr(Decl *D,
const AttributeList& Attr, const AttributeList& Attr,
Sema &S) { Sema &S) {
// Check the attribute arguments.
if (Attr.getNumArgs() != 0) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
<< Attr.getName() << 0;
return;
}
// If we try to apply it to a function pointer, don't warn, but don't // If we try to apply it to a function pointer, don't warn, but don't
// do anything, either. It doesn't matter anyway, because there's nothing // do anything, either. It doesn't matter anyway, because there's nothing
// special about calling a force_align_arg_pointer function. // special about calling a force_align_arg_pointer function.
...@@ -175,13 +161,6 @@ DLLImportAttr *Sema::mergeDLLImportAttr(Decl *D, SourceRange Range, ...@@ -175,13 +161,6 @@ DLLImportAttr *Sema::mergeDLLImportAttr(Decl *D, SourceRange Range,
} }
static void HandleDLLImportAttr(Decl *D, const AttributeList &Attr, Sema &S) { static void HandleDLLImportAttr(Decl *D, const AttributeList &Attr, Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs() != 0) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
<< Attr.getName() << 0;
return;
}
// Attribute can be applied only to functions or variables. // Attribute can be applied only to functions or variables.
FunctionDecl *FD = dyn_cast<FunctionDecl>(D); FunctionDecl *FD = dyn_cast<FunctionDecl>(D);
if (!FD && !isa<VarDecl>(D)) { if (!FD && !isa<VarDecl>(D)) {
...@@ -222,13 +201,6 @@ DLLExportAttr *Sema::mergeDLLExportAttr(Decl *D, SourceRange Range, ...@@ -222,13 +201,6 @@ DLLExportAttr *Sema::mergeDLLExportAttr(Decl *D, SourceRange Range,
} }
static void HandleDLLExportAttr(Decl *D, const AttributeList &Attr, Sema &S) { static void HandleDLLExportAttr(Decl *D, const AttributeList &Attr, Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs() != 0) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
<< Attr.getName() << 0;
return;
}
// Attribute can be applied only to functions or variables. // Attribute can be applied only to functions or variables.
FunctionDecl *FD = dyn_cast<FunctionDecl>(D); FunctionDecl *FD = dyn_cast<FunctionDecl>(D);
if (!FD && !isa<VarDecl>(D)) { if (!FD && !isa<VarDecl>(D)) {
...@@ -278,41 +250,6 @@ namespace { ...@@ -278,41 +250,6 @@ namespace {
}; };
} }
static void HandleMips16Attr(Decl *D, const AttributeList &Attr, Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs()) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
<< Attr.getName() << 0;
return;
}
// Attribute can only be applied to function types.
if (!isa<FunctionDecl>(D)) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type)
<< Attr.getName() << /* function */0;
return;
}
D->addAttr(::new (S.Context) Mips16Attr(Attr.getRange(), S.Context,
Attr.getAttributeSpellingListIndex()));
}
static void HandleNoMips16Attr(Decl *D, const AttributeList &Attr, Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs()) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
<< Attr.getName() << 0;
return;
}
// Attribute can only be applied to function types.
if (!isa<FunctionDecl>(D)) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type)
<< Attr.getName() << /* function */0;
return;
}
D->addAttr(::new (S.Context)
NoMips16Attr(Attr.getRange(), S.Context,
Attr.getAttributeSpellingListIndex()));
}
namespace { namespace {
class MipsAttributesSema : public TargetAttributesSema { class MipsAttributesSema : public TargetAttributesSema {
public: public:
...@@ -320,10 +257,12 @@ namespace { ...@@ -320,10 +257,12 @@ namespace {
bool ProcessDeclAttribute(Scope *scope, Decl *D, const AttributeList &Attr, bool ProcessDeclAttribute(Scope *scope, Decl *D, const AttributeList &Attr,
Sema &S) const { Sema &S) const {
if (Attr.getKind() == AttributeList::AT_Mips16) { if (Attr.getKind() == AttributeList::AT_Mips16) {
HandleMips16Attr(D, Attr, S); D->addAttr(::new (S.Context) Mips16Attr(Attr.getRange(), S.Context,
Attr.getAttributeSpellingListIndex()));
return true; return true;
} else if (Attr.getKind() == AttributeList::AT_NoMips16) { } else if (Attr.getKind() == AttributeList::AT_NoMips16) {
HandleNoMips16Attr(D, Attr, S); D->addAttr(::new (S.Context) NoMips16Attr(Attr.getRange(), S.Context,
Attr.getAttributeSpellingListIndex()));
return true; return true;
} }
return false; return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment