]> granicus.if.org Git - clang/commitdiff
Fix PCH issue. Attributes of a declaration were truncated to just one when the decl...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 11 Jun 2010 23:09:25 +0000 (23:09 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 11 Jun 2010 23:09:25 +0000 (23:09 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105852 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclBase.h
lib/AST/DeclBase.cpp
lib/Frontend/PCHReaderDecl.cpp
test/PCH/attrs.h

index 3e2435197d29e96a38914407e056be568a3a4084..f6478d9ea6695d5e88a473bbfc3fe63d5f0e1284 100644 (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.
index 8f6fdbc956f8a1bd2d4eae3204563ea3d0073720..f1b78e40fc807d88c03b6a119429466841acab1a 100644 (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;
 
index 7ccf14362f9d8b16fb1c1c24345c90931db5c55e..cece1b659c5c1b92f5dcf15db50514a2790d8f44 100644 (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++]);
index 0d0156515c88bcfd88661fc64feccb3b17650653..58f0589704319f651d1332df4e70271ff0cb0bf9 100644 (file)
@@ -4,4 +4,4 @@
 
 
 
-int f(int) __attribute__((overloadable));
+int f(int) __attribute__((visibility("default"), overloadable));