Re: r263687 - Add an optional named argument (replacement = "xxx") to AvailabilityAttr.

2016-03-19 Thread Manman Ren via cfe-commits
Sorry, working on it.

Manman

On Thu, Mar 17, 2016 at 12:45 PM, Kostya Serebryany  wrote:

> This change is causing ubsan bot to complain
> 
> .
> Please fix or revert.
>
> Most likely the guilty part is this:
>
> +*getReplacementSlot() = replacementExpr;
>
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/Sema/AttributeList.h:276:5:
>  runtime error: store to misaligned address 0x19b3784c for type 'const 
> clang::Expr *', which requires 8 byte alignment
> 0x19b3784c: note: pointer points here
>   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  
> 00 00 00 00 00 00 00 00  ^
> #0 0x448295e in 
> clang::AttributeList::AttributeList(clang::IdentifierInfo*, 
> clang::SourceRange, clang::IdentifierInfo*, clang::SourceLocation, 
> clang::IdentifierLoc*, clang::AvailabilityChange const&, 
> clang::AvailabilityChange const&, clang::AvailabilityChange const&, 
> clang::SourceLocation, clang::Expr const*, clang::AttributeList::Syntax, 
> clang::SourceLocation, clang::Expr const*) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/Sema/AttributeList.h:276:27
> #1 0x448269c in clang::AttributePool::create(clang::IdentifierInfo*, 
> clang::SourceRange, clang::IdentifierInfo*, clang::SourceLocation, 
> clang::IdentifierLoc*, clang::AvailabilityChange const&, 
> clang::AvailabilityChange const&, clang::AvailabilityChange const&, 
> clang::SourceLocation, clang::Expr const*, clang::AttributeList::Syntax, 
> clang::SourceLocation, clang::Expr const*) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/Sema/AttributeList.h:662:29
> #2 0x447c52d in clang::ParsedAttributes::addNew(clang::IdentifierInfo*, 
> clang::SourceRange, clang::IdentifierInfo*, clang::SourceLocation, 
> clang::IdentifierLoc*, clang::AvailabilityChange const&, 
> clang::AvailabilityChange const&, clang::AvailabilityChange const&, 
> clang::SourceLocation, clang::Expr const*, clang::AttributeList::Syntax, 
> clang::SourceLocation, clang::Expr const*) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/Sema/AttributeList.h:798:7
> #3 0x4465a73 in clang::Parser::Pa
>
>
>
>
> On Wed, Mar 16, 2016 at 8:09 PM, Manman Ren via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: mren
>> Date: Wed Mar 16 22:09:55 2016
>> New Revision: 263687
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=263687=rev
>> Log:
>> Add an optional named argument (replacement = "xxx") to AvailabilityAttr.
>>
>> This commit adds a named argument to AvailabilityAttr, while r263652 adds
>> an
>> optional string argument to __attribute__((deprecated)). This enables the
>> compiler to provide Fix-Its for deprecated declarations.
>>
>> rdar://20588929
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/Attr.td
>> cfe/trunk/include/clang/Basic/AttrDocs.td
>> cfe/trunk/include/clang/Parse/Parser.h
>> cfe/trunk/include/clang/Sema/AttributeList.h
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>> cfe/trunk/lib/Parse/ParseDecl.cpp
>> cfe/trunk/lib/Parse/Parser.cpp
>> cfe/trunk/lib/Sema/SemaDecl.cpp
>> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> cfe/trunk/test/SemaCXX/attr-deprecated-replacement-fixit.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/Attr.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=263687=263686=263687=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/Attr.td (original)
>> +++ cfe/trunk/include/clang/Basic/Attr.td Wed Mar 16 22:09:55 2016
>> @@ -467,7 +467,7 @@ def Availability : InheritableAttr {
>>let Args = [IdentifierArgument<"platform">,
>> VersionArgument<"introduced">,
>>VersionArgument<"deprecated">,
>> VersionArgument<"obsoleted">,
>>BoolArgument<"unavailable">, StringArgument<"message">,
>> -  BoolArgument<"strict">];
>> +  BoolArgument<"strict">, StringArgument<"replacement">];
>>let AdditionalMembers =
>>  [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform)
>> {
>>  return llvm::StringSwitch(Platform)
>>
>> Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=263687=263686=263687=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
>> +++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed Mar 16 22:09:55 2016
>> @@ -661,6 +661,11 @@ message=\ *string-literal*
>>error about use of a deprecated or obsoleted declaration.  Useful 

r263687 - Add an optional named argument (replacement = "xxx") to AvailabilityAttr.

2016-03-19 Thread Manman Ren via cfe-commits
Author: mren
Date: Wed Mar 16 22:09:55 2016
New Revision: 263687

URL: http://llvm.org/viewvc/llvm-project?rev=263687=rev
Log:
Add an optional named argument (replacement = "xxx") to AvailabilityAttr.

This commit adds a named argument to AvailabilityAttr, while r263652 adds an
optional string argument to __attribute__((deprecated)). This enables the
compiler to provide Fix-Its for deprecated declarations.

rdar://20588929

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

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=263687=263686=263687=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed Mar 16 22:09:55 2016
@@ -467,7 +467,7 @@ def Availability : InheritableAttr {
   let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
   VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
   BoolArgument<"unavailable">, StringArgument<"message">,
-  BoolArgument<"strict">];
+  BoolArgument<"strict">, StringArgument<"replacement">];
   let AdditionalMembers =
 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
 return llvm::StringSwitch(Platform)

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=263687=263686=263687=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed Mar 16 22:09:55 2016
@@ -661,6 +661,11 @@ 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

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=263687=263686=263687=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Wed Mar 16 22:09:55 2016
@@ -137,6 +137,9 @@ class Parser : public CodeCompletionHand
   /// \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;

