]> granicus.if.org Git - clang/commitdiff
Revert r263687 for ubsan bot failure.
authorManman Ren <manman.ren@gmail.com>
Thu, 17 Mar 2016 22:13:50 +0000 (22:13 +0000)
committerManman Ren <manman.ren@gmail.com>
Thu, 17 Mar 2016 22:13:50 +0000 (22:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263752 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Attr.td
include/clang/Basic/AttrDocs.td
include/clang/Parse/Parser.h
include/clang/Sema/AttributeList.h
include/clang/Sema/Sema.h
lib/Lex/PPMacroExpansion.cpp
lib/Parse/ParseDecl.cpp
lib/Parse/Parser.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclAttr.cpp
test/SemaCXX/attr-deprecated-replacement-fixit.cpp

index c7a797cdd13e5a743a69224e51adb8154dd6be6a..fc0baa84b5be6f512fbd0ce846f7369d6abc8836 100644 (file)
@@ -467,7 +467,7 @@ def Availability : InheritableAttr {
   let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
               VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
               BoolArgument<"unavailable">, StringArgument<"message">,
-              BoolArgument<"strict">, StringArgument<"replacement">];
+              BoolArgument<"strict">];
   let AdditionalMembers =
 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
     return llvm::StringSwitch<llvm::StringRef>(Platform)
index af117588308ba91dd69e1dc929be70c4b94f0a1d..eabba7826e6fce3e429f1f0a478ff7fa4fdcf4cb 100644 (file)
@@ -661,11 +661,6 @@ message=\ *string-literal*
   error about use of a deprecated or obsoleted declaration.  Useful to direct
   users to replacement APIs.
 
-replacement=\ *string-literal*
-  Additional message text that Clang will use to provide Fix-It when emitting
-  a warning about use of a deprecated declaration. The Fix-It will replace
-  the deprecated declaration with the new declaration specified.
-
 Multiple availability attributes can be placed on a declaration, which may
 correspond to different platforms.  Only the availability attribute with the
 platform corresponding to the target platform will be used; any others will be
index ecfd3a382e7828309e950456a8892eb7442047b8..7e89fdc4a77d3f45530865c703ee573fff0c0fa8 100644 (file)
@@ -137,9 +137,6 @@ class Parser : public CodeCompletionHandler {
   /// \brief Identifier for "strict".
   IdentifierInfo *Ident_strict;
 
-  /// \brief Identifier for "replacement".
-  IdentifierInfo *Ident_replacement;
-
   /// C++0x contextual keywords.
   mutable IdentifierInfo *Ident_final;
   mutable IdentifierInfo *Ident_override;
index c2c087ffdc594baaefb40f78ef91400c62dd658b..c59f3b9dd54f5bcfddb9ee554d1acb0598c1050c 100644 (file)
@@ -174,14 +174,6 @@ private:
                &getAvailabilitySlot(ObsoletedSlot) + 1);
   }
 
-  const Expr **getReplacementSlot() {
-    return reinterpret_cast<const Expr**>(getStrictSlot() + 1);
-  }
-
-  const Expr *const *getReplacementSlot() const {
-    return reinterpret_cast<const Expr *const *>(getStrictSlot() + 1);
-  }
-
 public:
   struct TypeTagForDatatypeData {
     ParsedType *MatchingCType;
@@ -259,8 +251,7 @@ private:
                 const AvailabilityChange &obsoleted,
                 SourceLocation unavailable, 
                 const Expr *messageExpr,
-                Syntax syntaxUsed, SourceLocation strict,
-                const Expr *replacementExpr)
+                Syntax syntaxUsed, SourceLocation strict)
     : AttrName(attrName), ScopeName(scopeName), AttrRange(attrRange),
       ScopeLoc(scopeLoc), EllipsisLoc(), NumArgs(1), SyntaxUsed(syntaxUsed),
       Invalid(false), UsedAsTypeAttr(false), IsAvailability(true),
@@ -273,7 +264,6 @@ private:
     new (&getAvailabilitySlot(DeprecatedSlot)) AvailabilityChange(deprecated);
     new (&getAvailabilitySlot(ObsoletedSlot)) AvailabilityChange(obsoleted);
     memcpy(getStrictSlot(), &strict, sizeof(SourceLocation));
