[cfe-commits] r108195 - in /cfe/trunk: include/clang/AST/DeclBase.h lib/AST/DeclBase.cpp lib/Sema/SemaTemplateInstantiateDecl.cpp lib/Sema/TreeTransform.h
Fariborz Jahanian
fjahanian at apple.com
Mon Jul 12 14:12:19 PDT 2010
Author: fjahanian
Date: Mon Jul 12 16:12:19 2010
New Revision: 108195
URL: http://llvm.org/viewvc/llvm-project?rev=108195&view=rev
Log:
Copy over attributes to instantiated variable.
Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/TreeTransform.h
Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=108195&r1=108194&r2=108195&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Mon Jul 12 16:12:19 2010
@@ -312,6 +312,7 @@
return getAttrsImpl(); // Uncommon case, out of line hash lookup.
}
void swapAttrs(Decl *D);
+ void copyAttrs(Decl *D);
void invalidateAttrs();
template<typename T> const T *getAttr() const {
Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=108195&r1=108194&r2=108195&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Mon Jul 12 16:12:19 2010
@@ -372,6 +372,17 @@
RHS->HasAttrs = true;
}
+void Decl::copyAttrs(Decl *SRC) {
+ if (!SRC->hasAttrs())
+ return;
+ ASTContext &Context = getASTContext();
+ for (const Attr *attr = SRC->getAttrs(); attr; attr = attr->getNext()) {
+ Attr *NewAttr = attr->clone(Context);
+ addAttr(const_cast<Attr*>(NewAttr));
+ }
+ HasAttrs = true;
+}
+
void Decl::Destroy(ASTContext &C) {
// Free attributes for this decl.
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=108195&r1=108194&r2=108195&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Mon Jul 12 16:12:19 2010
@@ -2591,7 +2591,10 @@
ParentDC->isFunctionOrMethod()) {
// D is a local of some kind. Look into the map of local
// declarations to their instantiations.
- return cast<NamedDecl>(CurrentInstantiationScope->getInstantiationOf(D));
+ NamedDecl *ND =
+ cast<NamedDecl>(CurrentInstantiationScope->getInstantiationOf(D));
+ ND->copyAttrs(D);
+ return ND;
}
if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(D)) {
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=108195&r1=108194&r2=108195&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Mon Jul 12 16:12:19 2010
@@ -6279,11 +6279,6 @@
if (!ND)
return SemaRef.ExprError();
- // Is this instantiation of a __block variable?
- ValueDecl *V = E->getDecl();
- if (V->getAttr<BlocksAttr>())
- ND->addAttr(::new (SemaRef.Context) BlocksAttr(BlocksAttr::ByRef));
-
if (!getDerived().AlwaysRebuild() &&
ND == E->getDecl()) {
// Mark it referenced in the new context regardless.
More information about the cfe-commits
mailing list