Modified: cfe/trunk/include/clang/Sema/AttributeList.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=263687=263686=263687=diff
==
--- cfe/trunk/include/clang/Sema/AttributeList.h (original)
+++ cfe/trunk/include/clang/Sema/AttributeList.h Wed Mar 16 22:09:55 2016
@@ -174,6 +174,14 @@ private:
(ObsoletedSlot) + 1);
   }
 
+  const Expr **getReplacementSlot() {
+return reinterpret_cast(getStrictSlot() + 1);
+  }
+
+  const Expr *const *getReplacementSlot() const {
+return reinterpret_cast(getStrictSlot() + 1);
+  }
+
 public:
   struct TypeTagForDatatypeData {
 ParsedType *MatchingCType;
@@ -251,7 +259,8 @@ private:
 const AvailabilityChange ,
 SourceLocation unavailable, 
 const Expr *messageExpr,
-Syntax syntaxUsed, SourceLocation strict)
+Syntax syntaxUsed, SourceLocation strict,
+const Expr *replacementExpr)
 : AttrName(attrName), ScopeName(scopeName), AttrRange(attrRange),
   ScopeLoc(scopeLoc), EllipsisLoc(), NumArgs(1), SyntaxUsed(syntaxUsed),
   Invalid(false), UsedAsTypeAttr(false), IsAvailability(true),
