aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2008-06-08 15:45:52 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2008-06-08 15:45:52 +0000
commitd4cbda6292b321c2e7dce7f039d92918fee99b3a (patch)
treebafb6964c04d55e8f69832155513962da2180514 /lib/Sema/SemaDecl.cpp
parent3cd1a2dc07014aa6b675030823690cf06619a745 (diff)
implement the alias attirbute (in both Sema and Codegen)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52092 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index b56622ceb9..ed34f9fe00 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -2250,6 +2250,9 @@ void Sema::HandleDeclAttribute(Decl *New, AttributeList *Attr) {
}
// FIXME: Diagnostic?
break;
+ case AttributeList::AT_alias:
+ HandleAliasAttribute(New, Attr);
+ break;
case AttributeList::AT_deprecated:
HandleDeprecatedAttribute(New, Attr);
break;
@@ -2438,6 +2441,32 @@ void Sema::HandlePackedAttribute(Decl *d, AttributeList *rawAttr) {
rawAttr->getName()->getName());
}
+void Sema::HandleAliasAttribute(Decl *d, AttributeList *rawAttr) {
+ // check the attribute arguments.
+ if (rawAttr->getNumArgs() != 1) {
+ Diag(rawAttr->getLoc(), diag::err_attribute_wrong_number_arguments,
+ std::string("1"));
+ return;
+ }
+
+ Expr *Arg = static_cast<Expr*>(rawAttr->getArg(0));
+ Arg = Arg->IgnoreParenCasts();
+ StringLiteral *Str = dyn_cast<StringLiteral>(Arg);
+
+ if (Str == 0 || Str->isWide()) {
+ Diag(rawAttr->getLoc(), diag::err_attribute_argument_n_not_string,
+ "alias", std::string("1"));
+ return;
+ }
+
+ const char *Alias = Str->getStrData();
+ unsigned AliasLen = Str->getByteLength();
+
+ // FIXME: check if target symbol exists in current file
+
+ d->addAttr(new AliasAttr(std::string(Alias, AliasLen)));
+}
+
void Sema::HandleNoReturnAttribute(Decl *d, AttributeList *rawAttr) {
// check the attribute arguments.
if (rawAttr->getNumArgs() != 0) {