diff options
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/DeclBase.cpp | 11 | ||||
| -rw-r--r-- | clang/lib/Frontend/PCHReaderDecl.cpp | 2 | 
2 files changed, 12 insertions, 1 deletions
| diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 8f6fdbc956f..f1b78e40fc8 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -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; diff --git a/clang/lib/Frontend/PCHReaderDecl.cpp b/clang/lib/Frontend/PCHReaderDecl.cpp index 7ccf14362f9..cece1b659c5 100644 --- a/clang/lib/Frontend/PCHReaderDecl.cpp +++ b/clang/lib/Frontend/PCHReaderDecl.cpp @@ -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++]); | 