@@ -264,6 +273,7 @@ private:
 new ((DeprecatedSlot)) AvailabilityChange(deprecated);
 new ((ObsoletedSlot)) AvailabilityChange(obsoleted);
 memcpy(getStrictSlot(), , 

Re: r263687 - Add an optional named argument (replacement = "xxx") to AvailabilityAttr.

2016-03-19 Thread Kostya Serebryany via cfe-commits
This change is causing ubsan bot to complain

.
Please fix or revert.

Most likely the guilty part is this:

+*getReplacementSlot() = replacementExpr;

/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/Sema/AttributeList.h:276:5:
runtime error: store to misaligned address 0x19b3784c for type
'const clang::Expr *', which requires 8 byte alignment
0x19b3784c: note: pointer points here
  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00
00 00  00 00 00 00 00 00 00 00  ^
#0 0x448295e in
clang::AttributeList::AttributeList(clang::IdentifierInfo*,
clang::SourceRange, clang::IdentifierInfo*, clang::SourceLocation,
clang::IdentifierLoc*, clang::AvailabilityChange const&,
clang::AvailabilityChange const&, clang::AvailabilityChange const&,
clang::SourceLocation, clang::Expr const*,
clang::AttributeList::Syntax, clang::SourceLocation, clang::Expr
const*) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/Sema/AttributeList.h:276:27
#1 0x448269c in
clang::AttributePool::create(clang::IdentifierInfo*,
clang::SourceRange, clang::IdentifierInfo*, clang::SourceLocation,
clang::IdentifierLoc*, clang::AvailabilityChange const&,
clang::AvailabilityChange const&, clang::AvailabilityChange const&,
clang::SourceLocation, clang::Expr const*,
clang::AttributeList::Syntax, clang::SourceLocation, clang::Expr
const*) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/Sema/AttributeList.h:662:29
#2 0x447c52d in
clang::ParsedAttributes::addNew(clang::IdentifierInfo*,
clang::SourceRange, clang::IdentifierInfo*, clang::SourceLocation,
clang::IdentifierLoc*, clang::AvailabilityChange const&,
clang::AvailabilityChange const&, clang::AvailabilityChange const&,
clang::SourceLocation, clang::Expr const*,
clang::AttributeList::Syntax, clang::SourceLocation, clang::Expr
const*) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/Sema/AttributeList.h:798:7
#3 0x4465a73 in clang::Parser::Pa




On Wed, Mar 16, 2016 at 8:09 PM, Manman Ren via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: mren
> Date: Wed Mar 16 22:09:55 2016
> New Revision: 263687
>
> URL: http://llvm.org/viewvc/llvm-project?rev=263687=rev
> Log:
> Add an optional named argument (replacement = "xxx") to AvailabilityAttr.
>
> This commit adds a named argument to AvailabilityAttr, while r263652 adds
> an
> optional string argument to __attribute__((deprecated)). This enables the
> compiler to provide Fix-Its for deprecated declarations.
>
> rdar://20588929
>
> Modified:
> cfe/trunk/include/clang/Basic/Attr.td
> cfe/trunk/include/clang/Basic/AttrDocs.td
> cfe/trunk/include/clang/Parse/Parser.h
> cfe/trunk/include/clang/Sema/AttributeList.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Lex/PPMacroExpansion.cpp
> cfe/trunk/lib/Parse/ParseDecl.cpp
> cfe/trunk/lib/Parse/Parser.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> cfe/trunk/test/SemaCXX/attr-deprecated-replacement-fixit.cpp
>
> Modified: cfe/trunk/include/clang/Basic/Attr.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=263687=263686=263687=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/Attr.td (original)
> +++ cfe/trunk/include/clang/Basic/Attr.td Wed Mar 16 22:09:55 2016
> @@ -467,7 +467,7 @@ def Availability : InheritableAttr {
>let Args = [IdentifierArgument<"platform">,
> VersionArgument<"introduced">,
>VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
>BoolArgument<"unavailable">, StringArgument<"message">,
> -  BoolArgument<"strict">];
> +  BoolArgument<"strict">, StringArgument<"replacement">];
>let AdditionalMembers =
>  [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
>  return llvm::StringSwitch(Platform)
>
> Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=263687=263686=263687=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
> +++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed Mar 16 22:09:55 2016
> @@ -661,6 +661,11 @@ 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 

Re: r263687 - Add an optional named argument (replacement = "xxx") to AvailabilityAttr.

2016-03-18 Thread Manman Ren via cfe-commits
Revert it in r263752.

Thanks,
Manman

On Thu, Mar 17, 2016 at 2:17 PM, Manman Ren  wrote:

> Sorry, working on it.
>
> Manman
>
> On Thu, Mar 17, 2016 at 12:45 PM, Kostya Serebryany 
> wrote:
>
>> This change is causing ubsan bot to complain
>> 
>> .
>> Please fix or revert.
>>
>> Most likely the guilty part is this:
>>
>> +*getReplacementSlot() = replacementExpr;
>>
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/Sema/AttributeList.h:276:5:
>>  runtime error: store to misaligned address 0x19b3784c for type 'const 
>> clang::Expr *', which requires 8 byte alignment
>> 0x19b3784c: note: pointer points here
>>   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  
>> 00 00 00 00 00 00 00 00  ^
>> #0 0x448295e in 
>> clang::AttributeList::AttributeList(clang::IdentifierInfo*, 
>> clang::SourceRange, clang::IdentifierInfo*, clang::SourceLocation, 
>> clang::IdentifierLoc*, clang::AvailabilityChange const&, 
>> clang::AvailabilityChange const&, clang::AvailabilityChange const&, 
>> clang::SourceLocation, clang::Expr const*, clang::AttributeList::Syntax, 
>> clang::SourceLocation, clang::Expr const*) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/Sema/AttributeList.h:276:27
>> #1 0x448269c in clang::AttributePool::create(clang::IdentifierInfo*, 
>> clang::SourceRange, clang::IdentifierInfo*, clang::SourceLocation, 
>> clang::IdentifierLoc*, clang::AvailabilityChange const&, 
>> clang::AvailabilityChange const&, clang::AvailabilityChange const&, 
>> clang::SourceLocation, clang::Expr const*, clang::AttributeList::Syntax, 
>> clang::SourceLocation, clang::Expr const*) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/Sema/AttributeList.h:662:29
>> #2 0x447c52d in clang::ParsedAttributes::addNew(clang::IdentifierInfo*, 
>> clang::SourceRange, clang::IdentifierInfo*, clang::SourceLocation, 
>> clang::IdentifierLoc*, clang::AvailabilityChange const&, 
>> clang::AvailabilityChange const&, clang::AvailabilityChange const&, 
>> clang::SourceLocation, clang::Expr const*, clang::AttributeList::Syntax, 
>> clang::SourceLocation, clang::Expr const*) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/Sema/AttributeList.h:798:7
>> #3 0x4465a73 in clang::Parser::Pa
>>
>>
>>
>>
>> On Wed, Mar 16, 2016 at 8:09 PM, Manman Ren via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: mren
>>> Date: Wed Mar 16 22:09:55 2016
>>> New Revision: 263687
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=263687=rev
>>> Log:
>>> Add an optional named argument (replacement = "xxx") to AvailabilityAttr.
>>>
>>> This commit adds a named argument to AvailabilityAttr, while r263652
>>> adds an
>>> optional string argument to __attribute__((deprecated)). This enables the
>>> compiler to provide Fix-Its for deprecated declarations.
>>>
>>> rdar://20588929
>>>
>>> Modified:
>>> cfe/trunk/include/clang/Basic/Attr.td
>>> cfe/trunk/include/clang/Basic/AttrDocs.td
>>> cfe/trunk/include/clang/Parse/Parser.h
>>> cfe/trunk/include/clang/Sema/AttributeList.h
>>> cfe/trunk/include/clang/Sema/Sema.h
>>> cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>>> cfe/trunk/lib/Parse/ParseDecl.cpp
>>> cfe/trunk/lib/Parse/Parser.cpp
>>> cfe/trunk/lib/Sema/SemaDecl.cpp
>>> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>>> cfe/trunk/test/SemaCXX/attr-deprecated-replacement-fixit.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Basic/Attr.td
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=263687=263686=263687=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Basic/Attr.td (original)
>>> +++ cfe/trunk/include/clang/Basic/Attr.td Wed Mar 16 22:09:55 2016
>>> @@ -467,7 +467,7 @@ def Availability : InheritableAttr {
>>>let Args = [IdentifierArgument<"platform">,
>>> VersionArgument<"introduced">,
>>>VersionArgument<"deprecated">,
>>> VersionArgument<"obsoleted">,
>>>BoolArgument<"unavailable">, StringArgument<"message">,
>>> -  BoolArgument<"strict">];
>>> +  BoolArgument<"strict">, StringArgument<"replacement">];
>>>let AdditionalMembers =
>>>  [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef
>>> Platform) {
>>>  return llvm::StringSwitch(Platform)
>>>
>>> Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=263687=263686=263687=diff
>>>
>>> ==
>>> ---