[cfe-commits] r104795 - in /cfe/trunk: include/clang/AST/Attr.h lib/AST/AttrImpl.cpp lib/AST/RecordLayoutBuilder.cpp lib/CodeGen/CGRecordLayoutBuilder.cpp lib/Frontend/PCHReaderDecl.cpp lib/Frontend/PCHWriter.cpp lib/Sema/SemaDecl.cpp
Daniel Dunbar
daniel at zuster.org
Wed May 26 18:12:46 PDT 2010
Author: ddunbar
Date: Wed May 26 20:12:46 2010
New Revision: 104795
URL: http://llvm.org/viewvc/llvm-project?rev=104795&view=rev
Log:
AST: Rename PragmaPackAttr to MaxFieldAlignmentAttr, which is more accurate.
Modified:
cfe/trunk/include/clang/AST/Attr.h
cfe/trunk/lib/AST/AttrImpl.cpp
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
cfe/trunk/lib/Frontend/PCHWriter.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/include/clang/AST/Attr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=104795&r1=104794&r2=104795&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Attr.h (original)
+++ cfe/trunk/include/clang/AST/Attr.h Wed May 26 20:12:46 2010
@@ -67,6 +67,7 @@
IBOutletCollectionKind, // Clang-specific.
IBActionKind, // Clang-specific. Use "Kind" suffix to not conflict w/ macro.
Malloc,
+ MaxFieldAlignment,
NoDebug,
NoInline,
NonNull,
@@ -81,7 +82,6 @@
NSReturnsNotRetained, // Clang/Checker-specific.
Overloadable, // Clang-specific
Packed,
- PragmaPack,
Pure,
Regparm,
ReqdWorkGroupSize, // OpenCL-specific
@@ -186,11 +186,14 @@
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 @@
// 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 {
Modified: cfe/trunk/lib/AST/AttrImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/AttrImpl.cpp?rev=104795&r1=104794&r2=104795&view=diff
==============================================================================
--- cfe/trunk/lib/AST/AttrImpl.cpp (original)
+++ cfe/trunk/lib/AST/AttrImpl.cpp Wed May 26 20:12:46 2010
@@ -111,8 +111,8 @@
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 {
Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=104795&r1=104794&r2=104795&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Wed May 26 20:12:46 2010
@@ -782,9 +782,8 @@
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 @@
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);
Modified: cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=104795&r1=104794&r2=104795&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp Wed May 26 20:12:46 2010
@@ -329,8 +329,9 @@
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;
}
}
Modified: cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderDecl.cpp?rev=104795&r1=104794&r2=104795&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderDecl.cpp Wed May 26 20:12:46 2010
@@ -765,7 +765,7 @@
SIMPLE_ATTR(Overloadable);
SIMPLE_ATTR(Override);
SIMPLE_ATTR(Packed);
- UNSIGNED_ATTR(PragmaPack);
+ UNSIGNED_ATTR(MaxFieldAlignment);
SIMPLE_ATTR(Pure);
UNSIGNED_ATTR(Regparm);
STRING_ATTR(Section);
Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=104795&r1=104794&r2=104795&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Wed May 26 20:12:46 2010
@@ -1943,8 +1943,8 @@
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:
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=104795&r1=104794&r2=104795&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed May 26 20:12:46 2010
@@ -5410,7 +5410,7 @@
// 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),
More information about the cfe-commits
mailing list