summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclAttr.cpp
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2016-05-06 21:04:01 +0000
committerManman Ren <manman.ren@gmail.com>2016-05-06 21:04:01 +0000
commit719a864147e0fe6beb145424c8e9958a9ceb23d9 (patch)
treedb8aa5ddc61c0cd0bfbca1c110ae8544f436c50d /clang/lib/Sema/SemaDeclAttr.cpp
parent2b37017c38a4af183b4435bbec20c12b22537d26 (diff)
downloadbcm5719-llvm-719a864147e0fe6beb145424c8e9958a9ceb23d9.tar.gz
bcm5719-llvm-719a864147e0fe6beb145424c8e9958a9ceb23d9.zip
Availability: set location when creating attribute for tvos, watchos.
When inferring availability attributes for tvos, watchos from ios, we use the same source location and set the implicit bit to true. So when emitting diagnostics on inferred attributes, we have a source location. rdar://25893544 llvm-svn: 268793
Diffstat (limited to 'clang/lib/Sema/SemaDeclAttr.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index e0272a0eb63..f185d9c4b42 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -1957,6 +1957,7 @@ static bool versionsMatch(const VersionTuple &X, const VersionTuple &Y,
AvailabilityAttr *Sema::mergeAvailabilityAttr(NamedDecl *D, SourceRange Range,
IdentifierInfo *Platform,
+ bool Implicit,
VersionTuple Introduced,
VersionTuple Deprecated,
VersionTuple Obsoleted,
@@ -2001,14 +2002,14 @@ AvailabilityAttr *Sema::mergeAvailabilityAttr(NamedDecl *D, SourceRange Range,
// If there is an existing availability attribute for this platform that
// is explicit and the new one is implicit use the explicit one and
// discard the new implicit attribute.
- if (OldAA->getRange().isValid() && Range.isInvalid()) {
+ if (!OldAA->isImplicit() && Implicit) {
return nullptr;
}
// If there is an existing attribute for this platform that is implicit
// and the new attribute is explicit then erase the old one and
// continue processing the attributes.
- if (Range.isValid() && OldAA->getRange().isInvalid()) {
+ if (!Implicit && OldAA->isImplicit()) {
Attrs.erase(Attrs.begin() + i);
--e;
continue;
@@ -2107,11 +2108,13 @@ AvailabilityAttr *Sema::mergeAvailabilityAttr(NamedDecl *D, SourceRange Range,
if (!checkAvailabilityAttr(*this, Range, Platform, MergedIntroduced,
MergedDeprecated, MergedObsoleted) &&
!OverrideOrImpl) {
- return ::new (Context) AvailabilityAttr(Range, Context, Platform,
+ auto *Avail = ::new (Context) AvailabilityAttr(Range, Context, Platform,
Introduced, Deprecated,
Obsoleted, IsUnavailable, Message,
IsStrict, Replacement,
AttrSpellingListIndex);
+ Avail->setImplicit(Implicit);
+ return Avail;
}
return nullptr;
}
@@ -2149,6 +2152,7 @@ static void handleAvailabilityAttr(Sema &S, Decl *D,
Replacement = SE->getString();
AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr(ND, Attr.getRange(), II,
+ false/*Implicit*/,
Introduced.Version,
Deprecated.Version,
Obsoleted.Version,
@@ -2192,8 +2196,9 @@ static void handleAvailabilityAttr(Sema &S, Decl *D,
auto NewObsoleted = adjustWatchOSVersion(Obsoleted.Version);
AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr(ND,
- SourceRange(),
+ Attr.getRange(),
NewII,
+ true/*Implicit*/,
NewIntroduced,
NewDeprecated,
NewObsoleted,
@@ -2216,8 +2221,9 @@ static void handleAvailabilityAttr(Sema &S, Decl *D,
if (NewII) {
AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr(ND,
- SourceRange(),
+ Attr.getRange(),
NewII,
+ true/*Implicit*/,
Introduced.Version,
Deprecated.Version,
Obsoleted.Version,
OpenPOWER on IntegriCloud