-    *getReplacementSlot() = replacementExpr;
     AttrKind = getKind(getName(), getScopeName(), syntaxUsed);
   }
 
@@ -466,11 +456,6 @@ public:
     return MessageExpr;
   }
 
-  const Expr *getReplacementExpr() const {
-    assert(getKind() == AT_Availability && "Not an availability attribute");
-    return *getReplacementSlot();
-  }
-
   const ParsedType &getMatchingCType() const {
     assert(getKind() == AT_TypeTagForDatatype &&
            "Not a type_tag_for_datatype attribute");
@@ -538,7 +523,7 @@ public:
     AvailabilityAllocSize =
       sizeof(AttributeList)
       + ((3 * sizeof(AvailabilityChange) + sizeof(void*) +
-         sizeof(ArgsUnion) + sizeof(SourceLocation) + sizeof(const Expr *) - 1)
+         sizeof(ArgsUnion) + sizeof(SourceLocation) - 1)
          / sizeof(void*) * sizeof(void*)),
     TypeTagForDatatypeAllocSize =
       sizeof(AttributeList)
@@ -657,13 +642,13 @@ public:
                         SourceLocation unavailable,
                         const Expr *MessageExpr,
                         AttributeList::Syntax syntax,
-                        SourceLocation strict, const Expr *ReplacementExpr) {
+                        SourceLocation strict) {
     void *memory = allocate(AttributeFactory::AvailabilityAllocSize);
     return add(new (memory) AttributeList(attrName, attrRange,
                                           scopeName, scopeLoc,
                                           Param, introduced, deprecated,
                                           obsoleted, unavailable, MessageExpr,
-                                          syntax, strict, ReplacementExpr));
+                                          syntax, strict));
   }
 
   AttributeList *create(IdentifierInfo *attrName, SourceRange attrRange,
@@ -793,11 +778,11 @@ public:
                         SourceLocation unavailable,
                         const Expr *MessageExpr,
                         AttributeList::Syntax syntax,
-                        SourceLocation strict, const Expr *ReplacementExpr) {
+                        SourceLocation strict) {
     AttributeList *attr =
       pool.create(attrName, attrRange, scopeName, scopeLoc, Param, introduced,
                   deprecated, obsoleted, unavailable, MessageExpr, syntax,
-                  strict, ReplacementExpr);
+                  strict);
     add(attr);
     return attr;
   }
index ba39b10be0d0707ebc107f83dad82dfc5fa14387..27c35e944f18d6b93f3101df40d9212f2342ac8f 100644 (file)
@@ -2110,7 +2110,7 @@ public:
                                           VersionTuple Obsoleted,
                                           bool IsUnavailable,
                                           StringRef Message,
