aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDeclAttr.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-01-12 06:42:30 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-01-12 06:42:30 +0000
commit838dc597e25614c653a062a124b06a04d6b7f5eb (patch)
tree2c93daa5ee846c400fdfdc9b335b829f74048958 /lib/Sema/SemaDeclAttr.cpp
parentbcfdd263b79c766db9154b009bd831ef83090c83 (diff)
Disable caching of visibility.
The testcase in pr14929 shows that this is extremely hard to do. If we choose to apply the attribute, that causes the visibility of some decls to change and that can happen really late (during codegen). Current gcc warns and ignores the attribute in this testcase with a warning. This suggest that the correct solution is to find a point in the compilation where we can compute the visibility and * assert it was never computed before * reject any attempts to compute it again in the future (with warnings). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172305 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclAttr.cpp')
-rw-r--r--lib/Sema/SemaDeclAttr.cpp17
1 files changed, 2 insertions, 15 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 225ee24d0f..9c17d6eabd 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -2043,7 +2043,6 @@ AvailabilityAttr *Sema::mergeAvailabilityAttr(NamedDecl *D, SourceRange Range,
VersionTuple MergedDeprecated = Deprecated;
VersionTuple MergedObsoleted = Obsoleted;
bool FoundAny = false;
- bool DroppedAny = false;
if (D->hasAttrs()) {
AttrVec &Attrs = D->getAttrs();
@@ -2078,7 +2077,6 @@ AvailabilityAttr *Sema::mergeAvailabilityAttr(NamedDecl *D, SourceRange Range,
Diag(OldAA->getLocation(), diag::warn_mismatched_availability);
Diag(Range.getBegin(), diag::note_previous_attribute);
Attrs.erase(Attrs.begin() + i);
- DroppedAny = true;
--e;
continue;
}
@@ -2098,7 +2096,6 @@ AvailabilityAttr *Sema::mergeAvailabilityAttr(NamedDecl *D, SourceRange Range,
MergedIntroduced2, MergedDeprecated2,
MergedObsoleted2)) {
Attrs.erase(Attrs.begin() + i);
- DroppedAny = true;
--e;
continue;
}
@@ -2110,9 +2107,6 @@ AvailabilityAttr *Sema::mergeAvailabilityAttr(NamedDecl *D, SourceRange Range,
}
}
- if (DroppedAny)
- D->ClearLVCache();
-
if (FoundAny &&
MergedIntroduced == Introduced &&
MergedDeprecated == Deprecated &&
@@ -2159,10 +2153,8 @@ static void handleAvailabilityAttr(Sema &S, Decl *D,
Deprecated.Version,
Obsoleted.Version,
IsUnavailable, Str);
- if (NewAttr) {
+ if (NewAttr)
D->addAttr(NewAttr);
- ND->ClearLVCache();
- }
}
VisibilityAttr *Sema::mergeVisibilityAttr(Decl *D, SourceRange Range,
@@ -2179,8 +2171,6 @@ VisibilityAttr *Sema::mergeVisibilityAttr(Decl *D, SourceRange Range,
Diag(ExistingAttr->getLocation(), diag::err_mismatched_visibility);
Diag(Range.getBegin(), diag::note_previous_attribute);
D->dropAttr<VisibilityAttr>();
- NamedDecl *ND = cast<NamedDecl>(D);
- ND->ClearLVCache();
}
return ::new (Context) VisibilityAttr(Range, Context, Vis);
}
@@ -2224,11 +2214,8 @@ static void handleVisibilityAttr(Sema &S, Decl *D, const AttributeList &Attr) {
}
VisibilityAttr *NewAttr = S.mergeVisibilityAttr(D, Attr.getRange(), type);
- if (NewAttr) {
+ if (NewAttr)
D->addAttr(NewAttr);
- NamedDecl *ND = cast<NamedDecl>(D);
- ND->ClearLVCache();
- }
}
static void handleObjCMethodFamilyAttr(Sema &S, Decl *decl,