[cfe-commits] r105852 - in /cfe/trunk: include/clang/AST/DeclBase.h lib/AST/DeclBase.cpp lib/Frontend/PCHReaderDecl.cpp test/PCH/attrs.h
Argiris Kirtzidis
akyrtzi at gmail.com
Fri Jun 11 16:09:25 PDT 2010
Author: akirtzidis
Date: Fri Jun 11 18:09:25 2010
New Revision: 105852
URL: http://llvm.org/viewvc/llvm-project?rev=105852&view=rev
Log:
Fix PCH issue. Attributes of a declaration were truncated to just one when the decl was read from a PCH file.
Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
cfe/trunk/test/PCH/attrs.h
Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=105852&r1=105851&r2=105852&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Fri Jun 11 18:09:25 2010
@@ -297,6 +297,7 @@
}
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.
Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=105852&r1=105851&r2=105852&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Fri Jun 11 18:09:25 2010
@@ -314,9 +314,20 @@
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;
Modified: cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderDecl.cpp?rev=105852&r1=105851&r2=105852&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderDecl.cpp Fri Jun 11 18:09:25 2010
@@ -113,7 +113,7 @@
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++]);
Modified: cfe/trunk/test/PCH/attrs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/attrs.h?rev=105852&r1=105851&r2=105852&view=diff
==============================================================================
--- cfe/trunk/test/PCH/attrs.h (original)
+++ cfe/trunk/test/PCH/attrs.h Fri Jun 11 18:09:25 2010
@@ -4,4 +4,4 @@
-int f(int) __attribute__((overloadable));
+int f(int) __attribute__((visibility("default"), overloadable));
More information about the cfe-commits
mailing list