-                                          bool IsStrict, StringRef Replacement,
+                                          bool IsStrict,
                                           AvailabilityMergeKind AMK,
                                           unsigned AttrSpellingListIndex);
   TypeVisibilityAttr *mergeTypeVisibilityAttr(Decl *D, SourceRange Range,
index 50ce2719d36ada7365c385caac7f025f06062a5f..36255a81144cd116d1541532e1542d9b0db5cb5e 100644 (file)
@@ -1074,7 +1074,6 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) {
       .Case("attribute_availability_tvos", true)
       .Case("attribute_availability_watchos", true)
       .Case("attribute_availability_with_strict", true)
-      .Case("attribute_availability_with_replacement", true)
       .Case("attribute_availability_in_templates", true)
       .Case("attribute_cf_returns_not_retained", true)
       .Case("attribute_cf_returns_retained", true)
index fef5d8d4441a10623c7b232043dc96d697391c98..52f3f9fe5040b277fcef0b614b3ad2cc9b038387 100644 (file)
@@ -833,8 +833,7 @@ VersionTuple Parser::ParseVersionTuple(SourceRange &Range) {
 /// \brief Parse the contents of the "availability" attribute.
 ///
 /// availability-attribute:
-///   'availability' '(' platform ',' opt-strict version-arg-list,
-///                      opt-replacement, opt-message')'
+///   'availability' '(' platform ',' opt-strict version-arg-list, opt-message')'
 ///
 /// platform:
 ///   identifier
@@ -851,8 +850,6 @@ VersionTuple Parser::ParseVersionTuple(SourceRange &Range) {
 ///   'deprecated' '=' version
 ///   'obsoleted' = version
 ///   'unavailable'
-/// opt-replacement:
-///   'replacement' '=' <string>
 /// opt-message:
 ///   'message' '=' <string>
 void Parser::ParseAvailabilityAttribute(IdentifierInfo &Availability,
@@ -864,7 +861,7 @@ void Parser::ParseAvailabilityAttribute(IdentifierInfo &Availability,
                                         AttributeList::Syntax Syntax) {
   enum { Introduced, Deprecated, Obsoleted, Unknown };
   AvailabilityChange Changes[Unknown];
-  ExprResult MessageExpr, ReplacementExpr;
+  ExprResult MessageExpr;
 
   // Opening '('.
   BalancedDelimiterTracker T(*this, tok::l_paren);
@@ -896,10 +893,9 @@ void Parser::ParseAvailabilityAttribute(IdentifierInfo &Availability,
     Ident_unavailable = PP.getIdentifierInfo("unavailable");
     Ident_message = PP.getIdentifierInfo("message");
     Ident_strict = PP.getIdentifierInfo("strict");
-    Ident_replacement = PP.getIdentifierInfo("replacement");
   }
 
-  // Parse the optional "strict", the optional "replacement" and the set of
+  // Parse the optional "strict" and the set of
   // introductions/deprecations/removals.
   SourceLocation UnavailableLoc, StrictLoc;
   do {
@@ -935,17 +931,14 @@ void Parser::ParseAvailabilityAttribute(IdentifierInfo &Availability,
       return;
     }
     ConsumeToken();
-    if (Keyword == Ident_message || Keyword == Ident_replacement) {
+    if (Keyword == Ident_message) {
       if (Tok.isNot(tok::string_literal)) {
         Diag(Tok, diag::err_expected_string_literal)
           << /*Source='availability attribute'*/2;
         SkipUntil(tok::r_paren, StopAtSemi);
         return;
       }
-      if (Keyword == Ident_message)
-        MessageExpr = ParseStringLiteralExpression();
-      else
-        ReplacementExpr = ParseStringLiteralExpression();
+      MessageExpr = ParseStringLiteralExpression();
       // Also reject wide string literals.
       if (StringLiteral *MessageStringLiteral =
               cast_or_null<StringLiteral>(MessageExpr.get())) {
@@ -957,10 +950,7 @@ void Parser::ParseAvailabilityAttribute(IdentifierInfo &Availability,
           return;
         }
       }
-      if (Keyword == Ident_message)
-        break;
-      else
-        continue;
+      break;
     }
 
     // Special handling of 'NA' only when applied to introduced or
@@ -1047,7 +1037,7 @@ void Parser::ParseAvailabilityAttribute(IdentifierInfo &Availability,
                Changes[Deprecated],
                Changes[Obsoleted],
                UnavailableLoc, MessageExpr.get(),
-               Syntax, StrictLoc, ReplacementExpr.get());
+               Syntax, StrictLoc);
 }
 
 /// \brief Parse the contents of the "objc_bridge_related" attribute.
index 07f60cbbe167b8530ee949dcb9581f835fb7e997..9ef57cb53841508d4c5a731cd52c54f9ee325082 100644 (file)
@@ -492,7 +492,6 @@ void Parser::Initialize() {
   Ident_obsoleted = nullptr;
   Ident_unavailable = nullptr;
   Ident_strict = nullptr;
-  Ident_replacement = nullptr;
 
   Ident__except = nullptr;
 
index 2f50b701cad5a78151346717af9c2d1f30c7e340..d8740d2beb1cf7d25ee9c57e743b99615aabafc6 100644 (file)
@@ -2196,8 +2196,7 @@ static bool mergeDeclAttribute(Sema &S, NamedDecl *D,
     NewAttr = S.mergeAvailabilityAttr(D, AA->getRange(), AA->getPlatform(),
                                       AA->getIntroduced(), AA->getDeprecated(),
                                       AA->getObsoleted(), AA->getUnavailable(),
-                                      AA->getMessage(), AA->getStrict(),
-                                      AA->getReplacement(), AMK,
+                                      AA->getMessage(), AA->getStrict(), AMK,
                                       AttrSpellingListIndex);
   else if (const auto *VA = dyn_cast<VisibilityAttr>(Attr))
     NewAttr = S.mergeVisibilityAttr(D, VA->getRange(), VA->getVisibility(),
index c90d6236c188d90346aa8d227931b6be87df573f..18065cb52d83b13ce4aede9067d48d817944da52 100644 (file)
@@ -1941,7 +1941,6 @@ AvailabilityAttr *Sema::mergeAvailabilityAttr(NamedDecl *D, SourceRange Range,
                                               bool IsUnavailable,
                                               StringRef Message,
                                               bool IsStrict,
-                                              StringRef Replacement,
                                               AvailabilityMergeKind AMK,
                                               unsigned AttrSpellingListIndex) {
   VersionTuple MergedIntroduced = Introduced;
@@ -2088,8 +2087,7 @@ AvailabilityAttr *Sema::mergeAvailabilityAttr(NamedDecl *D, SourceRange Range,
     return ::new (Context) AvailabilityAttr(Range, Context, Platform,
                                             Introduced, Deprecated,
                                             Obsoleted, IsUnavailable, Message,
-                                            IsStrict, Replacement,
-                                            AttrSpellingListIndex);
+                                            IsStrict, AttrSpellingListIndex);
   }
   return nullptr;
 }
@@ -2121,17 +2119,13 @@ static void handleAvailabilityAttr(Sema &S, Decl *D,
   if (const StringLiteral *SE =
           dyn_cast_or_null<StringLiteral>(Attr.getMessageExpr()))
     Str = SE->getString();
-  StringRef Replacement;
-  if (const StringLiteral *SE =
-          dyn_cast_or_null<StringLiteral>(Attr.getReplacementExpr()))
-    Replacement = SE->getString();
 
   AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr(ND, Attr.getRange(), II,
                                                       Introduced.Version,
                                                       Deprecated.Version,
                                                       Obsoleted.Version,
                                                       IsUnavailable, Str,
-                                                      IsStrict, Replacement,
+                                                      IsStrict,
                                                       Sema::AMK_None,
                                                       Index);
   if (NewAttr)
@@ -2177,7 +2171,6 @@ static void handleAvailabilityAttr(Sema &S, Decl *D,
                                                             NewObsoleted,
                                                             IsUnavailable, Str,
                                                             IsStrict,
-                                                            Replacement,
                                                             Sema::AMK_None,
                                                             Index);
         if (NewAttr)
@@ -2201,7 +2194,6 @@ static void handleAvailabilityAttr(Sema &S, Decl *D,
                                                             Obsoleted.Version,
                                                             IsUnavailable, Str,
                                                             IsStrict,
-                                                            Replacement,
                                                             Sema::AMK_None,
                                                             Index);
         if (NewAttr)
@@ -6237,8 +6229,6 @@ static void DoEmitAvailabilityWarning(Sema &S, Sema::AvailabilityDiagnostic K,
   if (K == Sema::AD_Deprecation) {
     if (auto attr = D->getAttr<DeprecatedAttr>())
       Replacement = attr->getReplacement();
-    if (auto attr = D->getAttr<AvailabilityAttr>())
-      Replacement = attr->getReplacement();
 
     if (!Replacement.empty())
       UseRange =
index 8e0af7a648d5e503e224500420c178b12ece6a77..9a2d0f409aaa96ab0c2d8f8e7fdebc888a38a8cd 100644 (file)
@@ -8,17 +8,9 @@
 #error "Missing __has_feature"
 #endif
 
-#if !__has_feature(attribute_availability_with_replacement)
-#error "Missing __has_feature"
-#endif
-
 void f_8(int) __attribute__((deprecated("message", "new8"))); // expected-note {{'f_8' has been explicitly marked deprecated here}}
 void new8(int);
-void f_2(int) __attribute__((availability(macosx,deprecated=9.0,replacement="new2"))); // expected-note {{'f_2' has been explicitly marked deprecated here}}
-void new2(int);
 void test() {
   f_8(0); // expected-warning{{'f_8' is deprecated}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:6}:"new8"
-  f_2(0); // expected-warning{{'f_2' is deprecated: first deprecated in OS X 9.0}}
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:6}:"new2"
 }