Fix PCH issue. Attributes of a declaration were truncated to just one when the decl was read from a PCH file.

llvm-svn: 105852
This commit is contained in:
Argyrios Kyrtzidis 2010-06-11 23:09:25 +00:00
parent 649caee022
commit 9116717189
4 changed files with 14 additions and 2 deletions

View File

@ -297,6 +297,7 @@ public:
}
bool hasAttrs() const { return HasAttrs; }
void initAttrs(Attr *attrs);
void addAttr(Attr *attr);
const Attr *getAttrs() const {
if (!HasAttrs) return 0; // common case, no attributes.

View File

@ -314,9 +314,20 @@ unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) {
return 0;
}
void Decl::initAttrs(Attr *attrs) {
assert(!HasAttrs && "Decl already contains attrs.");
Attr *&AttrBlank = getASTContext().getDeclAttrs(this);
assert(AttrBlank == 0 && "HasAttrs was wrong?");
AttrBlank = attrs;
HasAttrs = true;
}
void Decl::addAttr(Attr *NewAttr) {
Attr *&ExistingAttr = getASTContext().getDeclAttrs(this);
assert(NewAttr->getNext() == 0 && "Chain of attributes will be truncated!");
NewAttr->setNext(ExistingAttr);
ExistingAttr = NewAttr;

View File

@ -113,7 +113,7 @@ void PCHDeclReader::VisitDecl(Decl *D) {
D->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
D->setInvalidDecl(Record[Idx++]);
if (Record[Idx++])
D->addAttr(Reader.ReadAttributes());
D->initAttrs(Reader.ReadAttributes());
D->setImplicit(Record[Idx++]);
D->setUsed(Record[Idx++]);
D->setAccess((AccessSpecifier)Record[Idx++]);

View File

@ -4,4 +4,4 @@
int f(int) __attribute__((overloadable));
int f(int) __attribute__((visibility("default"), overloadable));