forked from OSchip/llvm-project
AST: Rename PragmaPackAttr to MaxFieldAlignmentAttr, which is more accurate.
llvm-svn: 104795
This commit is contained in:
parent
8ae57895f5
commit
401304462a
|
@ -67,6 +67,7 @@ public:
|
||||||
IBOutletCollectionKind, // Clang-specific.
|
IBOutletCollectionKind, // Clang-specific.
|
||||||
IBActionKind, // Clang-specific. Use "Kind" suffix to not conflict w/ macro.
|
IBActionKind, // Clang-specific. Use "Kind" suffix to not conflict w/ macro.
|
||||||
Malloc,
|
Malloc,
|
||||||
|
MaxFieldAlignment,
|
||||||
NoDebug,
|
NoDebug,
|
||||||
NoInline,
|
NoInline,
|
||||||
NonNull,
|
NonNull,
|
||||||
|
@ -81,7 +82,6 @@ public:
|
||||||
NSReturnsNotRetained, // Clang/Checker-specific.
|
NSReturnsNotRetained, // Clang/Checker-specific.
|
||||||
Overloadable, // Clang-specific
|
Overloadable, // Clang-specific
|
||||||
Packed,
|
Packed,
|
||||||
PragmaPack,
|
|
||||||
Pure,
|
Pure,
|
||||||
Regparm,
|
Regparm,
|
||||||
ReqdWorkGroupSize, // OpenCL-specific
|
ReqdWorkGroupSize, // OpenCL-specific
|
||||||
|
@ -186,11 +186,14 @@ public: \
|
||||||
|
|
||||||
DEF_SIMPLE_ATTR(Packed);
|
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;
|
unsigned Alignment;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PragmaPackAttr(unsigned alignment) : Attr(PragmaPack), Alignment(alignment) {}
|
MaxFieldAlignmentAttr(unsigned alignment)
|
||||||
|
: Attr(MaxFieldAlignment), Alignment(alignment) {}
|
||||||
|
|
||||||
/// getAlignment - The specified alignment in bits.
|
/// getAlignment - The specified alignment in bits.
|
||||||
unsigned getAlignment() const { return Alignment; }
|
unsigned getAlignment() const { return Alignment; }
|
||||||
|
@ -199,9 +202,9 @@ public:
|
||||||
|
|
||||||
// Implement isa/cast/dyncast/etc.
|
// Implement isa/cast/dyncast/etc.
|
||||||
static bool classof(const Attr *A) {
|
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 {
|
class AlignedAttr : public Attr {
|
||||||
|
|
|
@ -111,8 +111,8 @@ DEF_SIMPLE_ATTR_CLONE(WeakImport)
|
||||||
DEF_SIMPLE_ATTR_CLONE(WeakRef)
|
DEF_SIMPLE_ATTR_CLONE(WeakRef)
|
||||||
DEF_SIMPLE_ATTR_CLONE(X86ForceAlignArgPointer)
|
DEF_SIMPLE_ATTR_CLONE(X86ForceAlignArgPointer)
|
||||||
|
|
||||||
Attr* PragmaPackAttr::clone(ASTContext &C) const {
|
Attr* MaxFieldAlignmentAttr::clone(ASTContext &C) const {
|
||||||
return ::new (C) PragmaPackAttr(Alignment);
|
return ::new (C) MaxFieldAlignmentAttr(Alignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
Attr* AlignedAttr::clone(ASTContext &C) const {
|
Attr* AlignedAttr::clone(ASTContext &C) const {
|
||||||
|
|
|
@ -782,9 +782,8 @@ void RecordLayoutBuilder::InitializeLayout(const RecordDecl *D) {
|
||||||
|
|
||||||
Packed = D->hasAttr<PackedAttr>();
|
Packed = D->hasAttr<PackedAttr>();
|
||||||
|
|
||||||
// The #pragma pack attribute specifies the maximum field alignment.
|
if (const MaxFieldAlignmentAttr *MFAA = D->getAttr<MaxFieldAlignmentAttr>())
|
||||||
if (const PragmaPackAttr *PPA = D->getAttr<PragmaPackAttr>())
|
MaxFieldAlignment = MFAA->getAlignment();
|
||||||
MaxFieldAlignment = PPA->getAlignment();
|
|
||||||
|
|
||||||
if (const AlignedAttr *AA = D->getAttr<AlignedAttr>())
|
if (const AlignedAttr *AA = D->getAttr<AlignedAttr>())
|
||||||
UpdateAlignment(AA->getMaxAlignment());
|
UpdateAlignment(AA->getMaxAlignment());
|
||||||
|
@ -862,12 +861,12 @@ void RecordLayoutBuilder::Layout(const ObjCInterfaceDecl *D) {
|
||||||
|
|
||||||
Packed = D->hasAttr<PackedAttr>();
|
Packed = D->hasAttr<PackedAttr>();
|
||||||
|
|
||||||
// The #pragma pack attribute specifies the maximum field alignment.
|
if (const MaxFieldAlignmentAttr *MFAA = D->getAttr<MaxFieldAlignmentAttr>())
|
||||||
if (const PragmaPackAttr *PPA = D->getAttr<PragmaPackAttr>())
|
MaxFieldAlignment = MFAA->getAlignment();
|
||||||
MaxFieldAlignment = PPA->getAlignment();
|
|
||||||
|
|
||||||
if (const AlignedAttr *AA = D->getAttr<AlignedAttr>())
|
if (const AlignedAttr *AA = D->getAttr<AlignedAttr>())
|
||||||
UpdateAlignment(AA->getMaxAlignment());
|
UpdateAlignment(AA->getMaxAlignment());
|
||||||
|
|
||||||
// Layout each ivar sequentially.
|
// Layout each ivar sequentially.
|
||||||
llvm::SmallVector<ObjCIvarDecl*, 16> Ivars;
|
llvm::SmallVector<ObjCIvarDecl*, 16> Ivars;
|
||||||
Context.ShallowCollectObjCIvars(D, Ivars);
|
Context.ShallowCollectObjCIvars(D, Ivars);
|
||||||
|
|
|
@ -329,8 +329,9 @@ bool CGRecordLayoutBuilder::LayoutField(const FieldDecl *D,
|
||||||
|
|
||||||
if (const RecordType *RT = D->getType()->getAs<RecordType>()) {
|
if (const RecordType *RT = D->getType()->getAs<RecordType>()) {
|
||||||
const RecordDecl *RD = cast<RecordDecl>(RT->getDecl());
|
const RecordDecl *RD = cast<RecordDecl>(RT->getDecl());
|
||||||
if (const PragmaPackAttr *PPA = RD->getAttr<PragmaPackAttr>()) {
|
if (const MaxFieldAlignmentAttr *MFAA =
|
||||||
if (PPA->getAlignment() != TypeAlignment * 8 && !Packed)
|
RD->getAttr<MaxFieldAlignmentAttr>()) {
|
||||||
|
if (MFAA->getAlignment() != TypeAlignment * 8 && !Packed)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -765,7 +765,7 @@ Attr *PCHReader::ReadAttributes() {
|
||||||
SIMPLE_ATTR(Overloadable);
|
SIMPLE_ATTR(Overloadable);
|
||||||
SIMPLE_ATTR(Override);
|
SIMPLE_ATTR(Override);
|
||||||
SIMPLE_ATTR(Packed);
|
SIMPLE_ATTR(Packed);
|
||||||
UNSIGNED_ATTR(PragmaPack);
|
UNSIGNED_ATTR(MaxFieldAlignment);
|
||||||
SIMPLE_ATTR(Pure);
|
SIMPLE_ATTR(Pure);
|
||||||
UNSIGNED_ATTR(Regparm);
|
UNSIGNED_ATTR(Regparm);
|
||||||
STRING_ATTR(Section);
|
STRING_ATTR(Section);
|
||||||
|
|
|
@ -1943,8 +1943,8 @@ void PCHWriter::WriteAttributeRecord(const Attr *Attr) {
|
||||||
case Attr::Override:
|
case Attr::Override:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Attr::PragmaPack:
|
case Attr::MaxFieldAlignment:
|
||||||
Record.push_back(cast<PragmaPackAttr>(Attr)->getAlignment());
|
Record.push_back(cast<MaxFieldAlignmentAttr>(Attr)->getAlignment());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Attr::Packed:
|
case Attr::Packed:
|
||||||
|
|
|
@ -5410,7 +5410,7 @@ CreateNewDecl:
|
||||||
// the #pragma tokens are effectively skipped over during the
|
// the #pragma tokens are effectively skipped over during the
|
||||||
// parsing of the struct).
|
// parsing of the struct).
|
||||||
if (unsigned Alignment = getPragmaPackAlignment())
|
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),
|
// If this is a specialization of a member class (of a class template),
|
||||||
|
|
Loading…
Reference in New Issue