aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDeclAttr.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-06-29 00:23:49 +0000
committerChris Lattner <sabre@nondot.org>2008-06-29 00:23:49 +0000
commit0744e5f3325e2d2107506002e43c37ea0155a5ac (patch)
tree77f27cf9c24ae539e8c6aa4235dfe1852cbcb543 /lib/Sema/SemaDeclAttr.cpp
parent0bf29ad534c381087e89efadbf7aff0579bf259f (diff)
move a few methods, no other change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52878 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclAttr.cpp')
-rw-r--r--lib/Sema/SemaDeclAttr.cpp149
1 files changed, 75 insertions, 74 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 9f63c936e9..ed616655d9 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -58,80 +58,6 @@ static inline bool isNSStringType(QualType T, ASTContext &Ctx) {
}
//===----------------------------------------------------------------------===//
-// Top Level Sema Entry Points
-//===----------------------------------------------------------------------===//
-
-/// ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in
-/// it, apply them to D. This is a bit tricky because PD can have attributes
-/// specified in many different places, and we need to find and apply them all.
-void Sema::ProcessDeclAttributes(Decl *D, const Declarator &PD) {
- // Apply decl attributes from the DeclSpec if present.
- if (const AttributeList *Attrs = PD.getDeclSpec().getAttributes())
- ProcessDeclAttributeList(D, Attrs);
-
- // Walk the declarator structure, applying decl attributes that were in a type
- // position to the decl itself. This handles cases like:
- // int *__attr__(x)** D;
- // when X is a decl attribute.
- for (unsigned i = 0, e = PD.getNumTypeObjects(); i != e; ++i)
- if (const AttributeList *Attrs = PD.getTypeObject(i).getAttrs())
- ProcessDeclAttributeList(D, Attrs);
-
- // Finally, apply any attributes on the decl itself.
- if (const AttributeList *Attrs = PD.getAttributes())
- ProcessDeclAttributeList(D, Attrs);
-}
-
-/// ProcessDeclAttributeList - Apply all the decl attributes in the specified
-/// attribute list to the specified decl, ignoring any type attributes.
-void Sema::ProcessDeclAttributeList(Decl *D, const AttributeList *AttrList) {
- while (AttrList) {
- ProcessDeclAttribute(D, *AttrList);
- AttrList = AttrList->getNext();
- }
-}
-
-/// HandleDeclAttribute - Apply the specific attribute to the specified decl if
-/// the attribute applies to decls. If the attribute is a type attribute, just
-/// silently ignore it.
-void Sema::ProcessDeclAttribute(Decl *D, const AttributeList &Attr) {
- switch (Attr.getKind()) {
- case AttributeList::AT_address_space:
- // Ignore this, this is a type attribute, handled by ProcessTypeAttributes.
- break;
- case AttributeList::AT_vector_size: HandleVectorSizeAttribute(D, Attr); break;
- case AttributeList::AT_ext_vector_type:
- HandleExtVectorTypeAttribute(D, Attr);
- break;
- case AttributeList::AT_mode: HandleModeAttribute(D, Attr); break;
- case AttributeList::AT_alias: HandleAliasAttribute(D, Attr); break;
- case AttributeList::AT_deprecated: HandleDeprecatedAttribute(D, Attr);break;
- case AttributeList::AT_visibility: HandleVisibilityAttribute(D, Attr);break;
- case AttributeList::AT_weak: HandleWeakAttribute(D, Attr); break;
- case AttributeList::AT_dllimport: HandleDLLImportAttribute(D, Attr); break;
- case AttributeList::AT_dllexport: HandleDLLExportAttribute(D, Attr); break;
- case AttributeList::AT_nothrow: HandleNothrowAttribute(D, Attr); break;
- case AttributeList::AT_stdcall: HandleStdCallAttribute(D, Attr); break;
- case AttributeList::AT_fastcall: HandleFastCallAttribute(D, Attr); break;
- case AttributeList::AT_aligned: HandleAlignedAttribute(D, Attr); break;
- case AttributeList::AT_packed: HandlePackedAttribute(D, Attr); break;
- case AttributeList::AT_annotate: HandleAnnotateAttribute(D, Attr); break;
- case AttributeList::AT_noreturn: HandleNoReturnAttribute(D, Attr); break;
- case AttributeList::AT_format: HandleFormatAttribute(D, Attr); break;
- case AttributeList::AT_transparent_union:
- HandleTransparentUnionAttribute(D, Attr);
- break;
- default:
-#if 0
- // TODO: when we have the full set of attributes, warn about unknown ones.
- Diag(Attr->getLoc(), diag::warn_attribute_ignored,
- Attr->getName()->getName());
-#endif
- break;
- }
-}
-
-//===----------------------------------------------------------------------===//
// Attribute Implementations
//===----------------------------------------------------------------------===//
@@ -792,3 +718,78 @@ void Sema::HandleModeAttribute(Decl *D, const AttributeList &Attr) {
else
cast<ValueDecl>(D)->setType(NewTy);
}
+
+//===----------------------------------------------------------------------===//
+// Top Level Sema Entry Points
+//===----------------------------------------------------------------------===//
+
+/// ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in
+/// it, apply them to D. This is a bit tricky because PD can have attributes
+/// specified in many different places, and we need to find and apply them all.
+void Sema::ProcessDeclAttributes(Decl *D, const Declarator &PD) {
+ // Apply decl attributes from the DeclSpec if present.
+ if (const AttributeList *Attrs = PD.getDeclSpec().getAttributes())
+ ProcessDeclAttributeList(D, Attrs);
+
+ // Walk the declarator structure, applying decl attributes that were in a type
+ // position to the decl itself. This handles cases like:
+ // int *__attr__(x)** D;
+ // when X is a decl attribute.
+ for (unsigned i = 0, e = PD.getNumTypeObjects(); i != e; ++i)
+ if (const AttributeList *Attrs = PD.getTypeObject(i).getAttrs())
+ ProcessDeclAttributeList(D, Attrs);
+
+ // Finally, apply any attributes on the decl itself.
+ if (const AttributeList *Attrs = PD.getAttributes())
+ ProcessDeclAttributeList(D, Attrs);
+}
+
+/// ProcessDeclAttributeList - Apply all the decl attributes in the specified
+/// attribute list to the specified decl, ignoring any type attributes.
+void Sema::ProcessDeclAttributeList(Decl *D, const AttributeList *AttrList) {
+ while (AttrList) {
+ ProcessDeclAttribute(D, *AttrList);
+ AttrList = AttrList->getNext();
+ }
+}
+
+/// HandleDeclAttribute - Apply the specific attribute to the specified decl if
+/// the attribute applies to decls. If the attribute is a type attribute, just
+/// silently ignore it.
+void Sema::ProcessDeclAttribute(Decl *D, const AttributeList &Attr) {
+ switch (Attr.getKind()) {
+ case AttributeList::AT_address_space:
+ // Ignore this, this is a type attribute, handled by ProcessTypeAttributes.
+ break;
+ case AttributeList::AT_vector_size: HandleVectorSizeAttribute(D, Attr); break;
+ case AttributeList::AT_ext_vector_type:
+ HandleExtVectorTypeAttribute(D, Attr);
+ break;
+ case AttributeList::AT_mode: HandleModeAttribute(D, Attr); break;
+ case AttributeList::AT_alias: HandleAliasAttribute(D, Attr); break;
+ case AttributeList::AT_deprecated: HandleDeprecatedAttribute(D, Attr);break;
+ case AttributeList::AT_visibility: HandleVisibilityAttribute(D, Attr);break;
+ case AttributeList::AT_weak: HandleWeakAttribute(D, Attr); break;
+ case AttributeList::AT_dllimport: HandleDLLImportAttribute(D, Attr); break;
+ case AttributeList::AT_dllexport: HandleDLLExportAttribute(D, Attr); break;
+ case AttributeList::AT_nothrow: HandleNothrowAttribute(D, Attr); break;
+ case AttributeList::AT_stdcall: HandleStdCallAttribute(D, Attr); break;
+ case AttributeList::AT_fastcall: HandleFastCallAttribute(D, Attr); break;
+ case AttributeList::AT_aligned: HandleAlignedAttribute(D, Attr); break;
+ case AttributeList::AT_packed: HandlePackedAttribute(D, Attr); break;
+ case AttributeList::AT_annotate: HandleAnnotateAttribute(D, Attr); break;
+ case AttributeList::AT_noreturn: HandleNoReturnAttribute(D, Attr); break;
+ case AttributeList::AT_format: HandleFormatAttribute(D, Attr); break;
+ case AttributeList::AT_transparent_union:
+ HandleTransparentUnionAttribute(D, Attr);
+ break;
+ default:
+#if 0
+ // TODO: when we have the full set of attributes, warn about unknown ones.
+ Diag(Attr->getLoc(), diag::warn_attribute_ignored,
+ Attr->getName()->getName());
+#endif
+ break;
+ }
+}
+