AST: Rename PragmaPackAttr to MaxFieldAlignmentAttr, which is more accurate.

llvm-svn: 104795
This commit is contained in:
Daniel Dunbar 2010-05-27 01:12:46 +00:00
parent 8ae57895f5
commit 401304462a
7 changed files with 22 additions and 19 deletions

View File

@ -67,6 +67,7 @@ public:
IBOutletCollectionKind, // Clang-specific.
IBActionKind, // Clang-specific. Use "Kind" suffix to not conflict w/ macro.
Malloc,
MaxFieldAlignment,
NoDebug,
NoInline,
NonNull,
@ -81,7 +82,6 @@ public:
NSReturnsNotRetained, // Clang/Checker-specific.
Overloadable, // Clang-specific
Packed,
PragmaPack,
Pure,
Regparm,
ReqdWorkGroupSize, // OpenCL-specific
@ -186,11 +186,14 @@ public: \
DEF_SIMPLE_ATTR(Packed);
class PragmaPackAttr : public Attr {
/// \brief Attribute for specifying a maximum field alignment; this is only
/// valid on record decls.
class MaxFieldAlignmentAttr : public Attr {
unsigned Alignment;
public:
PragmaPackAttr(unsigned alignment) : Attr(PragmaPack), Alignment(alignment) {}
MaxFieldAlignmentAttr(unsigned alignment)
: Attr(MaxFieldAlignment), Alignment(alignment) {}
/// getAlignment - The specified alignment in bits.
unsigned getAlignment() const { return Alignment; }
@ -199,9 +202,9 @@ public:
// Implement isa/cast/dyncast/etc.
static bool classof(const Attr *A) {
return A->getKind() == PragmaPack;
return A->getKind() == MaxFieldAlignment;
}
static bool classof(const PragmaPackAttr *A) { return true; }
static bool classof(const MaxFieldAlignmentAttr *A) { return true; }
};
class AlignedAttr : public Attr {

View File

@ -111,8 +111,8 @@ DEF_SIMPLE_ATTR_CLONE(WeakImport)
DEF_SIMPLE_ATTR_CLONE(WeakRef)
DEF_SIMPLE_ATTR_CLONE(X86ForceAlignArgPointer)
Attr* PragmaPackAttr::clone(ASTContext &C) const {
return ::new (C) PragmaPackAttr(Alignment);
Attr* MaxFieldAlignmentAttr::clone(ASTContext &C) const {
return ::new (C) MaxFieldAlignmentAttr(Alignment);
}
Attr* AlignedAttr::clone(ASTContext &C) const {

View File

@ -782,9 +782,8 @@ void RecordLayoutBuilder::InitializeLayout(const RecordDecl *D) {
Packed = D->hasAttr<PackedAttr>();
// The #pragma pack attribute specifies the maximum field alignment.
if (const PragmaPackAttr *PPA = D->getAttr<PragmaPackAttr>())
MaxFieldAlignment = PPA->getAlignment();
if (const MaxFieldAlignmentAttr *MFAA = D->getAttr<MaxFieldAlignmentAttr>())
MaxFieldAlignment = MFAA->getAlignment();
if (const AlignedAttr *AA = D->getAttr<AlignedAttr>())
UpdateAlignment(AA->getMaxAlignment());
@ -862,12 +861,12 @@ void RecordLayoutBuilder::Layout(const ObjCInterfaceDecl *D) {
Packed = D->hasAttr<PackedAttr>();
// The #pragma pack attribute specifies the maximum field alignment.
if (const PragmaPackAttr *PPA = D->getAttr<PragmaPackAttr>())
MaxFieldAlignment = PPA->getAlignment();
if (const MaxFieldAlignmentAttr *MFAA = D->getAttr<MaxFieldAlignmentAttr>())
MaxFieldAlignment = MFAA->getAlignment();
if (const AlignedAttr *AA = D->getAttr<AlignedAttr>())
UpdateAlignment(AA->getMaxAlignment());
// Layout each ivar sequentially.
llvm::SmallVector<ObjCIvarDecl*, 16> Ivars;
Context.ShallowCollectObjCIvars(D, Ivars);

View File

@ -329,8 +329,9 @@ bool CGRecordLayoutBuilder::LayoutField(const FieldDecl *D,
if (const RecordType *RT = D->getType()->getAs<RecordType>()) {
const RecordDecl *RD = cast<RecordDecl>(RT->getDecl());
if (const PragmaPackAttr *PPA = RD->getAttr<PragmaPackAttr>()) {
if (PPA->getAlignment() != TypeAlignment * 8 && !Packed)
if (const MaxFieldAlignmentAttr *MFAA =
RD->getAttr<MaxFieldAlignmentAttr>()) {
if (MFAA->getAlignment() != TypeAlignment * 8 && !Packed)
return false;
}
}

View File

@ -765,7 +765,7 @@ Attr *PCHReader::ReadAttributes() {
SIMPLE_ATTR(Overloadable);
SIMPLE_ATTR(Override);
SIMPLE_ATTR(Packed);
UNSIGNED_ATTR(PragmaPack);
UNSIGNED_ATTR(MaxFieldAlignment);
SIMPLE_ATTR(Pure);
UNSIGNED_ATTR(Regparm);
STRING_ATTR(Section);

View File

@ -1943,8 +1943,8 @@ void PCHWriter::WriteAttributeRecord(const Attr *Attr) {
case Attr::Override:
break;
case Attr::PragmaPack:
Record.push_back(cast<PragmaPackAttr>(Attr)->getAlignment());
case Attr::MaxFieldAlignment:
Record.push_back(cast<MaxFieldAlignmentAttr>(Attr)->getAlignment());
break;
case Attr::Packed:

View File

@ -5410,7 +5410,7 @@ CreateNewDecl:
// the #pragma tokens are effectively skipped over during the
// parsing of the struct).
if (unsigned Alignment = getPragmaPackAlignment())
New->addAttr(::new (Context) PragmaPackAttr(Alignment * 8));
New->addAttr(::new (Context) MaxFieldAlignmentAttr(Alignment * 8));
}
// If this is a specialization of a member class (of a class template),