aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-02-21 01:07:18 +0000
committerChris Lattner <sabre@nondot.org>2008-02-21 01:07:18 +0000
commitf1d705c3e2276f7f5b97b8b3394b9b3068fdf25b (patch)
tree1b42cf70b3cb0435c24eae3d1a561d793641e0f4
parent74788ba1dc1dd836edd1956c1a4b071b2bb71574 (diff)
move type attribute processing into the creatively named ProcessTypeAttributes method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47418 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Sema/Sema.h4
-rw-r--r--Sema/SemaType.cpp22
-rw-r--r--include/clang/Parse/DeclSpec.h1
3 files changed, 15 insertions, 12 deletions
diff --git a/Sema/Sema.h b/Sema/Sema.h
index e33a3cb18b..70f76cc2fe 100644
--- a/Sema/Sema.h
+++ b/Sema/Sema.h
@@ -174,7 +174,9 @@ public:
// Type Analysis / Processing: SemaType.cpp.
//
QualType ConvertDeclSpecToType(DeclSpec &DS);
+ AttributeList *ProcessTypeAttributes(QualType &Result, AttributeList *AL);
QualType GetTypeForDeclarator(Declarator &D, Scope *S);
+
QualType ObjCGetTypeForMethodDefinition(DeclTy *D);
@@ -227,7 +229,7 @@ private:
virtual void ActOnEnumBody(SourceLocation EnumLoc, DeclTy *EnumDecl,
DeclTy **Elements, unsigned NumElements);
private:
- /// Subroutines of ActOnDeclarator()...
+ /// Subroutines of ActOnDeclarator().
TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, QualType T,
ScopedDecl *LastDecl);
TypedefDecl *MergeTypeDefDecl(TypedefDecl *New, ScopedDecl *Old);
diff --git a/Sema/SemaType.cpp b/Sema/SemaType.cpp
index 2002bd3719..e5477c030d 100644
--- a/Sema/SemaType.cpp
+++ b/Sema/SemaType.cpp
@@ -142,16 +142,19 @@ QualType Sema::ConvertDeclSpecToType(DeclSpec &DS) {
// See if there are any attributes on the declspec that apply to the type (as
// opposed to the decl).
- if (!DS.getAttributes())
- return Result;
-
+ if (AttributeList *AL = DS.getAttributes())
+ DS.SetAttributes(ProcessTypeAttributes(Result, AL));
+
+ return Result;
+}
+
+AttributeList *Sema::ProcessTypeAttributes(QualType &Result, AttributeList *AL){
// Scan through and apply attributes to this type where it makes sense. Some
// attributes (such as __address_space__, __vector_size__, etc) apply to the
- // declspec, but others can be present in the decl spec even though they apply
- // to the decl. Here we apply and delete attributes that apply to the
- // declspec and leave the others alone.
+ // type, but others can be present in the type specifiers even though they
+ // apply to the decl. Here we apply and delete attributes that apply to the
+ // type and leave the others alone.
llvm::SmallVector<AttributeList *, 8> LeftOverAttrs;
- AttributeList *AL = DS.getAttributes();
while (AL) {
// Unlink this attribute from the chain, so we can process it independently.
AttributeList *ThisAttr = AL;
@@ -178,10 +181,7 @@ QualType Sema::ConvertDeclSpecToType(DeclSpec &DS) {
List = LeftOverAttrs[i];
}
- DS.clearAttributes();
- DS.AddAttributes(List);
- //DS.setAttributes(List);
- return Result;
+ return List;
}
/// HandleAddressSpaceTypeAttribute - Process an address_space attribute on the
diff --git a/include/clang/Parse/DeclSpec.h b/include/clang/Parse/DeclSpec.h
index 8c07f6f92f..2eb2364ad9 100644
--- a/include/clang/Parse/DeclSpec.h
+++ b/include/clang/Parse/DeclSpec.h
@@ -258,6 +258,7 @@ public:
alist->addAttributeList(AttrList);
AttrList = alist;
}
+ void SetAttributes(AttributeList *AL) { AttrList = AL; }
AttributeList *getAttributes() const { return AttrList; }
void clearAttributes() { AttrList = 0; }