aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2011-06-23 16:18:44 +0000
committerFariborz Jahanian <fjahanian@apple.com>2011-06-23 16:18:44 +0000
commitbe5a4416ff7c85f0b7edb3f425721a583f26354c (patch)
treefdf7debe5adb20c0126a2b9b01f8ff4137ce1658
parente2456536b5e1699734c60051f41b7cb4020fdfed (diff)
downloadllvm-be5a4416ff7c85f0b7edb3f425721a583f26354c.zip
llvm-be5a4416ff7c85f0b7edb3f425721a583f26354c.tar.gz
llvm-be5a4416ff7c85f0b7edb3f425721a583f26354c.tar.bz2
Remove weak_import attribute on new declaration.
// rdar://9538608 llvm-svn: 133721
-rw-r--r--clang/include/clang/AST/DeclBase.h1
-rw-r--r--clang/lib/AST/DeclBase.cpp14
-rw-r--r--clang/lib/Sema/SemaDecl.cpp4
3 files changed, 16 insertions, 3 deletions
diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h
index b5047b9..8d1ef8f 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -363,6 +363,7 @@ public:
const AttrVec &getAttrs() const;
void swapAttrs(Decl *D);
void dropAttrs();
+ void dropWeakImportAttr();
void addAttr(Attr *A) {
if (hasAttrs())
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 1766d39..c183e61 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -520,6 +520,20 @@ void Decl::dropAttrs() {
getASTContext().eraseDeclAttrs(this);
}
+void Decl::dropWeakImportAttr() {
+ if (!HasAttrs) return;
+ AttrVec &Attrs = getASTContext().getDeclAttrs(this);
+ for (llvm::SmallVectorImpl<Attr*>::iterator A = Attrs.begin();
+ A != Attrs.end(); ++A) {
+ if (isa<WeakImportAttr>(*A)) {
+ Attrs.erase(A);
+ break;
+ }
+ }
+ if (Attrs.empty())
+ HasAttrs = false;
+}
+
const AttrVec &Decl::getAttrs() const {
assert(HasAttrs && "No attrs to get!");
return getASTContext().getDeclAttrs(this);
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index daf9f03..487390b 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2046,9 +2046,7 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous) {
Diag(New->getLocation(), diag::warn_weak_import) << New->getDeclName();
Diag(Old->getLocation(), diag::note_previous_definition);
// Remove weak_import attribute on new declaration.
- // I am just dropping all attributes in curernt decl. We have
- // already issued a warning, so we are OK.
- New->dropAttrs();
+ New->dropWeakImportAttr();
}
// Merge the types.