r314697 - Revert "Add /System/Library/PrivateFrameworks as a header search path."

2017-10-02 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Mon Oct  2 11:22:19 2017
New Revision: 314697

URL: http://llvm.org/viewvc/llvm-project?rev=314697=rev
Log:
Revert "Add /System/Library/PrivateFrameworks as a header search path."

This reverts commit f7a95215a435aa8d5f64f43a8bb23ba077270755.

Modified:
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp

Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=314697=314696=314697=diff
==
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Mon Oct  2 11:22:19 2017
@@ -484,7 +484,6 @@ void InitHeaderSearch::AddDefaultInclude
 if (triple.isOSDarwin()) {
   AddPath("/System/Library/Frameworks", System, true);
   AddPath("/Library/Frameworks", System, true);
-  AddPath("/System/Library/PrivateFrameworks", System, true);
 }
   }
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r313316 - [Module map] Introduce a private module re-export directive.

2017-09-18 Thread Douglas Gregor via cfe-commits

> On Sep 18, 2017, at 3:11 PM, Richard Smith <rich...@metafoo.co.uk> wrote:
> 
> On 18 September 2017 at 14:34, Douglas Gregor via cfe-commits 
> <cfe-commits@lists.llvm.org <mailto:cfe-commits@lists.llvm.org>> wrote:
> 
>> On Sep 18, 2017, at 1:45 PM, Galina Kistanova <gkistan...@gmail.com 
>> <mailto:gkistan...@gmail.com>> wrote:
>> 
>> Hello Douglas,
>> 
>> Your r313316 commit broke one of our builders on Thursday, Sep-14th.
>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/17506
>>  
>> <http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/17506>
>> 
>> Are you about to commit the fix, or shall I revert that commit to give you 
>> more time?
> 
> I’m unable to reproduce this issue, and it’s weirdly not hitting the other 
> bots.
> 
> Is anyone able to reproduce this? The stack trace is… insufficient… to figure 
> out what’s going on.
> 
> I think that bot might be the only one with a target whose default C++ 
> language mode is C++11.

Hmm. It’s not the C++ RUN lines that are failing, though; it’s the default 
(Objective-C) one.

- Doug

>  
>   - Doug
> 
>> 
>> Thanks
>> 
>> Galina
>> 
>> On Thu, Sep 14, 2017 at 4:38 PM, Douglas Gregor via cfe-commits 
>> <cfe-commits@lists.llvm.org <mailto:cfe-commits@lists.llvm.org>> wrote:
>> Author: dgregor
>> Date: Thu Sep 14 16:38:44 2017
>> New Revision: 313316
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=313316=rev 
>> <http://llvm.org/viewvc/llvm-project?rev=313316=rev>
>> Log:
>> [Module map] Introduce a private module re-export directive.
>> 
>> Introduce a new "export_as" directive for top-level modules, which
>> indicates that the current module is a "private" module whose symbols
>> will eventually be exported through the named "public" module. This is
>> in support of a common pattern in the Darwin ecosystem where a single
>> public framework is constructed of several private frameworks, with
>> (currently) header duplication and some support from the linker.
>> 
>> Addresses rdar://problem/34438420 <>.
>> 
>> Added:
>> cfe/trunk/test/Modules/Inputs/export_as_test.modulemap
>> cfe/trunk/test/Modules/export_as_test.c
>> Modified:
>> cfe/trunk/docs/Modules.rst
>> cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>> cfe/trunk/include/clang/Basic/Module.h
>> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
>> cfe/trunk/lib/Basic/Module.cpp
>> cfe/trunk/lib/Lex/ModuleMap.cpp
>> cfe/trunk/lib/Serialization/ASTReader.cpp
>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>> 
>> Modified: cfe/trunk/docs/Modules.rst
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=313316=313315=313316=diff
>>  
>> <http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=313316=313315=313316=diff>
>> ==
>> --- cfe/trunk/docs/Modules.rst (original)
>> +++ cfe/trunk/docs/Modules.rst Thu Sep 14 16:38:44 2017
>> @@ -323,11 +323,12 @@ Module map files use a simplified form o
>> 
>>  .. parsed-literal::
>> 
>> -  ``config_macros`` ``export`` ``private``
>> +  ``config_macros`` ``export_as``  ``private``
>>``conflict``  ``framework``  ``requires``
>>``exclude``   ``header`` ``textual``
>>``explicit``  ``link``   ``umbrella``
>>``extern````module`` ``use``
>> +  ``export``
>> 
>>  Module map file
>>  ---
>> @@ -387,6 +388,7 @@ Modules can have a number of different k
>>  *umbrella-dir-declaration*
>>  *submodule-declaration*
>>  *export-declaration*
>> +*export-as-declaration*
>>  *use-declaration*
>>  *link-declaration*
>>  *config-macros-declaration*
>> @@ -666,6 +668,31 @@ Note that, if ``Derived.h`` includes ``B
>>compatibility for programs that rely on transitive inclusion (i.e.,
>>all of them).
>> 
>> +Re-export Declaration
>> +~~
>> +An *export-as-declaration* specifies that the current module is a private
>> +module whose interface will be re-exported by the named public module.
>> +
>> +.. parsed-literal::
>> +
>> +  *export-as-declaration*:
>> +``export_as`` *identifier*
>> +
>> +The *export-as-declaration* names the

Re: r313316 - [Module map] Introduce a private module re-export directive.

2017-09-18 Thread Douglas Gregor via cfe-commits

> On Sep 18, 2017, at 1:45 PM, Galina Kistanova <gkistan...@gmail.com> wrote:
> 
> Hello Douglas,
> 
> Your r313316 commit broke one of our builders on Thursday, Sep-14th.
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/17506
>  
> <http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/17506>
> 
> Are you about to commit the fix, or shall I revert that commit to give you 
> more time?

I’m unable to reproduce this issue, and it’s weirdly not hitting the other bots.

Is anyone able to reproduce this? The stack trace is… insufficient… to figure 
out what’s going on.

- Doug

> 
> Thanks
> 
> Galina
> 
> On Thu, Sep 14, 2017 at 4:38 PM, Douglas Gregor via cfe-commits 
> <cfe-commits@lists.llvm.org <mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: dgregor
> Date: Thu Sep 14 16:38:44 2017
> New Revision: 313316
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=313316=rev 
> <http://llvm.org/viewvc/llvm-project?rev=313316=rev>
> Log:
> [Module map] Introduce a private module re-export directive.
> 
> Introduce a new "export_as" directive for top-level modules, which
> indicates that the current module is a "private" module whose symbols
> will eventually be exported through the named "public" module. This is
> in support of a common pattern in the Darwin ecosystem where a single
> public framework is constructed of several private frameworks, with
> (currently) header duplication and some support from the linker.
> 
> Addresses rdar://problem/34438420.
> 
> Added:
> cfe/trunk/test/Modules/Inputs/export_as_test.modulemap
> cfe/trunk/test/Modules/export_as_test.c
> Modified:
> cfe/trunk/docs/Modules.rst
> cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> cfe/trunk/include/clang/Basic/Module.h
> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> cfe/trunk/lib/Basic/Module.cpp
> cfe/trunk/lib/Lex/ModuleMap.cpp
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> 
> Modified: cfe/trunk/docs/Modules.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=313316=313315=313316=diff
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=313316=313315=313316=diff>
> ==
> --- cfe/trunk/docs/Modules.rst (original)
> +++ cfe/trunk/docs/Modules.rst Thu Sep 14 16:38:44 2017
> @@ -323,11 +323,12 @@ Module map files use a simplified form o
> 
>  .. parsed-literal::
> 
> -  ``config_macros`` ``export`` ``private``
> +  ``config_macros`` ``export_as``  ``private``
>``conflict``  ``framework``  ``requires``
>``exclude``   ``header`` ``textual``
>``explicit``  ``link``   ``umbrella``
>``extern````module`` ``use``
> +  ``export``
> 
>  Module map file
>  ---
> @@ -387,6 +388,7 @@ Modules can have a number of different k
>  *umbrella-dir-declaration*
>  *submodule-declaration*
>  *export-declaration*
> +*export-as-declaration*
>  *use-declaration*
>  *link-declaration*
>  *config-macros-declaration*
> @@ -666,6 +668,31 @@ Note that, if ``Derived.h`` includes ``B
>compatibility for programs that rely on transitive inclusion (i.e.,
>all of them).
> 
> +Re-export Declaration
> +~~
> +An *export-as-declaration* specifies that the current module is a private
> +module whose interface will be re-exported by the named public module.
> +
> +.. parsed-literal::
> +
> +  *export-as-declaration*:
> +``export_as`` *identifier*
> +
> +The *export-as-declaration* names the public module that the current
> +(private) module will be re-exported through. Only top-level modules
> +can be re-exported, and any given module may only be re-exported
> +through a single public module.
> +
> +**Example:** In the following example, the (private) module
> +``MyFrameworkCore`` will be re-exported via the public module
> +``MyFramework``:
> +
> +.. parsed-literal::
> +
> +  module MyFrameworkCore {
> +export_as MyFramework
> +  }
> +
>  Use declaration
>  ~~~
>  A *use-declaration* specifies another module that the current top-level 
> module
> 
> Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=313316=313315=313316=diff
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagn

Re: r313315 - Diagnostic specific failed condition in a static_assert.

2017-09-17 Thread Douglas Gregor via cfe-commits
Thank you!

Sent from my iPhone

> On Sep 17, 2017, at 1:58 PM, Eric Fiselier <e...@efcs.ca> wrote:
> 
> Fixed in r313499.
> 
> /Eric
> 
>> On Sun, Sep 17, 2017 at 2:04 PM, Eric Fiselier <e...@efcs.ca> wrote:
>> I'll correct them.
>> 
>> /Eric
>> 
>>> On Sat, Sep 16, 2017 at 6:28 PM, Richard Smith <rich...@metafoo.co.uk> 
>>> wrote:
>> 
>>> This is a bug in the libc++ tests. It's OK for them to check that the 
>>> static_assert message is produced, but not that they're prefixed with the 
>>> exact string "static_assert failed:".
>>> 
>>>> On 16 September 2017 at 05:54, NAKAMURA Takumi via cfe-commits 
>>>> <cfe-commits@lists.llvm.org> wrote:
>>>> This triggered failure in libcxx tests.
>>>> http://bb.pgr.jp/builders/bootstrap-clang-libcxx-lld-i686-linux/builds/97
>>>> 
>>>> 
>>>>> On Fri, Sep 15, 2017 at 8:40 AM Douglas Gregor via cfe-commits 
>>>>> <cfe-commits@lists.llvm.org> wrote:
>>>>> Author: dgregor
>>>>> Date: Thu Sep 14 16:38:42 2017
>>>>> New Revision: 313315
>>>>> 
>>>>> URL: http://llvm.org/viewvc/llvm-project?rev=313315=rev
>>>>> Log:
>>>>> Diagnostic specific failed condition in a static_assert.
>>>>> 
>>>>> When a static_assert fails, dig out a specific condition to diagnose,
>>>>> using the same logic that we use to find the enable_if condition to
>>>>> diagnose.
>>>>> 
>>>>> Modified:
>>>>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>>>> cfe/trunk/include/clang/Sema/Sema.h
>>>>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>>>>> cfe/trunk/lib/Sema/SemaTemplate.cpp
>>>>> cfe/trunk/test/SemaCXX/static-assert.cpp
>>>>> 
>>>>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>>>> URL: 
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=313315=313314=313315=diff
>>>>> ==
>>>>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>>>>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Sep 14 
>>>>> 16:38:42 2017
>>>>> @@ -1219,6 +1219,8 @@ def warn_messaging_unqualified_id : Warn
>>>>>  def err_static_assert_expression_is_not_constant : Error<
>>>>>"static_assert expression is not an integral constant expression">;
>>>>>  def err_static_assert_failed : Error<"static_assert failed%select{ 
>>>>> %1|}0">;
>>>>> +def err_static_assert_requirement_failed : Error<
>>>>> +  "static_assert failed due to requirement '%0'%select{ %2|}1">;
>>>>>  def ext_static_assert_no_message : ExtWarn<
>>>>>"static_assert with no message is a C++17 extension">, InGroup;
>>>>>  def warn_cxx14_compat_static_assert_no_message : Warning<
>>>>> 
>>>>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>>>>> URL: 
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=313315=313314=313315=diff
>>>>> ==
>>>>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>>>>> +++ cfe/trunk/include/clang/Sema/Sema.h Thu Sep 14 16:38:42 2017
>>>>> @@ -2783,6 +2783,14 @@ public:
>>>>>EnableIfAttr *CheckEnableIf(FunctionDecl *Function, ArrayRef 
>>>>> Args,
>>>>>bool MissingImplicitThis = false);
>>>>> 
>>>>> +  /// Find the failed Boolean condition within a given Boolean
>>>>> +  /// constant expression, and describe it with a string.
>>>>> +  ///
>>>>> +  /// \param AllowTopLevelCond Whether to allow the result to be the
>>>>> +  /// complete top-level condition.
>>>>> +  std::pair
>>>>> +  findFailedBooleanCondition(Expr *Cond, bool AllowTopLevelCond);
>>>>> +
>>>>>/// Emit diagnostics for the diagnose_if attributes on Function, 
>>>>> ignoring any
>>>>>/// non-ArgDependent DiagnoseIfAttrs.
>>>>>///
>&g

r313320 - Fix reStructuredText warning.

2017-09-14 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Thu Sep 14 16:58:18 2017
New Revision: 313320

URL: http://llvm.org/viewvc/llvm-project?rev=313320=rev
Log:
Fix reStructuredText warning.

Modified:
cfe/trunk/docs/Modules.rst

Modified: cfe/trunk/docs/Modules.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=313320=313319=313320=diff
==
--- cfe/trunk/docs/Modules.rst (original)
+++ cfe/trunk/docs/Modules.rst Thu Sep 14 16:58:18 2017
@@ -669,7 +669,7 @@ Note that, if ``Derived.h`` includes ``B
   all of them).
 
 Re-export Declaration
-~~
+~
 An *export-as-declaration* specifies that the current module will have
 its interface re-exported by the named module.
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r313318 - Minor cleanups to address feedback from Bruno. NFC

2017-09-14 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Thu Sep 14 16:40:51 2017
New Revision: 313318

URL: http://llvm.org/viewvc/llvm-project?rev=313318=rev
Log:
Minor cleanups to address feedback from Bruno. NFC

Modified:
cfe/trunk/docs/Modules.rst
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/docs/Modules.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=313318=313317=313318=diff
==
--- cfe/trunk/docs/Modules.rst (original)
+++ cfe/trunk/docs/Modules.rst Thu Sep 14 16:40:51 2017
@@ -670,22 +670,21 @@ Note that, if ``Derived.h`` includes ``B
 
 Re-export Declaration
 ~~
-An *export-as-declaration* specifies that the current module is a private
-module whose interface will be re-exported by the named public module.
+An *export-as-declaration* specifies that the current module will have
+its interface re-exported by the named module.
 
 .. parsed-literal::
 
   *export-as-declaration*:
 ``export_as`` *identifier*
 
-The *export-as-declaration* names the public module that the current
-(private) module will be re-exported through. Only top-level modules
+The *export-as-declaration* names the module that the current
+module will be re-exported through. Only top-level modules
 can be re-exported, and any given module may only be re-exported
-through a single public module.
+through a single module.
 
-**Example:** In the following example, the (private) module
-``MyFrameworkCore`` will be re-exported via the public module
-``MyFramework``:
+**Example:** In the following example, the module ``MyFrameworkCore``
+will be re-exported via the module ``MyFramework``:
 
 .. parsed-literal::
 

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=313318=313317=313318=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Thu Sep 14 16:40:51 2017
@@ -2797,7 +2797,6 @@ void ASTWriter::WriteSubmodules(Module *
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));// Macro name
   unsigned ExportAsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
 
-
   // Write the submodule metadata block.
   RecordData::value_type Record[] = {
   getNumberOfModules(WritingModule),


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r313315 - Diagnostic specific failed condition in a static_assert.

2017-09-14 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Thu Sep 14 16:38:42 2017
New Revision: 313315

URL: http://llvm.org/viewvc/llvm-project?rev=313315=rev
Log:
Diagnostic specific failed condition in a static_assert.

When a static_assert fails, dig out a specific condition to diagnose,
using the same logic that we use to find the enable_if condition to
diagnose.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaCXX/static-assert.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=313315=313314=313315=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Sep 14 16:38:42 
2017
@@ -1219,6 +1219,8 @@ def warn_messaging_unqualified_id : Warn
 def err_static_assert_expression_is_not_constant : Error<
   "static_assert expression is not an integral constant expression">;
 def err_static_assert_failed : Error<"static_assert failed%select{ %1|}0">;
+def err_static_assert_requirement_failed : Error<
+  "static_assert failed due to requirement '%0'%select{ %2|}1">;
 def ext_static_assert_no_message : ExtWarn<
   "static_assert with no message is a C++17 extension">, InGroup;
 def warn_cxx14_compat_static_assert_no_message : Warning<

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=313315=313314=313315=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Sep 14 16:38:42 2017
@@ -2783,6 +2783,14 @@ public:
   EnableIfAttr *CheckEnableIf(FunctionDecl *Function, ArrayRef Args,
   bool MissingImplicitThis = false);
 
+  /// Find the failed Boolean condition within a given Boolean
+  /// constant expression, and describe it with a string.
+  ///
+  /// \param AllowTopLevelCond Whether to allow the result to be the
+  /// complete top-level condition.
+  std::pair
+  findFailedBooleanCondition(Expr *Cond, bool AllowTopLevelCond);
+
   /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
   /// non-ArgDependent DiagnoseIfAttrs.
   ///

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=313315=313314=313315=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Sep 14 16:38:42 2017
@@ -13296,8 +13296,20 @@ Decl *Sema::BuildStaticAssertDeclaration
   llvm::raw_svector_ostream Msg(MsgBuffer);
   if (AssertMessage)
 AssertMessage->printPretty(Msg, nullptr, getPrintingPolicy());
-  Diag(StaticAssertLoc, diag::err_static_assert_failed)
-<< !AssertMessage << Msg.str() << AssertExpr->getSourceRange();
+
+  Expr *InnerCond = nullptr;
+  std::string InnerCondDescription;
+  std::tie(InnerCond, InnerCondDescription) =
+findFailedBooleanCondition(Converted.get(),
+   /*AllowTopLevelCond=*/false);
+  if (InnerCond) {
+Diag(StaticAssertLoc, diag::err_static_assert_requirement_failed)
+  << InnerCondDescription << !AssertMessage
+  << Msg.str() << InnerCond->getSourceRange();
+  } else {
+Diag(StaticAssertLoc, diag::err_static_assert_failed)
+  << !AssertMessage << Msg.str() << AssertExpr->getSourceRange();
+  }
   Failed = true;
 }
   }

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=313315=313314=313315=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Sep 14 16:38:42 2017
@@ -2863,11 +2863,9 @@ static Expr *lookThroughRangesV3Conditio
   return Cond;
 }
 
-/// Find the failed subexpression within enable_if, and describe it
-/// with a string.
-static std::pair
-findFailedEnableIfCondition(Sema , Expr *Cond) {
-  Cond = lookThroughRangesV3Condition(S.PP, Cond);
+std::pair
+Sema::findFailedBooleanCondition(Expr *Cond, bool AllowTopLevelCond) {
+  Cond = lookThroughRangesV3Condition(PP, Cond);
 
   // Separate out all of the terms in a conjunction.
   SmallVector Terms;
@@ -2876,27 +2874,37 @@ findFailedEnableIfCondition(Sema , Exp
   // Determine which term failed.
   Expr *FailedCond = nullptr;
   for (Expr *Term : Terms) {
+Expr *TermAsWritten = Term->IgnoreParenImpCasts();
+
+// Literals are uninteresting.
+if (isa(TermAsWritten) ||
+  

r313317 - Add /System/Library/PrivateFrameworks as a header search path.

2017-09-14 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Thu Sep 14 16:38:44 2017
New Revision: 313317

URL: http://llvm.org/viewvc/llvm-project?rev=313317=rev
Log:
Add /System/Library/PrivateFrameworks as a header search path.

Addresses rdar://problem/34438708.

Modified:
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp

Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=313317=313316=313317=diff
==
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Thu Sep 14 16:38:44 2017
@@ -484,6 +484,7 @@ void InitHeaderSearch::AddDefaultInclude
 if (triple.isOSDarwin()) {
   AddPath("/System/Library/Frameworks", System, true);
   AddPath("/Library/Frameworks", System, true);
+  AddPath("/System/Library/PrivateFrameworks", System, true);
 }
   }
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r313316 - [Module map] Introduce a private module re-export directive.

2017-09-14 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Thu Sep 14 16:38:44 2017
New Revision: 313316

URL: http://llvm.org/viewvc/llvm-project?rev=313316=rev
Log:
[Module map] Introduce a private module re-export directive.

Introduce a new "export_as" directive for top-level modules, which
indicates that the current module is a "private" module whose symbols
will eventually be exported through the named "public" module. This is
in support of a common pattern in the Darwin ecosystem where a single
public framework is constructed of several private frameworks, with
(currently) header duplication and some support from the linker.

Addresses rdar://problem/34438420.

Added:
cfe/trunk/test/Modules/Inputs/export_as_test.modulemap
cfe/trunk/test/Modules/export_as_test.c
Modified:
cfe/trunk/docs/Modules.rst
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Basic/Module.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/Basic/Module.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/docs/Modules.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=313316=313315=313316=diff
==
--- cfe/trunk/docs/Modules.rst (original)
+++ cfe/trunk/docs/Modules.rst Thu Sep 14 16:38:44 2017
@@ -323,11 +323,12 @@ Module map files use a simplified form o
 
 .. parsed-literal::
 
-  ``config_macros`` ``export`` ``private``
+  ``config_macros`` ``export_as``  ``private``
   ``conflict``  ``framework``  ``requires``
   ``exclude``   ``header`` ``textual``
   ``explicit``  ``link``   ``umbrella``
   ``extern````module`` ``use``
+  ``export``
 
 Module map file
 ---
@@ -387,6 +388,7 @@ Modules can have a number of different k
 *umbrella-dir-declaration*
 *submodule-declaration*
 *export-declaration*
+*export-as-declaration*
 *use-declaration*
 *link-declaration*
 *config-macros-declaration*
@@ -666,6 +668,31 @@ Note that, if ``Derived.h`` includes ``B
   compatibility for programs that rely on transitive inclusion (i.e.,
   all of them).
 
+Re-export Declaration
+~~
+An *export-as-declaration* specifies that the current module is a private
+module whose interface will be re-exported by the named public module.
+
+.. parsed-literal::
+
+  *export-as-declaration*:
+``export_as`` *identifier*
+
+The *export-as-declaration* names the public module that the current
+(private) module will be re-exported through. Only top-level modules
+can be re-exported, and any given module may only be re-exported
+through a single public module.
+
+**Example:** In the following example, the (private) module
+``MyFrameworkCore`` will be re-exported via the public module
+``MyFramework``:
+
+.. parsed-literal::
+
+  module MyFrameworkCore {
+export_as MyFramework
+  }
+
 Use declaration
 ~~~
 A *use-declaration* specifies another module that the current top-level module

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=313316=313315=313316=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Thu Sep 14 16:38:44 2017
@@ -674,6 +674,13 @@ def err_mmap_invalid_header_attribute_va
   "expected integer literal as value for header attribute '%0'">;
 def err_mmap_expected_header_attribute : Error<
   "expected a header attribute name ('size' or 'mtime')">;
+def err_mmap_conflicting_export_as : Error<
+  "conflicting re-export of module '%0' as '%1' or '%2'">;
+def warn_mmap_redundant_export_as : Warning<
+  "module '%0' already re-exported as '%1'">,
+  InGroup;
+def err_mmap_submodule_export_as : Error<
+  "only top-level modules can be re-exported as public">;
 
 def warn_auto_module_import : Warning<
   "treating #%select{include|import|include_next|__include_macros}0 as an "

Modified: cfe/trunk/include/clang/Basic/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=313316=313315=313316=diff
==
--- cfe/trunk/include/clang/Basic/Module.h (original)
+++ cfe/trunk/include/clang/Basic/Module.h Thu Sep 14 16:38:44 2017
@@ -99,6 +99,10 @@ public:
 
   /// \brief The name of the umbrella entry, as written in the module map.
   std::string UmbrellaAsWritten;
+
+  /// \brief The module through which entities defined in this module will
+  /// eventually be exposed, for use in "private" modules.
+  std::string ExportAsModule;
   
 private:
   /// \brief The submodules of this module, indexed by name.

Modified: 

r307202 - Fix test case in pre-C++11 mode; address Aaron Ballman's code review.

2017-07-05 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Wed Jul  5 14:12:37 2017
New Revision: 307202

URL: http://llvm.org/viewvc/llvm-project?rev=307202=rev
Log:
Fix test case in pre-C++11 mode; address Aaron Ballman's code review.

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaTemplate/overload-candidates.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=307202=307201=307202=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Jul  5 14:12:37 2017
@@ -2843,7 +2843,7 @@ static Expr *lookThroughRangesV3Conditio
 
   // With an inner '==' that has a literal on the right-hand side.
   Expr *LHS = BinOp->getLHS();
-  auto InnerBinOp = dyn_cast(LHS->IgnoreParenImpCasts());
+  auto *InnerBinOp = dyn_cast(LHS->IgnoreParenImpCasts());
   if (!InnerBinOp) return Cond;
 
   if (InnerBinOp->getOpcode() != BO_EQ ||
@@ -2853,7 +2853,7 @@ static Expr *lookThroughRangesV3Conditio
   // If the inner binary operation came from a macro expansion named
   // CONCEPT_REQUIRES or CONCEPT_REQUIRES_, return the right-hand side
   // of the '||', which is the real, user-provided condition.
-  auto Loc = InnerBinOp->getExprLoc();
+  SourceLocation Loc = InnerBinOp->getExprLoc();
   if (!Loc.isMacroID()) return Cond;
 
   StringRef MacroName = PP.getImmediateMacroName(Loc);

Modified: cfe/trunk/test/SemaTemplate/overload-candidates.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/overload-candidates.cpp?rev=307202=307201=307202=diff
==
--- cfe/trunk/test/SemaTemplate/overload-candidates.cpp (original)
+++ cfe/trunk/test/SemaTemplate/overload-candidates.cpp Wed Jul  5 14:12:37 2017
@@ -157,7 +157,7 @@ namespace PR15673 {
 
 #if __cplusplus <= 199711L
   // expected-warning@+4 {{default template arguments for a function template 
are a C++11 extension}}
-  // expected-warning@+4 {{default template arguments for a function template 
are a C++11 extension}}
+  // expected-warning@+3 {{default template arguments for a function template 
are a C++11 extension}}
 #endif
   template::value && 
some_trait::value)>


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r307197 - Cope with Range-v3's CONCEPT_REQUIRES idiom

2017-07-05 Thread Douglas Gregor via cfe-commits

> On Jul 5, 2017, at 1:33 PM, Aaron Ballman <aa...@aaronballman.com> wrote:
> 
> On Wed, Jul 5, 2017 at 4:20 PM, Douglas Gregor via cfe-commits
> <cfe-commits@lists.llvm.org <mailto:cfe-commits@lists.llvm.org>> wrote:
>> Author: dgregor
>> Date: Wed Jul  5 13:20:15 2017
>> New Revision: 307197
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=307197=rev
>> Log:
>> Cope with Range-v3's CONCEPT_REQUIRES idiom
>> 
>> Modified:
>>cfe/trunk/lib/Sema/SemaTemplate.cpp
>>cfe/trunk/test/SemaTemplate/overload-candidates.cpp
>> 
>> Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=307197=307196=307197=diff
>> ==
>> --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Jul  5 13:20:15 2017
>> @@ -2831,10 +2831,44 @@ static void collectConjunctionTerms(Expr
>>   Terms.push_back(Clause);
>> }
>> 
>> +// The ranges-v3 library uses an odd pattern of a top-level "||" with
>> +// a left-hand side that is value-dependent but never true. Identify
>> +// the idiom and ignore that term.
>> +static Expr *lookThroughRangesV3Condition(Preprocessor , Expr *Cond) {
>> +  // Top-level '||'.
>> +  auto *BinOp = dyn_cast(Cond->IgnoreParenImpCasts());
>> +  if (!BinOp) return Cond;
>> +
>> +  if (BinOp->getOpcode() != BO_LOr) return Cond;
>> +
>> +  // With an inner '==' that has a literal on the right-hand side.
>> +  Expr *LHS = BinOp->getLHS();
>> +  auto InnerBinOp = dyn_cast(LHS->IgnoreParenImpCasts());
> 
> auto * please (or better yet, const auto * here and above).

Sure, commit incoming.

> 
>> +  if (!InnerBinOp) return Cond;
>> +
>> +  if (InnerBinOp->getOpcode() != BO_EQ ||
>> +  !isa(InnerBinOp->getRHS()))
>> +return Cond;
>> +
>> +  // If the inner binary operation came from a macro expansion named
>> +  // CONCEPT_REQUIRES or CONCEPT_REQUIRES_, return the right-hand side
>> +  // of the '||', which is the real, user-provided condition.
>> +  auto Loc = InnerBinOp->getExprLoc();
> 
> Please do not use auto here.

I’m fine with spelling it out, although I don’t know what criteria you’re 
applying here. Presumably it’s okay to use “auto” when the initializer is some 
form of cast to that type, but you prefer not to use “auto” elsewhere, despite 
the “Loc” in the variable name and in the initializer?

> It's unfortunate that we have this special case instead of a more
> general mechanism. While I love Ranges v3, I'm not keen on a compiler
> hack just for it. These "tricks" have a habit of leaking out into
> other user code, which will behave differently than what happens with
> Ranges.

It’s possible that we can do something more general here by converting the 
expression to disjunctive normal form and identifying when some of the 
top-level terms will never succeed. 

- Doug

> ~Aaron
> 
>> +  if (!Loc.isMacroID()) return Cond;
>> +
>> +  StringRef MacroName = PP.getImmediateMacroName(Loc);
>> +  if (MacroName == "CONCEPT_REQUIRES" || MacroName == "CONCEPT_REQUIRES_")
>> +return BinOp->getRHS();
>> +
>> +  return Cond;
>> +}
>> +
>> /// Find the failed subexpression within enable_if, and describe it
>> /// with a string.
>> static std::pair
>> findFailedEnableIfCondition(Sema , Expr *Cond) {
>> +  Cond = lookThroughRangesV3Condition(S.PP, Cond);
>> +
>>   // Separate out all of the terms in a conjunction.
>>   SmallVector Terms;
>>   collectConjunctionTerms(Cond, Terms);
>> 
>> Modified: cfe/trunk/test/SemaTemplate/overload-candidates.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/overload-candidates.cpp?rev=307197=307196=307197=diff
>> ==
>> --- cfe/trunk/test/SemaTemplate/overload-candidates.cpp (original)
>> +++ cfe/trunk/test/SemaTemplate/overload-candidates.cpp Wed Jul  5 13:20:15 
>> 2017
>> @@ -137,4 +137,30 @@ namespace PR15673 {
>> #endif
>>   void wibble() {}
>>   void wobble() { wibble(); } // expected-error {{no matching function 
>> for call to 'wibble'}}
>> +
>> +  template
>> +  struct some_passing_trait : std::true_type {};
>> +
>> +#if __cplusplus <= 199711L
>> +  // expected-warning@+4 {{default template arguments for a function 
>> 

r307197 - Cope with Range-v3's CONCEPT_REQUIRES idiom

2017-07-05 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Wed Jul  5 13:20:15 2017
New Revision: 307197

URL: http://llvm.org/viewvc/llvm-project?rev=307197=rev
Log:
Cope with Range-v3's CONCEPT_REQUIRES idiom

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaTemplate/overload-candidates.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=307197=307196=307197=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Jul  5 13:20:15 2017
@@ -2831,10 +2831,44 @@ static void collectConjunctionTerms(Expr
   Terms.push_back(Clause);
 }
 
+// The ranges-v3 library uses an odd pattern of a top-level "||" with
+// a left-hand side that is value-dependent but never true. Identify
+// the idiom and ignore that term.
+static Expr *lookThroughRangesV3Condition(Preprocessor , Expr *Cond) {
+  // Top-level '||'.
+  auto *BinOp = dyn_cast(Cond->IgnoreParenImpCasts());
+  if (!BinOp) return Cond;
+
+  if (BinOp->getOpcode() != BO_LOr) return Cond;
+
+  // With an inner '==' that has a literal on the right-hand side.
+  Expr *LHS = BinOp->getLHS();
+  auto InnerBinOp = dyn_cast(LHS->IgnoreParenImpCasts());
+  if (!InnerBinOp) return Cond;
+
+  if (InnerBinOp->getOpcode() != BO_EQ ||
+  !isa(InnerBinOp->getRHS()))
+return Cond;
+
+  // If the inner binary operation came from a macro expansion named
+  // CONCEPT_REQUIRES or CONCEPT_REQUIRES_, return the right-hand side
+  // of the '||', which is the real, user-provided condition.
+  auto Loc = InnerBinOp->getExprLoc();
+  if (!Loc.isMacroID()) return Cond;
+
+  StringRef MacroName = PP.getImmediateMacroName(Loc);
+  if (MacroName == "CONCEPT_REQUIRES" || MacroName == "CONCEPT_REQUIRES_")
+return BinOp->getRHS();
+
+  return Cond;
+}
+
 /// Find the failed subexpression within enable_if, and describe it
 /// with a string.
 static std::pair
 findFailedEnableIfCondition(Sema , Expr *Cond) {
+  Cond = lookThroughRangesV3Condition(S.PP, Cond);
+
   // Separate out all of the terms in a conjunction.
   SmallVector Terms;
   collectConjunctionTerms(Cond, Terms);

Modified: cfe/trunk/test/SemaTemplate/overload-candidates.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/overload-candidates.cpp?rev=307197=307196=307197=diff
==
--- cfe/trunk/test/SemaTemplate/overload-candidates.cpp (original)
+++ cfe/trunk/test/SemaTemplate/overload-candidates.cpp Wed Jul  5 13:20:15 2017
@@ -137,4 +137,30 @@ namespace PR15673 {
 #endif
   void wibble() {}
   void wobble() { wibble(); } // expected-error {{no matching function 
for call to 'wibble'}}
+
+  template
+  struct some_passing_trait : std::true_type {};
+
+#if __cplusplus <= 199711L
+  // expected-warning@+4 {{default template arguments for a function template 
are a C++11 extension}}
+  // expected-warning@+4 {{default template arguments for a function template 
are a C++11 extension}}
+#endif
+  template::value && 
some_trait::value), int>::type = 0>
+  void almost_rangesv3(); // expected-note{{candidate template ignored: 
requirement '42 == 43 || (some_passing_trait::value && 
some_trait::value)' was not satisfied}}
+  void test_almost_rangesv3() { almost_rangesv3(); } // 
expected-error{{no matching function for call to 'almost_rangesv3'}}
+
+  #define CONCEPT_REQUIRES_(...)\
+int x = 42, \
+typename std::enable_if<(x == 43) || (__VA_ARGS__)>::type = 0
+
+#if __cplusplus <= 199711L
+  // expected-warning@+4 {{default template arguments for a function template 
are a C++11 extension}}
+  // expected-warning@+4 {{default template arguments for a function template 
are a C++11 extension}}
+#endif
+  template::value && 
some_trait::value)>
+  void rangesv3(); // expected-note{{candidate template ignored: requirement 
'some_trait::value' was not satisfied [with T = int, x = 42]}}
+  void test_rangesv3() { rangesv3(); } // expected-error{{no matching 
function for call to 'rangesv3'}}
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r307196 - Customize the SFINAE diagnostics for enable_if to provide the failed condition.

2017-07-05 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Wed Jul  5 13:20:14 2017
New Revision: 307196

URL: http://llvm.org/viewvc/llvm-project?rev=307196=rev
Log:
Customize the SFINAE diagnostics for enable_if to provide the failed condition.

When enable_if disables a particular overload resolution candidate,
rummage through the enable_if condition to find the specific condition
that caused the failure. For example, if we have something like:

template<
  typename Iter,
  typename = std::enable_if_t>>
void mysort(Iter first, Iter last) {}

and we call "mysort" with "std::list" iterators, we'll get a
diagnostic saying that the "Random_access_iterator" requirement
failed. If we call "mysort" with
"std::vector", we'll get a diagnostic saying
that the "Comparable<...>" requirement failed.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/PartialDiagnostic.h
cfe/trunk/include/clang/Sema/TemplateDeduction.h
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaTemplate/constexpr-instantiate.cpp
cfe/trunk/test/SemaTemplate/overload-candidates.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=307196=307195=307196=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jul  5 13:20:14 
2017
@@ -3518,6 +3518,8 @@ def note_ovl_candidate_substitution_fail
 "candidate template ignored: substitution failure%0%1">;
 def note_ovl_candidate_disabled_by_enable_if : Note<
 "candidate template ignored: disabled by %0%1">;
+def note_ovl_candidate_disabled_by_requirement : Note<
+"candidate template ignored: requirement '%0' was not satisfied%1">;
 def note_ovl_candidate_has_pass_object_size_params: Note<
 "candidate address cannot be taken because parameter %0 has "
 "pass_object_size attribute">;
@@ -4431,6 +4433,9 @@ def err_typename_nested_not_found : Erro
 def err_typename_nested_not_found_enable_if : Error<
   "no type named 'type' in %0; 'enable_if' cannot be used to disable "
   "this declaration">;
+def err_typename_nested_not_found_requirement : Error<
+  "failed requirement '%0'; 'enable_if' cannot be used to disable this "
+  "declaration">;
 def err_typename_nested_not_type : Error<
 "typename specifier refers to non-type member %0 in %1">;
 def note_typename_refers_here : Note<

Modified: cfe/trunk/include/clang/Basic/PartialDiagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/PartialDiagnostic.h?rev=307196=307195=307196=diff
==
--- cfe/trunk/include/clang/Basic/PartialDiagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/PartialDiagnostic.h Wed Jul  5 13:20:14 2017
@@ -329,6 +329,15 @@ public:
 
   bool hasStorage() const { return DiagStorage != nullptr; }
 
+  /// Retrieve the string argument at the given index.
+  StringRef getStringArg(unsigned I) {
+assert(DiagStorage && "No diagnostic storage?");
+assert(I < DiagStorage->NumDiagArgs && "Not enough diagnostic args");
+assert(DiagStorage->DiagArgumentsKind[I]
+ == DiagnosticsEngine::ak_std_string && "Not a string arg");
+return DiagStorage->DiagArgumentsStr[I];
+  }
+
   friend const PartialDiagnostic <<(const PartialDiagnostic ,
  unsigned I) {
 PD.AddTaggedVal(I, DiagnosticsEngine::ak_uint);

Modified: cfe/trunk/include/clang/Sema/TemplateDeduction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/TemplateDeduction.h?rev=307196=307195=307196=diff
==
--- cfe/trunk/include/clang/Sema/TemplateDeduction.h (original)
+++ cfe/trunk/include/clang/Sema/TemplateDeduction.h Wed Jul  5 13:20:14 2017
@@ -88,6 +88,12 @@ public:
 HasSFINAEDiagnostic = false;
   }
 
+  /// Peek at the SFINAE diagnostic.
+  const PartialDiagnosticAt () const {
+assert(HasSFINAEDiagnostic);
+return SuppressedDiagnostics.front();
+  }
+
   /// \brief Provide a new template argument list that contains the
   /// results of template argument deduction.
   void reset(TemplateArgumentList *NewDeduced) {

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=307196=307195=307196=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Jul  5 13:20:14 2017
@@ -9830,6 +9830,15 @@ static void DiagnoseBadDeduction(Sema 
   return;
 }

r265201 - [Objective-C] Introduce objc_runtime_visible attribute.

2016-04-01 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Fri Apr  1 18:23:52 2016
New Revision: 265201

URL: http://llvm.org/viewvc/llvm-project?rev=265201=rev
Log:
[Objective-C] Introduce objc_runtime_visible attribute.

The objc_runtime_visible attribute deals with an odd corner case where
a particular Objective-C class is known to the Objective-C runtime
(and, therefore, accessible by name) but its symbol has been hidden
for some reason. For such classes, teach CodeGen to use
objc_lookUpClass to retrieve the Class object, rather than referencing
the class symbol directly.

Classes annotated with objc_runtime_visible have two major limitations
that fall out from places where Objective-C metadata needs to refer to
the class (or metaclass) symbol directly:

* One cannot implement a subclass of an objc_runtime_visible class.
* One cannot implement a category on an objc_runtime_visible class.

Implements rdar://problem/25494092.

Added:
cfe/trunk/test/CodeGenObjC/attr-objc-runtime-visible.m
cfe/trunk/test/SemaObjC/attr-objc-runtime-visible.m
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=265201=265200=265201=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Fri Apr  1 18:23:52 2016
@@ -1241,6 +1241,12 @@ def ObjCRuntimeName : Attr {
   let Documentation = [ObjCRuntimeNameDocs];
 }
 
+def ObjCRuntimeVisible : Attr {
+  let Spellings = [GNU<"objc_runtime_visible">];
+  let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
+  let Documentation = [ObjCRuntimeVisibleDocs];
+}
+
 def ObjCBoxable : Attr {
   let Spellings = [GNU<"objc_boxable">];
   let Subjects = SubjectList<[Record], ErrorDiag, "ExpectedStructOrUnion">;

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=265201=265200=265201=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Fri Apr  1 18:23:52 2016
@@ -612,6 +612,13 @@ can only be placed before an @protocol o
 }];
 }
 
+def ObjCRuntimeVisibleDocs : Documentation {
+let Category = DocCatFunction;
+let Content = [{
+This attribute specifies that the Objective-C class to which it applies is 
visible to the Objective-C runtime but not to the linker. Classes annotated 
with this attribute cannot be subclassed and cannot have categories defined for 
them.
+}];
+}
+
 def ObjCBoxableDocs : Documentation {
 let Category = DocCatFunction;
 let Content = [{

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=265201=265200=265201=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Apr  1 18:23:52 
2016
@@ -715,6 +715,12 @@ def err_objc_root_class_subclass : Error
 def warn_objc_root_class_missing : Warning<
   "class %0 defined without specifying a base class">,
   InGroup;
+def err_objc_runtime_visible_category : Error<
+  "cannot implement a category for class %0 that is only visible via the "
+  "Objective-C runtime">;
+def err_objc_runtime_visible_subclass : Error<
+  "cannot implement subclass %0 of a superclass %1 that is only visible via 
the "
+  "Objective-C runtime">;
 def note_objc_needs_superclass : Note<
   "add a super class to fix this problem">;
 def warn_dup_category_def : Warning<

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=265201=265200=265201=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Fri Apr  1 18:23:52 2016
@@ -349,6 +349,20 @@ public:
 return CGM.CreateRuntimeFunction(FTy, "objc_enumerationMutation");
   }
 
+  llvm::Constant *getLookUpClassFn() {
+CodeGen::CodeGenTypes  = CGM.getTypes();
+ASTContext  = CGM.getContext();
+// Class objc_lookUpClass (const char *)
+SmallVector Params;
+Params.push_back(
+  Ctx.getCanonicalType(Ctx.getPointerType(Ctx.CharTy.withConst(;
+llvm::FunctionType *FTy =
+Types.GetFunctionType(Types.arrangeBuiltinFunctionDeclaration(
+Ctx.getCanonicalType(Ctx.getObjCClassType()),
+ 

Re: r259734 - Fix predefine for __NSConstantString struct type

2016-02-03 Thread Douglas Gregor via cfe-commits

> On Feb 3, 2016, at 4:55 PM, Ben Langmuir via cfe-commits 
>  wrote:
> 
> Author: benlangmuir
> Date: Wed Feb  3 18:55:24 2016
> New Revision: 259734
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=259734=rev
> Log:
> Fix predefine for __NSConstantString struct type
> 
> Per review feedback the name was wrong and it can be used outside
> Objective-C.
> 
> Unfortunately, making the internal struct visible broke some ASTMatchers
> tests that assumed that the first record decl would be from user code,
> rather than a builtin type.  I'm worried that this will also affect
> users' code.  So this patch adds a typedef to wrap the internal struct
> and only makes the typedef visible to namelookup.  This is sufficient to
> allow the ASTReader to merge the decls we need without making the struct
> itself visible.

Looks great, thanks Ben!

- Doug

> rdar://problem/24425801
> 
> Modified:
>cfe/trunk/include/clang/AST/ASTContext.h
>cfe/trunk/include/clang/Serialization/ASTBitCodes.h
>cfe/trunk/lib/AST/ASTContext.cpp
>cfe/trunk/lib/Sema/Sema.cpp
>cfe/trunk/lib/Serialization/ASTReader.cpp
>cfe/trunk/lib/Serialization/ASTWriter.cpp
>cfe/trunk/test/CodeGenObjC/2010-02-01-utf16-with-null.m
>cfe/trunk/test/CodeGenObjC/arc-no-arc-exceptions.m
>cfe/trunk/test/CodeGenObjC/tentative-cfconstantstring.m
>cfe/trunk/test/Modules/Inputs/builtin.h
>cfe/trunk/test/Modules/builtins.m
> 
> Modified: cfe/trunk/include/clang/AST/ASTContext.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=259734=259733=259734=diff
> ==
> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
> +++ cfe/trunk/include/clang/AST/ASTContext.h Wed Feb  3 18:55:24 2016
> @@ -253,8 +253,9 @@ class ASTContext : public RefCountedBase
>   mutable IdentifierInfo *MakeIntegerSeqName = nullptr;
> 
>   QualType ObjCConstantStringType;
> -  mutable RecordDecl *CFConstantStringTypeDecl;
> -  
> +  mutable RecordDecl *CFConstantStringTagDecl;
> +  mutable TypedefDecl *CFConstantStringTypeDecl;
> +
>   mutable QualType ObjCSuperType;
> 
>   QualType ObjCNSStringType;
> @@ -1381,11 +1382,12 @@ public:
>   /// if it hasn't yet been built.
>   QualType getRawCFConstantStringType() const {
> if (CFConstantStringTypeDecl)
> -  return getTagDeclType(CFConstantStringTypeDecl);
> +  return getTypedefType(CFConstantStringTypeDecl);
> return QualType();
>   }
>   void setCFConstantStringType(QualType T);
> -  TagDecl *getCFConstantStringDecl() const;
> +  TypedefDecl *getCFConstantStringDecl() const;
> +  RecordDecl *getCFConstantStringTagDecl() const;
> 
>   // This setter/getter represents the ObjC type for an NSConstantString.
>   void setObjCConstantStringInterface(ObjCInterfaceDecl *Decl);
> 
> Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=259734=259733=259734=diff
> ==
> --- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
> +++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Wed Feb  3 18:55:24 
> 2016
> @@ -988,15 +988,18 @@ namespace clang {
>   /// \brief The internal '__make_integer_seq' template.
>   PREDEF_DECL_MAKE_INTEGER_SEQ_ID = 13,
> 
> -  /// \brief The internal '__NSConstantString' type.
> +  /// \brief The internal '__NSConstantString' typedef.
>   PREDEF_DECL_CF_CONSTANT_STRING_ID = 14,
> +
> +  /// \brief The internal '__NSConstantString' tag type.
> +  PREDEF_DECL_CF_CONSTANT_STRING_TAG_ID = 15,
> };
> 
> /// \brief The number of declaration IDs that are predefined.
> ///
> /// For more information about predefined declarations, see the
> /// \c PredefinedDeclIDs type and the PREDEF_DECL_*_ID constants.
> -const unsigned int NUM_PREDEF_DECL_IDS = 15;
> +const unsigned int NUM_PREDEF_DECL_IDS = 16;
> 
> /// \brief Record code for a list of local redeclarations of a 
> declaration.
> const unsigned int LOCAL_REDECLARATIONS = 50;
> 
> Modified: cfe/trunk/lib/AST/ASTContext.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=259734=259733=259734=diff
> ==
> --- cfe/trunk/lib/AST/ASTContext.cpp (original)
> +++ cfe/trunk/lib/AST/ASTContext.cpp Wed Feb  3 18:55:24 2016
> @@ -738,12 +738,13 @@ ASTContext::ASTContext(LangOptions 
>   BuiltinVaListDecl(nullptr), BuiltinMSVaListDecl(nullptr),
>   ObjCIdDecl(nullptr), ObjCSelDecl(nullptr), ObjCClassDecl(nullptr),
>   ObjCProtocolClassDecl(nullptr), BOOLDecl(nullptr),
> -  CFConstantStringTypeDecl(nullptr), ObjCInstanceTypeDecl(nullptr),
> -  FILEDecl(nullptr), jmp_bufDecl(nullptr), 

Re: r259624 - Make CF constant string decl visible to name lookup to fix module errors

2016-02-03 Thread Douglas Gregor via cfe-commits

> On Feb 2, 2016, at 7:26 PM, Ben Langmuir via cfe-commits 
>  wrote:
> 
> Author: benlangmuir
> Date: Tue Feb  2 21:26:19 2016
> New Revision: 259624
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=259624=rev
> Log:
> Make CF constant string decl visible to name lookup to fix module errors
> 
> The return type of the __builtin___*StringMakeConstantString functions
> is a pointer to a struct, so we need that struct to be visible to name
> lookup so that we will correctly merge multiple declarations of that
> type if they come from different modules.
> 
> Incidentally, to make this visible to name lookup we need to rename the
> type to __NSConstantString, since the real NSConstantString is an
> Objective-C interface type.  This shouldn't affect anyone outside the
> compiler since users of the constant string builtins cast the result
> immediately to CFStringRef.
> 
> Since this struct type is otherwise implicitly created by the AST
> context and cannot access namelookup, we make this a predefined type
> and initialize it in Sema.
> 
> Note: this issue of builtins that refer to types not visible to name
> lookup technically also affects other builtins (e.g. objc_msgSendSuper),
> but in all other cases the builtin is a library builtin and the issue
> goes away if you include the library that defines the types it uses,
> unlike for these constant string builtins.
> 
> rdar://problem/24425801

Two comments below…

> [snip]
> 
> Modified: cfe/trunk/lib/Sema/Sema.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=259624=259623=259624=diff
> ==
> --- cfe/trunk/lib/Sema/Sema.cpp (original)
> +++ cfe/trunk/lib/Sema/Sema.cpp Tue Feb  2 21:26:19 2016
> @@ -189,6 +189,10 @@ void Sema::Initialize() {
> DeclarationName Protocol = ("Protocol");
> if (IdResolver.begin(Protocol) == IdResolver.end())
>   PushOnScopeChains(Context.getObjCProtocolDecl(), TUScope);
> +
> +DeclarationName ConstantString = ("NSConstantString");
> +if (IdResolver.begin(ConstantString) == IdResolver.end())
> +  PushOnScopeChains(Context.getCFConstantStringDecl(), TUScope);

Shouldn’t this be looking for __NSConstantString?

Also, isn’t CFSTR available even in C? This code path is Objective-C-only...

- Doug


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r259681 - [Sema debugger support] Require non-void types to be complete in unknown-anytype casts.

2016-02-03 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Wed Feb  3 13:13:08 2016
New Revision: 259681

URL: http://llvm.org/viewvc/llvm-project?rev=259681=rev
Log:
[Sema debugger support] Require non-void types to be complete in 
unknown-anytype casts.

When performing a cast from an __unknown_anytype function call to a
non-void type, we need to make sure that type is complete. Fixes
rdar://problem/23959960.

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/unknown-anytype.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=259681=259680=259681=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Feb  3 13:13:08 2016
@@ -14478,6 +14478,12 @@ ExprResult RebuildUnknownAnyExpr::resolv
 ExprResult Sema::checkUnknownAnyCast(SourceRange TypeRange, QualType CastType,
  Expr *CastExpr, CastKind ,
  ExprValueKind , CXXCastPath ) {
+  // The type we're casting to must be either void or complete.
+  if (!CastType->isVoidType() &&
+  RequireCompleteType(TypeRange.getBegin(), CastType,
+  diag::err_typecheck_cast_to_incomplete))
+return ExprError();
+
   // Rewrite the casted expression from scratch.
   ExprResult result = RebuildUnknownAnyExpr(*this, CastType).Visit(CastExpr);
   if (!result.isUsable()) return ExprError();

Modified: cfe/trunk/test/SemaCXX/unknown-anytype.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/unknown-anytype.cpp?rev=259681=259680=259681=diff
==
--- cfe/trunk/test/SemaCXX/unknown-anytype.cpp (original)
+++ cfe/trunk/test/SemaCXX/unknown-anytype.cpp Wed Feb  3 13:13:08 2016
@@ -45,3 +45,14 @@ namespace test4 {
 int x = (int) test1; // expected-error {{function 'test1' with unknown 
type must be given a function type}}
   }
 }
+
+// rdar://problem/23959960
+namespace test5 {
+  template struct X; // expected-note{{template is declared here}}
+
+  extern __unknown_anytype test0(...);
+
+  void test() {
+(X)test0(); // expected-error{{implicit instantiation of undefined 
template 'test5::X'}}
+  }
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r255943 - ObjC properties: consider ownership of properties from protocols when synthesizing.

2015-12-17 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Thu Dec 17 18:52:31 2015
New Revision: 255943

URL: http://llvm.org/viewvc/llvm-project?rev=255943=rev
Log:
ObjC properties: consider ownership of properties from protocols when 
synthesizing.

When determining whether ownership was explicitly written for a
property when it is being synthesized, also consider that the original
property might have come from a protocol. Fixes rdar://problem/23931441.

Modified:
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/test/SemaObjC/arc-property-decl-attrs.m

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=255943=255942=255943=diff
==
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Thu Dec 17 18:52:31 2015
@@ -868,6 +868,13 @@ static bool hasWrittenStorageAttribute(O
   return OrigProp->getPropertyAttributesAsWritten() & OwnershipMask;
   }
 
+  // Look through all of the protocols.
+  for (const auto *Proto : OrigClass->all_referenced_protocols()) {
+if (ObjCPropertyDecl *OrigProp =
+  Proto->FindPropertyDeclaration(Prop->getIdentifier()))
+  return OrigProp->getPropertyAttributesAsWritten() & OwnershipMask;
+  }
+
   return false;
 }
 

Modified: cfe/trunk/test/SemaObjC/arc-property-decl-attrs.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-property-decl-attrs.m?rev=255943=255942=255943=diff
==
--- cfe/trunk/test/SemaObjC/arc-property-decl-attrs.m (original)
+++ cfe/trunk/test/SemaObjC/arc-property-decl-attrs.m Thu Dec 17 18:52:31 2015
@@ -105,3 +105,19 @@
 @property(nonatomic, weak, nonnull, readonly) id ROdelegate; // expected-error 
{{property attributes 'nonnull' and 'weak' are mutually exclusive}}
 @end
 
+// rdar://problem/23931441
+@protocol P
+@property(readonly, retain) id prop;
+@end
+
+__attribute__((objc_root_class))
+@interface I2
+@end
+
+@interface I2()
+@property (readwrite) id prop;
+@end
+
+@implementation I2
+@synthesize prop;
+@end


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r255309 - Objective-C properties: merge attributes when redeclaring 'readonly' as 'readwrite' in an extension.

2015-12-10 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Thu Dec 10 17:02:09 2015
New Revision: 255309

URL: http://llvm.org/viewvc/llvm-project?rev=255309=rev
Log:
Objective-C properties: merge attributes when redeclaring 'readonly' as 
'readwrite' in an extension.

r251874 stopped back-patching the AST when an Objective-C 'readonly'
property is redeclared in a class extension as 'readwrite'. However,
it did not properly handle merging of Objective-C property attributes
(e.g., getter name, ownership, atomicity) to the redeclaration,
leading to bad metadata. Merge (and check!) those property attributes
so we get the right metadata and reasonable ASTs. Fixes
rdar://problem/23823989.

Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/test/CodeGenObjC/property-list-in-extension.m
cfe/trunk/test/SemaObjC/property-3.m
cfe/trunk/test/SemaObjC/property-atomic-redecl.m

Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=255309=255308=255309=diff
==
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Thu Dec 10 17:02:09 2015
@@ -2509,17 +2509,14 @@ public:
   void setPropertyAttributes(PropertyAttributeKind PRVal) {
 PropertyAttributes |= PRVal;
   }
+  void overwritePropertyAttributes(unsigned PRVal) {
+PropertyAttributes = PRVal;
+  }
 
   PropertyAttributeKind getPropertyAttributesAsWritten() const {
 return PropertyAttributeKind(PropertyAttributesAsWritten);
   }
 
-  bool hasWrittenStorageAttribute() const {
-return PropertyAttributesAsWritten & (OBJC_PR_assign | OBJC_PR_copy |
-OBJC_PR_unsafe_unretained | OBJC_PR_retain | OBJC_PR_strong |
-OBJC_PR_weak);
-  }
-
   void setPropertyAttributesAsWritten(PropertyAttributeKind PRVal) {
 PropertyAttributesAsWritten = PRVal;
   }

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=255309=255308=255309=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Dec 10 17:02:09 
2015
@@ -930,6 +930,9 @@ def warn_missing_explicit_synthesis : Wa
 def warn_property_getter_owning_mismatch : Warning<
   "property declared as returning non-retained objects"
   "; getter returning retained objects">;
+def warn_property_redecl_getter_mismatch : Warning<
+  "getter name mismatch between property redeclaration (%1) and its original "
+  "declaration (%0)">, InGroup;
 def error_property_setter_ambiguous_use : Error<
   "synthesized properties %0 and %1 both claim setter %2 -"
   " use of this setter will cause unexpected behavior">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=255309=255308=255309=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Dec 10 17:02:09 2015
@@ -3057,11 +3057,9 @@ public:
   FieldDeclarator ,
   Selector GetterSel,
   Selector SetterSel,
-  const bool isAssign,
   const bool isReadWrite,
-  const unsigned Attributes,
+  unsigned ,
   const unsigned AttributesAsWritten,
-  bool *isOverridingProperty,
   QualType T,
   TypeSourceInfo *TSI,
   tok::ObjCKeywordKind MethodImplKind);
@@ -3075,7 +3073,6 @@ public:
FieldDeclarator ,
Selector GetterSel,
Selector SetterSel,
-   const bool isAssign,
const bool isReadWrite,
const unsigned Attributes,
const unsigned AttributesAsWritten,
@@ -7333,7 +7330,6 @@ public:
   SourceLocation LParenLoc,
   FieldDeclarator , ObjCDeclSpec ,
   Selector GetterSel, Selector SetterSel,
-  bool *OverridingProperty,
   tok::ObjCKeywordKind MethodImplKind,
   DeclContext *lexicalDC = nullptr);
 

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: 

r255174 - Objective-C properties: loosen 'atomic' checking for readonly properties.

2015-12-09 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Wed Dec  9 16:57:32 2015
New Revision: 255174

URL: http://llvm.org/viewvc/llvm-project?rev=255174=rev
Log:
Objective-C properties: loosen 'atomic' checking for readonly properties.

r251874 reworked the way we handle properties declared within
Objective-C class extensions, which had the effective of tightening up
property checking in a number of places. In this particular class of
cases, we end up complaining about "atomic" mismatches between an
implicitly-atomic, readonly property and a nonatomic, readwrite
property, which doesn't make sense because "atomic" is essentially
irrelevant to readonly properties.

Therefore, suppress this diagnostic when the readonly property is
implicitly atomic. Fixes rdar://problem/23803109.

Added:
cfe/trunk/test/SemaObjC/property-atomic-redecl.m
Modified:
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/test/SemaObjC/property-3.m
cfe/trunk/test/SemaObjC/property-in-class-extension-1.m

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=255174=255173=255174=diff
==
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Wed Dec  9 16:57:32 2015
@@ -339,6 +339,54 @@ static bool LocPropertyAttribute( ASTCon
   
 }
 
+/// Check for a mismatch in the atomicity of the given properties.
+static void checkAtomicPropertyMismatch(Sema ,
+ObjCPropertyDecl *OldProperty,
+ObjCPropertyDecl *NewProperty) {
+  // If the atomicity of both matches, we're done.
+  bool OldIsAtomic =
+(OldProperty->getPropertyAttributes() & ObjCDeclSpec::DQ_PR_nonatomic) == 
0;
+  bool NewIsAtomic =
+(NewProperty->getPropertyAttributes() & ObjCDeclSpec::DQ_PR_nonatomic) == 
0;
+  if (OldIsAtomic == NewIsAtomic) return;
+
+  // Determine whether the given property is readonly and implicitly
+  // atomic.
+  auto isImplicitlyReadonlyAtomic = [](ObjCPropertyDecl *Property) -> bool {
+// Is it readonly?
+auto Attrs = Property->getPropertyAttributes();
+if ((Attrs & ObjCDeclSpec::DQ_PR_readonly) == 0) return false;
+
+// Is it nonatomic?
+if (Attrs & ObjCDeclSpec::DQ_PR_nonatomic) return false;
+
+// Was 'atomic' specified directly?
+if (Property->getPropertyAttributesAsWritten() & 
ObjCDeclSpec::DQ_PR_atomic)
+  return false;
+
+return true;
+  };
+
+  // One of the properties is atomic; if it's a readonly property, and
+  // 'atomic' wasn't explicitly specified, we're okay.
+  if ((OldIsAtomic && isImplicitlyReadonlyAtomic(OldProperty)) ||
+  (NewIsAtomic && isImplicitlyReadonlyAtomic(NewProperty)))
+return;
+
+  // Diagnose the conflict.
+  const IdentifierInfo *OldContextName;
+  auto *OldDC = OldProperty->getDeclContext();
+  if (auto Category = dyn_cast(OldDC))
+OldContextName = Category->getClassInterface()->getIdentifier();
+  else
+OldContextName = cast(OldDC)->getIdentifier();
+
+  S.Diag(NewProperty->getLocation(), diag::warn_property_attribute)
+<< NewProperty->getDeclName() << "atomic"
+<< OldContextName;
+  S.Diag(OldProperty->getLocation(), diag::note_property_declare);
+}
+
 ObjCPropertyDecl *
 Sema::HandlePropertyInClassExtension(Scope *S,
  SourceLocation AtLoc,
@@ -464,20 +512,7 @@ Sema::HandlePropertyInClassExtension(Sco
   
   // Check that atomicity of property in class extension matches the previous
   // declaration.
-  unsigned PDeclAtomicity =
-PDecl->getPropertyAttributes() & (ObjCDeclSpec::DQ_PR_atomic | 
ObjCDeclSpec::DQ_PR_nonatomic);
-  unsigned PIDeclAtomicity =
-PIDecl->getPropertyAttributes() & (ObjCDeclSpec::DQ_PR_atomic | 
ObjCDeclSpec::DQ_PR_nonatomic);
-  if (PDeclAtomicity != PIDeclAtomicity) {
-bool PDeclAtomic = (!PDeclAtomicity || PDeclAtomicity & 
ObjCDeclSpec::DQ_PR_atomic);
-bool PIDeclAtomic = (!PIDeclAtomicity || PIDeclAtomicity & 
ObjCDeclSpec::DQ_PR_atomic);
-if (PDeclAtomic != PIDeclAtomic) {
-  Diag(PDecl->getLocation(), diag::warn_property_attribute)
-<< PDecl->getDeclName() << "atomic"
-<< cast(PIDecl->getDeclContext())->getName();
-  Diag(PIDecl->getLocation(), diag::note_property_declare);
-}
-  }
+  checkAtomicPropertyMismatch(*this, PIDecl, PDecl);
 
   *isOverridingProperty = true;
 
@@ -1326,12 +1361,10 @@ Sema::DiagnosePropertyMismatch(ObjCPrope
 }
   }
 
-  if ((CAttr & ObjCPropertyDecl::OBJC_PR_nonatomic)
-  != (SAttr & ObjCPropertyDecl::OBJC_PR_nonatomic)) {
-Diag(Property->getLocation(), diag::warn_property_attribute)
-  << Property->getDeclName() << "atomic" << inheritedName;
-Diag(SuperProperty->getLocation(), diag::note_property_declare);
-  }
+  // Check for nonatomic; note that nonatomic is effectively
+  // meaningless for readonly properties, so don't 

r255065 - Module file extensions: pass a Sema through to the extension writer.

2015-12-08 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Tue Dec  8 16:43:32 2015
New Revision: 255065

URL: http://llvm.org/viewvc/llvm-project?rev=255065=rev
Log:
Module file extensions: pass a Sema through to the extension writer.

Module file extensions are likely to need access to
Sema/Preprocessor/ASTContext, and cannot get it through other
sources.

Modified:
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/include/clang/Serialization/ModuleFileExtension.h
cfe/trunk/lib/Frontend/TestModuleFileExtension.cpp
cfe/trunk/lib/Frontend/TestModuleFileExtension.h
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=255065=255064=255065=diff
==
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Tue Dec  8 16:43:32 2015
@@ -551,7 +551,8 @@ private:
   void WriteObjCCategories();
   void WriteLateParsedTemplates(Sema );
   void WriteOptimizePragmaOptions(Sema );
-  void WriteModuleFileExtension(ModuleFileExtensionWriter );
+  void WriteModuleFileExtension(Sema ,
+ModuleFileExtensionWriter );
 
   unsigned DeclParmVarAbbrev;
   unsigned DeclContextLexicalAbbrev;

Modified: cfe/trunk/include/clang/Serialization/ModuleFileExtension.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ModuleFileExtension.h?rev=255065=255064=255065=diff
==
--- cfe/trunk/include/clang/Serialization/ModuleFileExtension.h (original)
+++ cfe/trunk/include/clang/Serialization/ModuleFileExtension.h Tue Dec  8 
16:43:32 2015
@@ -25,7 +25,8 @@ namespace clang {
 
 class ASTReader;
 class ASTWriter;
-
+class Sema;
+  
 namespace serialization {
   class ModuleFile;
 } // end namespace serialization
@@ -79,7 +80,7 @@ public:
   /// The default implementation of this function simply returns the
   /// hash code as given, so the presence/absence of this extension
   /// does not distinguish module files.
-  virtual llvm::hash_code hashExtension(llvm::hash_code Code) const;
+  virtual llvm::hash_code hashExtension(llvm::hash_code c) const;
 
   /// Create a new module file extension writer, which will be
   /// responsible for writing the extension contents into a particular
@@ -120,7 +121,8 @@ public:
   /// Responsible for writing the contents of the extension into the
   /// given stream. All of the contents should be written into custom
   /// records with IDs >= FIRST_EXTENSION_RECORD_ID.
-  virtual void writeExtensionContents(llvm::BitstreamWriter ) = 0;
+  virtual void writeExtensionContents(Sema ,
+  llvm::BitstreamWriter ) = 0;
 };
 
 /// Abstract base class that reads a module file extension block from

Modified: cfe/trunk/lib/Frontend/TestModuleFileExtension.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TestModuleFileExtension.cpp?rev=255065=255064=255065=diff
==
--- cfe/trunk/lib/Frontend/TestModuleFileExtension.cpp (original)
+++ cfe/trunk/lib/Frontend/TestModuleFileExtension.cpp Tue Dec  8 16:43:32 2015
@@ -19,6 +19,7 @@ using namespace clang::serialization;
 TestModuleFileExtension::Writer::~Writer() { }
 
 void TestModuleFileExtension::Writer::writeExtensionContents(
+   Sema ,
llvm::BitstreamWriter ) {
   using namespace llvm;
 

Modified: cfe/trunk/lib/Frontend/TestModuleFileExtension.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TestModuleFileExtension.h?rev=255065=255064=255065=diff
==
--- cfe/trunk/lib/Frontend/TestModuleFileExtension.h (original)
+++ cfe/trunk/lib/Frontend/TestModuleFileExtension.h Tue Dec  8 16:43:32 2015
@@ -30,7 +30,8 @@ class TestModuleFileExtension : public M
 Writer(ModuleFileExtension *Ext) : ModuleFileExtensionWriter(Ext) { }
 ~Writer() override;
 
-void writeExtensionContents(llvm::BitstreamWriter ) override;
+void writeExtensionContents(Sema ,
+llvm::BitstreamWriter ) override;
   };
 
   class Reader : public ModuleFileExtensionReader {

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=255065=255064=255065=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Tue Dec  8 16:43:32 2015
@@ -3880,7 +3880,8 @@ void ASTWriter::WriteOptimizePragmaOptio
   Stream.EmitRecord(OPTIMIZE_PRAGMA_OPTIONS, Record);
 }
 
-void ASTWriter::WriteModuleFileExtension(ModuleFileExtensionWriter ) {

r255066 - Objective-C properties: fix bogus use of "isa<>" on a QualType.

2015-12-08 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Tue Dec  8 16:45:17 2015
New Revision: 255066

URL: http://llvm.org/viewvc/llvm-project?rev=255066=rev
Log:
Objective-C properties: fix bogus use of "isa<>" on a QualType.

The code used "isa" to check the type and then "getAs" to look through
sugar; we need to look through the sugar when checking, too, otherwise
any kind of sugar (nullability qualifiers in the example; or a
typedef) will thwart this semantic check. Fixes rdar://problem/23804250.


Modified:
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/test/SemaObjCXX/property-type-mismatch.mm

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=255066=255065=255066=diff
==
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Tue Dec  8 16:45:17 2015
@@ -1372,12 +1372,11 @@ bool Sema::DiagnosePropertyAccessorMisma
   QualType PropertyIvarType = property->getType().getNonReferenceType();
   bool compat = Context.hasSameType(PropertyIvarType, GetterType);
   if (!compat) {
-if (isa(PropertyIvarType) && 
-isa(GetterType))
-  compat =
-Context.canAssignObjCInterfaces(
-  
GetterType->getAs(),
-  
PropertyIvarType->getAs());
+const ObjCObjectPointerType *propertyObjCPtr = nullptr;
+const ObjCObjectPointerType *getterObjCPtr = nullptr;
+if ((propertyObjCPtr = PropertyIvarType->getAs()) 
&& 
+(getterObjCPtr = GetterType->getAs()))
+  compat = Context.canAssignObjCInterfaces(getterObjCPtr, propertyObjCPtr);
 else if (CheckAssignmentConstraints(Loc, GetterType, PropertyIvarType) 
   != Compatible) {
   Diag(Loc, diag::error_property_accessor_type)

Modified: cfe/trunk/test/SemaObjCXX/property-type-mismatch.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/property-type-mismatch.mm?rev=255066=255065=255066=diff
==
--- cfe/trunk/test/SemaObjCXX/property-type-mismatch.mm (original)
+++ cfe/trunk/test/SemaObjCXX/property-type-mismatch.mm Tue Dec  8 16:45:17 2015
@@ -18,3 +18,13 @@
 @property (assign) NSObject *prop;
 @end
 
+@interface C : NSObject 
+@end
+
+@interface D
+@property (nonatomic,readonly,nonnull) C *property;
+@end
+
+@interface D ()
+@property (nonatomic, setter=_setProperty:) C *property; // okay
+@end


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [cfe-commits] r119285 - in /cfe/trunk: lib/Frontend/ASTUnit.cpp tools/c-index-test/c-index-test.c

2015-11-18 Thread Douglas Gregor via cfe-commits

> On Nov 18, 2015, at 9:36 AM, Manuel Klimek  wrote:
> 
> 
> 
> On Wed, Nov 18, 2015 at 6:19 PM Douglas Gregor  > wrote:
> 
> 
> Sent from my iPhone
> 
> On Nov 18, 2015, at 8:19 AM, Manuel Klimek  > wrote:
> 
>> (now with the right list)
>> 
>> On Tue, Nov 16, 2010 at 12:03 AM Douglas Gregor > > wrote:
>> Author: dgregor
>> Date: Mon Nov 15 17:00:34 2010
>> New Revision: 119285
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=119285=rev 
>> 
>> Log:
>> Tweak libclang's heuristics for building precompiled preambles and
>> caching global code-completion results. In particular, don't perform
>> either operation the first time we parse, but do both after the first
>> reparse.
>> 
>> Do you remember the reason behind not building the preamble on the first 
>> parse? For really large TUs having to parse 2 times before we get a preamble 
>> is rather painful.
> 
> We wanted to get the first set of results quickly, especially for syntax 
> coloring when a file is first opened. 
> 
> Do you remember how much storing the preamble would make this slower (without 
> the preamble many of our parses are >> 20 seconds, so 2x that is rather 
> unfortunate). Perhaps we can add a flag?

I don’t remember the numbers from… 5 years ago. I do remember that it was a 
noticeable lag in the UI when opening a new file, primarily because the AST 
serialization step needed to produce the preamble file is fairly expensive. You 
can turn on the timers by setting the LIBCLANG_TIMING environment variable to 
see how long things are taking without having to recompile, since it’s probably 
worth re-measuring now.

- Doug

>  
> 
>> 
>> Cheers,
>> /Manuel 
>> 
>> 
>> Modified:
>> cfe/trunk/lib/Frontend/ASTUnit.cpp
>> cfe/trunk/tools/c-index-test/c-index-test.c
>> 
>> Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=119285=119284=119285=diff
>>  
>> 
>> ==
>> --- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
>> +++ cfe/trunk/lib/Frontend/ASTUnit.cpp Mon Nov 15 17:00:34 2010
>> @@ -326,7 +326,6 @@
>> 
>>// Make a note of the state when we performed this caching.
>>NumTopLevelDeclsAtLastCompletionCache = top_level_size();
>> -  CacheCodeCompletionCoolDown = 15;
>>  }
>> 
>>  void ASTUnit::ClearCachedCompletionResults() {
>> @@ -824,12 +823,6 @@
>>}
>> 
>>Invocation.reset(Clang.takeInvocation());
>> -
>> -  // If we were asked to cache code-completion results and don't have any
>> -  // results yet, do so now.
>> -  if (ShouldCacheCodeCompletionResults && CachedCompletionResults.empty())
>> -CacheCodeCompletionResults();
>> -
>>return false;
>> 
>>  error:
>> @@ -1350,7 +1343,7 @@
>> 
>>llvm::MemoryBuffer *OverrideMainBuffer = 0;
>>if (PrecompilePreamble) {
>> -PreambleRebuildCounter = 1;
>> +PreambleRebuildCounter = 2;
>>  OverrideMainBuffer
>>= getMainBufferWithPrecompiledPreamble(*Invocation);
>>}
>> @@ -1377,6 +1370,7 @@
>>AST->CaptureDiagnostics = CaptureDiagnostics;
>>AST->CompleteTranslationUnit = CompleteTranslationUnit;
>>AST->ShouldCacheCodeCompletionResults = CacheCodeCompletionResults;
>> +  AST->CacheCodeCompletionCoolDown = 1;
>>AST->Invocation.reset(CI);
>> 
>>return AST->LoadFromCompilerInvocation(PrecompilePreamble)? 0 : 
>> AST.take();
>> @@ -1481,6 +1475,7 @@
>>AST->CaptureDiagnostics = CaptureDiagnostics;
>>AST->CompleteTranslationUnit = CompleteTranslationUnit;
>>AST->ShouldCacheCodeCompletionResults = CacheCodeCompletionResults;
>> +  AST->CacheCodeCompletionCoolDown = 1;
>>AST->NumStoredDiagnosticsFromDriver = StoredDiagnostics.size();
>>AST->NumStoredDiagnosticsInPreamble = StoredDiagnostics.size();
>>AST->StoredDiagnostics.swap(StoredDiagnostics);
>> 
>> Modified: cfe/trunk/tools/c-index-test/c-index-test.c
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=119285=119284=119285=diff
>>  
>> 
>> ==
>> --- cfe/trunk/tools/c-index-test/c-index-test.c (original)
>> +++ cfe/trunk/tools/c-index-test/c-index-test.c Mon Nov 15 17:00:34 2010
>> @@ -1040,6 +1040,11 @@
>>  fprintf(stderr, "Unable to load translation unit!\n");
>>  return 1;
>>}
>> +
>> +  if (clang_reparseTranslationUnit(TU, 0, 0, 
>> clang_defaultReparseOptions(TU))) {
>> +fprintf(stderr, "Unable to reparse translation init!\n");
>> +   

r251949 - Simplify Sema::ProcessPropertyDecl. NFC

2015-11-03 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Tue Nov  3 11:02:34 2015
New Revision: 251949

URL: http://llvm.org/viewvc/llvm-project?rev=251949=rev
Log:
Simplify Sema::ProcessPropertyDecl. NFC

Now that the properties created within Objective-C class extensions go
into the extension themselves, we don't need any of the extra
complexity here.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaObjCProperty.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=251949=251948=251949=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Nov  3 11:02:34 2015
@@ -7257,14 +7257,7 @@ public:
   /// Process the specified property declaration and create decls for the
   /// setters and getters as needed.
   /// \param property The property declaration being processed
-  /// \param CD The semantic container for the property
-  /// \param redeclaredProperty Declaration for property if redeclared
-  ///in class extension.
-  /// \param lexicalDC Container for redeclaredProperty.
-  void ProcessPropertyDecl(ObjCPropertyDecl *property,
-   ObjCContainerDecl *CD,
-   ObjCPropertyDecl *redeclaredProperty = nullptr,
-   ObjCContainerDecl *lexicalDC = nullptr);
+  void ProcessPropertyDecl(ObjCPropertyDecl *property);
 
 
   void DiagnosePropertyMismatch(ObjCPropertyDecl *Property,

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=251949=251948=251949=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Tue Nov  3 11:02:34 2015
@@ -3637,7 +3637,7 @@ Decl *Sema::ActOnAtEnd(Scope *S, SourceR
   // user-defined setter/getter. It also synthesizes setter/getter methods
   // and adds them to the DeclContext and global method pools.
   for (auto *I : CDecl->properties())
-ProcessPropertyDecl(I, CDecl);
+ProcessPropertyDecl(I);
 CDecl->setAtEndRange(AtEnd);
   }
   if (ObjCImplementationDecl *IC=dyn_cast(ClassDecl)) {

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=251949=251948=251949=diff
==
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Tue Nov  3 11:02:34 2015
@@ -390,9 +390,7 @@ Sema::HandlePropertyInClassExtension(Sco
   // If there was no declaration of a property with the same name in
   // the primary class, we're done.
   if (!PIDecl) {
-ProcessPropertyDecl(PDecl, CDecl,
-/* redeclaredProperty = */ nullptr,
-/* lexicalDC = */ CDecl);
+ProcessPropertyDecl(PDecl);
 return PDecl;
   }
 
@@ -483,8 +481,8 @@ Sema::HandlePropertyInClassExtension(Sco
 
   *isOverridingProperty = true;
 
-  // Make sure setter decl is synthesized, and added to continuation class's 
list.
-  ProcessPropertyDecl(PDecl, CDecl, PIDecl, CDecl);
+  // Make sure getter/setter are appropriately synthesized.
+  ProcessPropertyDecl(PDecl);
   return PDecl;
 }
 
@@ -1973,15 +1971,10 @@ static void AddPropertyAttrs(Sema , Ob
 /// ProcessPropertyDecl - Make sure that any user-defined setter/getter methods
 /// have the property type and issue diagnostics if they don't.
 /// Also synthesize a getter/setter method if none exist (and update the
-/// appropriate lookup tables. FIXME: Should reconsider if adding synthesized
-/// methods is the "right" thing to do.
-void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
-   ObjCContainerDecl *CD,
-   ObjCPropertyDecl *redeclaredProperty,
-   ObjCContainerDecl *lexicalDC) {
-
+/// appropriate lookup tables.
+void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property) {
   ObjCMethodDecl *GetterMethod, *SetterMethod;
-
+  ObjCContainerDecl *CD = cast(property->getDeclContext());
   if (CD->isInvalidDecl())
 return;
 
@@ -2060,10 +2053,6 @@ void Sema::ProcessPropertyDecl(ObjCPrope
 
 AddPropertyAttrs(*this, GetterMethod, property);
 
-// FIXME: Eventually this shouldn't be needed, as the lexical context
-// and the real context should be the same.
-if (lexicalDC)
-  GetterMethod->setLexicalDeclContext(lexicalDC);
 if (property->hasAttr())
   GetterMethod->addAttr(NSReturnsNotRetainedAttr::CreateImplicit(Context,
  Loc));
@@ -2134,10 +2123,6 @@ void Sema::ProcessPropertyDecl(ObjCPrope
   AddPropertyAttrs(*this, 

r251955 - Introduce module file extensions to piggy-back data onto module files.

2015-11-03 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Tue Nov  3 12:33:07 2015
New Revision: 251955

URL: http://llvm.org/viewvc/llvm-project?rev=251955=rev
Log:
Introduce module file extensions to piggy-back data onto module files.

Introduce the notion of a module file extension, which introduces
additional information into a module file at the time it is built that
can then be queried when the module file is read. Module file
extensions are identified by a block name (which must be unique to the
extension) and can write any bitstream records into their own
extension block within the module file. When a module file is loaded,
any extension blocks are matched up with module file extension
readers, that are per-module-file and are given access to the input
bitstream.

Note that module file extensions can only be introduced by
programmatic clients that have access to the CompilerInvocation. There
is only one such extension at the moment, which is used for testing
the module file extension harness. As a future direction, one could
imagine allowing the plugin mechanism to introduce new module file
extensions.

Added:
cfe/trunk/include/clang/Serialization/ModuleFileExtension.h
cfe/trunk/lib/Frontend/TestModuleFileExtension.cpp
cfe/trunk/lib/Frontend/TestModuleFileExtension.h
cfe/trunk/lib/Serialization/ModuleFileExtension.cpp
cfe/trunk/test/Modules/Inputs/ExtensionTestA.h
cfe/trunk/test/Modules/extensions.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/CompilerInstance.h
cfe/trunk/include/clang/Frontend/FrontendOptions.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/include/clang/Serialization/Module.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/CMakeLists.txt
cfe/trunk/lib/Frontend/ChainedIncludesSource.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/CMakeLists.txt
cfe/trunk/lib/Serialization/GeneratePCH.cpp
cfe/trunk/test/Modules/Inputs/module.map

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=251955=251954=251955=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Nov  3 12:33:07 
2015
@@ -193,6 +193,10 @@ def err_drv_modules_validate_once_requir
   "option '-fmodules-validate-once-per-build-session' requires "
   "'-fbuild-session-timestamp=' or 
'-fbuild-session-file='">;
 
+def err_test_module_file_extension_format : Error<
+  "-ftest-module-file-extension argument '%0' is not of the required form "
+  "'blockname:major:minor:hashed:user info'">;
+
 def warn_drv_invoking_fallback : Warning<"falling back to %0">,
   InGroup;
 

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=251955=251954=251955=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Tue Nov  3 
12:33:07 2015
@@ -204,6 +204,10 @@ def err_modules_embed_file_not_found :
   Error<"file '%0' specified by '-fmodules-embed-file=' not found">,
   DefaultFatal;
 
+def err_test_module_file_extension_version : Error<
+  "test module file extension '%0' has different version (%1.%2) than expected 
"
+  "(%3.%4)">;
+
 def err_conflicting_module_names : Error<
   "conflicting module names specified: '-fmodule-name=%0' and "
   "'-fmodule-implementation-of %1'">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=251955=251954=251955=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Nov  3 12:33:07 2015
@@ -253,6 +253,7 @@ def MismatchedTags : DiagGroup<"mismatch
 def MissingFieldInitializers : DiagGroup<"missing-field-initializers">;
 def ModuleBuild : DiagGroup<"module-build">;
 def ModuleConflict : DiagGroup<"module-conflict">;
+def ModuleFileExtension : 

r251877 - Eliminate "rewritten decls" from the AST writer. NFC

2015-11-02 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Mon Nov  2 19:20:54 2015
New Revision: 251877

URL: http://llvm.org/viewvc/llvm-project?rev=251877=rev
Log:
Eliminate "rewritten decls" from the AST writer. NFC


Modified:
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=251877=251876=251877=diff
==
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Mon Nov  2 19:20:54 2015
@@ -376,10 +376,6 @@ private:
   /// coming from another AST file.
   SmallVector UpdatingVisibleDecls;
 
-  typedef llvm::SmallSetVector DeclsToRewriteTy;
-  /// \brief Decls that will be replaced in the current dependent AST file.
-  DeclsToRewriteTy DeclsToRewrite;
-
   /// \brief The set of Objective-C class that have categories we
   /// should serialize.
   llvm::SetVector ObjCClassesWithCategories;
@@ -764,14 +760,6 @@ public:
   /// \brief Add a version tuple to the given record
   void AddVersionTuple(const VersionTuple , RecordDataImpl );
 
-  void RewriteDecl(const Decl *D) {
-DeclsToRewrite.insert(D);
-  }
-
-  bool isRewritten(const Decl *D) const {
-return DeclsToRewrite.count(D);
-  }
-
   /// \brief Infer the submodule ID that contains an entity at the given
   /// source location.
   serialization::SubmoduleID inferSubmoduleIDFromLocation(SourceLocation Loc);

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=251877=251876=251877=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Mon Nov  2 19:20:54 2015
@@ -3513,11 +3513,11 @@ ASTWriter::GenerateNameLookupTable(const
 auto  = Lookup.first;
 auto  = Lookup.second;
 
-// If there are no local declarations in our lookup result, we don't
-// need to write an entry for the name at all unless we're rewriting
-// the decl context. If we can't write out a lookup set without
-// performing more deserialization, just skip this entry.
-if (isLookupResultExternal(Result, DC) && !isRewritten(cast(DC)) &&
+// If there are no local declarations in our lookup result, we
+// don't need to write an entry for the name at all. If we can't
+// write out a lookup set without performing more deserialization,
+// just skip this entry.
+if (isLookupResultExternal(Result, DC) &&
 isLookupResultEntirelyExternal(Result, DC))
   continue;
 
@@ -3758,9 +3758,6 @@ uint64_t ASTWriter::WriteDeclContextVisi
 /// (in C++), for namespaces, and for classes with forward-declared unscoped
 /// enumeration members (in C++11).
 void ASTWriter::WriteDeclContextVisibleUpdate(const DeclContext *DC) {
-  if (isRewritten(cast(DC)))
-return;
-
   StoredDeclsMap *Map = DC->getLookupPtr();
   if (!Map || Map->empty())
 return;
@@ -4376,10 +4373,6 @@ uint64_t ASTWriter::WriteASTCore(Sema 
   Stream.EnterSubblock(DECLTYPES_BLOCK_ID, /*bits for abbreviations*/5);
   WriteTypeAbbrevs();
   WriteDeclAbbrevs();
-  for (DeclsToRewriteTy::iterator I = DeclsToRewrite.begin(),
-  E = DeclsToRewrite.end();
-   I != E; ++I)
-DeclTypesToEmit.push(const_cast(*I));
   do {
 WriteDeclUpdatesBlocks(DeclUpdatesOffsetsRecord);
 while (!DeclTypesToEmit.empty()) {
@@ -4545,8 +4538,6 @@ void ASTWriter::WriteDeclUpdatesBlocks(R
 
   for (auto  : LocalUpdates) {
 const Decl *D = DeclUpdate.first;
-if (isRewritten(D))
-  continue; // The decl will be written completely,no need to store 
updates.
 
 bool HasUpdatedBody = false;
 RecordData Record;

Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=251877=251876=251877=diff
==
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Mon Nov  2 19:20:54 2015
@@ -2093,16 +2093,12 @@ void ASTWriter::WriteDecl(ASTContext 
 
   // Determine the ID for this declaration.
   serialization::DeclID ID;
-  if (D->isFromASTFile()) {
-assert(isRewritten(D) && "should not be emitting imported decl");
-ID = getDeclID(D);
-  } else {
-serialization::DeclID  = DeclIDs[D];
-if (IDR == 0)
-  IDR = NextDeclID++;
+  assert(!D->isFromASTFile() && "should not be emitting imported decl");
+  serialization::DeclID  = DeclIDs[D];
+  if (IDR == 0)
+IDR = NextDeclID++;
 
-ID = IDR;
-  }
+  ID = IDR;
 
   bool isReplacingADecl = 

Re: r251874 - Stop back-patching 'readonly' Objective-C properties with 'readwrite' ones.

2015-11-02 Thread Douglas Gregor via cfe-commits
… and I forgot the most important part, which is that this is based on the good 
work of Mr. Kyrtzidis that I failed to acknowledge in the commit message.

- Doug


> On Nov 2, 2015, at 5:15 PM, Douglas Gregor via cfe-commits 
> <cfe-commits@lists.llvm.org> wrote:
> 
> Author: dgregor
> Date: Mon Nov  2 19:15:46 2015
> New Revision: 251874
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=251874=rev
> Log:
> Stop back-patching 'readonly' Objective-C properties with 'readwrite' ones.
> 
> A 'readonly' Objective-C property declared in the primary class can
> effectively be shadowed by a 'readwrite' property declared within an
> extension of that class, so long as the types and attributes of the
> two property declarations are compatible.
> 
> Previously, this functionality was implemented by back-patching the
> original 'readonly' property to make it 'readwrite', destroying source
> information and causing some hideously redundant, incorrect
> code. Simplify the implementation to express how this should actually
> be modeled: as a separate property declaration in the extension that
> shadows (via the name lookup rules) the declaration in the primary
> class. While here, correct some broken Fix-Its, eliminate a pile of
> redundant code, clean up the ARC migrator's handling of properties
> declared in extensions, and fix debug info's naming of methods that
> come from categories.
> 
> A wonderous side effect of doing this write is that it eliminates the
> "AddedObjCPropertyInClassExtension" method from the AST mutation
> listener, which in turn eliminates the last place where we rewrite
> entire declarations in a chained PCH file or a module file. This
> change (which fixes rdar://problem/18475765) will allow us to
> eliminate the rewritten-decls logic from the serialization library,
> and fixes a crash (rdar://problem/23247794) illustrated by the
> test/PCH/chain-categories.m example.
> 
> 
> Modified:
>cfe/trunk/include/clang/AST/ASTMutationListener.h
>cfe/trunk/include/clang/AST/DeclObjC.h
>cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>cfe/trunk/include/clang/Sema/Sema.h
>cfe/trunk/include/clang/Serialization/ASTWriter.h
>cfe/trunk/lib/ARCMigrate/TransProperties.cpp
>cfe/trunk/lib/AST/DeclObjC.cpp
>cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>cfe/trunk/lib/Frontend/MultiplexConsumer.cpp
>cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>cfe/trunk/lib/Sema/SemaExprObjC.cpp
>cfe/trunk/lib/Sema/SemaObjCProperty.cpp
>cfe/trunk/lib/Serialization/ASTWriter.cpp
>cfe/trunk/test/FixIt/atomic-property.m
>cfe/trunk/test/Index/complete-kvc.m
>cfe/trunk/test/Modules/ModuleDebugInfo.m
>cfe/trunk/test/PCH/chain-categories.m
>cfe/trunk/test/SemaObjC/atomoic-property-synnthesis-rules.m
>cfe/trunk/test/SemaObjC/property-3.m
>cfe/trunk/test/SemaObjC/property-in-class-extension-1.m
>cfe/trunk/test/SemaObjCXX/property-invalid-type.mm
> 
> Modified: cfe/trunk/include/clang/AST/ASTMutationListener.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTMutationListener.h?rev=251874=251873=251874=diff
> ==
> --- cfe/trunk/include/clang/AST/ASTMutationListener.h (original)
> +++ cfe/trunk/include/clang/AST/ASTMutationListener.h Mon Nov  2 19:15:46 2015
> @@ -92,18 +92,6 @@ public:
>   virtual void AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD,
> const ObjCInterfaceDecl *IFD) {}
> 
> -  /// \brief A objc class extension redeclared or introduced a property.
> -  ///
> -  /// \param Prop the property in the class extension
> -  ///
> -  /// \param OrigProp the property from the original interface that was 
> declared
> -  /// or null if the property was introduced.
> -  ///
> -  /// \param ClassExt the class extension.
> -  virtual void AddedObjCPropertyInClassExtension(const ObjCPropertyDecl 
> *Prop,
> -const ObjCPropertyDecl *OrigProp,
> -const ObjCCategoryDecl 
> *ClassExt) {}
> -
>   /// \brief A declaration is marked used which was not previously marked 
> used.
>   ///
>   /// \param D the declaration marked used
> 
> Modified: cfe/trunk/include/clang/AST/DeclObjC.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=251874=251873=251874=diff
> ==
> --- cfe/trunk/include/clang/AST/DeclObjC.h (original)
> +++ cfe/trunk/include/clang/AST/DeclObjC.h Mon Nov  2 19:15:46 2015
> @@ -2524,11 +2524,6 @@ p

Re: r248949 - Don't inherit availability information when implementing a protocol requirement.

2015-10-09 Thread Douglas Gregor via cfe-commits

> On Oct 7, 2015, at 11:55 AM, Hans Wennborg <h...@chromium.org> wrote:
> 
> Hi Doug,
> 
> On Wed, Sep 30, 2015 at 2:27 PM, Douglas Gregor via cfe-commits
> <cfe-commits@lists.llvm.org> wrote:
>> Author: dgregor
>> Date: Wed Sep 30 16:27:42 2015
>> New Revision: 248949
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=248949=rev
>> Log:
>> Don't inherit availability information when implementing a protocol 
>> requirement.
>> 
>> When an Objective-C method implements a protocol requirement, do not
>> inherit any availability information from the protocol
>> requirement. Rather, check that the implementation is not less
>> available than the protocol requirement, as we do when overriding a
>> method that has availability. Fixes rdar://problem/22734745.
> 
> This is causing new warnings to fire in Chromium, and I'm not sure
> they're correct.
> 
> For example:
> 
>  $ cat | build/bin/clang -c -x objective-c++ -
>  #import 
>  @protocol Foo
>  @end
>  @interface Bar : NSTextView {
>  }
>  @end
>  @implementation Bar
>  - (void)setMarkedText:(id)aString selectedRange:(NSRange)selRange {
>[super setMarkedText:aString selectedRange:selRange];
>  }
>  @end
>  :9:10: warning: 'setMarkedText:selectedRange:' is deprecated:
> first deprecated in OS X 10.6 [-Wdeprecated-declarations]
>[super setMarkedText:aString selectedRange:selRange];
>   ^
>  /System/Library/Frameworks/AppKit.framework/Headers/NSInputManager.h:21:1:
> note: 'setMarkedText:selectedRange:' has been explicitly marked
> deprecated here
>  - (void) setMarkedText:(id)aString selectedRange:(NSRange)selRange
> NS_DEPRECATED_MAC(10_0, 10_6);
>  ^
> 
> I don't really know Objective-C, but from what I understand,
> NSTextView implements both NSTextInput and NSTextInputClient.
> setMarkedText is deprecated in the former, but not the latter. So
> warning here is probably wrong?

The warning is correct. We no longer infer that -[Bar 
setMarkedText:selectedRange:] is deprecated simply because it matches up with a 
deprecated requirement in the NSTextView protocol. You can mark this method with

NS_DEPRECATED_MAC(10_0, 10_6)

(i.e., copy the availability information from the protocol requirement) to get 
the old behavior.

- Doug

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r249896 - Fix inference of _Nullable for weak Objective-C properties.

2015-10-09 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Fri Oct  9 15:36:17 2015
New Revision: 249896

URL: http://llvm.org/viewvc/llvm-project?rev=249896=rev
Log:
Fix inference of _Nullable for weak Objective-C properties.

The inference of _Nullable for weak Objective-C properties was broken
in several ways:

* It was back-patching the type information very late in the process
  of checking the attributes for an Objective-C property, which is
  just wrong.
* It was using ad hoc checks to try to suppress the warning about
  missing nullability specifiers (-Wnullability-completeness), which
  didn't actual work in all cases (rdar://problem/22985457)
* It was inferring _Nullable even outside of assumes-nonnull regions,
  which is wrong.

Putting the inference of _Nullable for weak Objective-C properties in
the same place as all of the other inference logic fixes all of these
ills.


Modified:
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaObjC/arc-unavailable-for-weakref.m
cfe/trunk/test/SemaObjC/nullable-weak-property.m
cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-2.h
cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-6.h

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=249896=249895=249896=diff
==
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Fri Oct  9 15:36:17 2015
@@ -181,7 +181,7 @@ Decl *Sema::ActOnProperty(Scope *S, Sour
   }
 
   // Validate the attributes on the @property.
-  CheckObjCPropertyAttributes(Res, AtLoc, Attributes, 
+  CheckObjCPropertyAttributes(Res, AtLoc, Attributes,
   (isa(ClassDecl) ||
isa(ClassDecl)));
 
@@ -2301,13 +2301,6 @@ void Sema::CheckObjCPropertyAttributes(D
   if (*nullability == NullabilityKind::NonNull)
 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
   << "nonnull" << "weak";
-} else {
-PropertyTy =
-  Context.getAttributedType(
-AttributedType::getNullabilityAttrKind(NullabilityKind::Nullable),
-PropertyTy, PropertyTy);
-TypeSourceInfo *TSInfo = PropertyDecl->getTypeSourceInfo();
-PropertyDecl->setType(PropertyTy, TSInfo);
 }
   }
 

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=249896=249895=249896=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Fri Oct  9 15:36:17 2015
@@ -3311,9 +3311,7 @@ static TypeSourceInfo *GetFullTypeForDec
 
   // Are we in an assume-nonnull region?
   bool inAssumeNonNullRegion = false;
-  if (S.PP.getPragmaAssumeNonNullLoc().isValid() &&
-  !state.getDeclarator().isObjCWeakProperty() &&
-  !S.deduceWeakPropertyFromType(T)) {
+  if (S.PP.getPragmaAssumeNonNullLoc().isValid()) {
 inAssumeNonNullRegion = true;
 // Determine which file we saw the assume-nonnull region in.
 FileID file = getNullabilityCompletenessCheckFileID(
@@ -3392,6 +3390,13 @@ static TypeSourceInfo *GetFullTypeForDec
 complainAboutMissingNullability = CAMN_No;
 break;
   }
+
+  // Weak properties are inferred to be nullable.
+  if (state.getDeclarator().isObjCWeakProperty() && inAssumeNonNullRegion) 
{
+inferNullability = NullabilityKind::Nullable;
+break;
+  }
+
   // fallthrough
 
 case Declarator::FileContext:

Modified: cfe/trunk/test/SemaObjC/arc-unavailable-for-weakref.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-unavailable-for-weakref.m?rev=249896=249895=249896=diff
==
--- cfe/trunk/test/SemaObjC/arc-unavailable-for-weakref.m (original)
+++ cfe/trunk/test/SemaObjC/arc-unavailable-for-weakref.m Fri Oct  9 15:36:17 
2015
@@ -56,7 +56,7 @@ __attribute__((objc_arc_weak_reference_u
 @interface I
 {
 }
-@property (weak) NSFont *font; // expected-error {{synthesizing __weak 
instance variable of type 'NSFont * _Nullable', which does not support weak 
references}}
+@property (weak) NSFont *font; // expected-error {{synthesizing __weak 
instance variable of type 'NSFont *', which does not support weak references}}
 @end
 
 @implementation I // expected-note {{when implemented by class I}}
@@ -65,7 +65,7 @@ __attribute__((objc_arc_weak_reference_u
 
 // rdar://13676793
 @protocol MyProtocol
-@property (weak) NSFont *font; // expected-error {{synthesizing __weak 
instance variable of type 'NSFont * _Nullable', which does not support weak 
references}}
+@property (weak) NSFont *font; // expected-error {{synthesizing __weak 
instance variable of type 'NSFont *', which does not support weak 

Re: r248949 - Don't inherit availability information when implementing a protocol requirement.

2015-10-09 Thread Douglas Gregor via cfe-commits


Sent from my iPhone

> On Oct 9, 2015, at 2:17 PM, Hans Wennborg <h...@chromium.org> wrote:
> 
>> On Fri, Oct 9, 2015 at 1:46 PM, Douglas Gregor <dgre...@apple.com> wrote:
>> 
>>> On Oct 7, 2015, at 11:55 AM, Hans Wennborg <h...@chromium.org> wrote:
>>> 
>>> Hi Doug,
>>> 
>>> On Wed, Sep 30, 2015 at 2:27 PM, Douglas Gregor via cfe-commits
>>> <cfe-commits@lists.llvm.org> wrote:
>>>> Author: dgregor
>>>> Date: Wed Sep 30 16:27:42 2015
>>>> New Revision: 248949
>>>> 
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=248949=rev
>>>> Log:
>>>> Don't inherit availability information when implementing a protocol 
>>>> requirement.
>>>> 
>>>> When an Objective-C method implements a protocol requirement, do not
>>>> inherit any availability information from the protocol
>>>> requirement. Rather, check that the implementation is not less
>>>> available than the protocol requirement, as we do when overriding a
>>>> method that has availability. Fixes rdar://problem/22734745.
>>> 
>>> This is causing new warnings to fire in Chromium, and I'm not sure
>>> they're correct.
>>> 
>>> For example:
>>> 
>>> $ cat | build/bin/clang -c -x objective-c++ -
>>> #import 
>>> @protocol Foo
>>> @end
>>> @interface Bar : NSTextView {
>>> }
>>> @end
>>> @implementation Bar
>>> - (void)setMarkedText:(id)aString selectedRange:(NSRange)selRange {
>>>   [super setMarkedText:aString selectedRange:selRange];
>>> }
>>> @end
>>> :9:10: warning: 'setMarkedText:selectedRange:' is deprecated:
>>> first deprecated in OS X 10.6 [-Wdeprecated-declarations]
>>>   [super setMarkedText:aString selectedRange:selRange];
>>>  ^
>>> /System/Library/Frameworks/AppKit.framework/Headers/NSInputManager.h:21:1:
>>> note: 'setMarkedText:selectedRange:' has been explicitly marked
>>> deprecated here
>>> - (void) setMarkedText:(id)aString selectedRange:(NSRange)selRange
>>> NS_DEPRECATED_MAC(10_0, 10_6);
>>> ^
>>> 
>>> I don't really know Objective-C, but from what I understand,
>>> NSTextView implements both NSTextInput and NSTextInputClient.
>>> setMarkedText is deprecated in the former, but not the latter. So
>>> warning here is probably wrong?
>> 
>> The warning is correct. We no longer infer that -[Bar 
>> setMarkedText:selectedRange:] is deprecated simply because it matches up 
>> with a deprecated requirement in the NSTextView protocol. You can mark this 
>> method with
>> 
>>NS_DEPRECATED_MAC(10_0, 10_6)
>> 
>> (i.e., copy the availability information from the protocol requirement) to 
>> get the old behavior.
> 
> 
> Again, apologies for my Objective-C ignorance here, but don't you mean
> the other way around?

No, I have it correct. 

> Before this patch we did not warn that setMarkedText was deprecated,
> but now we do. It seems we've gone from not inferring that it's
> deprecated to doing so?

NSTextView's setMarkedText is deprecated. Whether we diagnose a call to a 
deprecated method depends on the context: inside another deprecated method we 
suppress the diagnostic. 

That's where the inference comes in. We used to (incorrectly) infer that Bar's 
setMarkedText was deprecated. That's wrong, and it suppressed the deprecated 
warning for the call to the NSTextView version. 

  - Doug

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r249065 - Perform Objective-C lifetime adjustments before comparing deduced lambda result types.

2015-10-01 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Thu Oct  1 15:20:47 2015
New Revision: 249065

URL: http://llvm.org/viewvc/llvm-project?rev=249065=rev
Log:
Perform Objective-C lifetime adjustments before comparing deduced lambda result 
types.

Objective-C ARC lifetime qualifiers are dropped when canonicalizing
function types. Perform the same adjustment before comparing the
deduced result types of lambdas. Fixes rdar://problem/22344904.

Added:
cfe/trunk/test/SemaObjCXX/cxx1y-lambda.mm
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=249065=249064=249065=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Oct  1 15:20:47 2015
@@ -968,6 +968,9 @@ public:
   const FunctionType *adjustFunctionType(const FunctionType *Fn,
  FunctionType::ExtInfo EInfo);
 
+  /// Adjust the given function result type.
+  CanQualType getCanonicalFunctionResultType(QualType ResultType) const;
+
   /// \brief Change the result type of a function type once it is deduced.
   void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType);
 

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=249065=249064=249065=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Oct  1 15:20:47 2015
@@ -2990,6 +2990,21 @@ static bool isCanonicalResultType(QualTy
   T.getObjCLifetime() == Qualifiers::OCL_ExplicitNone);
 }
 
+CanQualType
+ASTContext::getCanonicalFunctionResultType(QualType ResultType) const {
+  CanQualType CanResultType = getCanonicalType(ResultType);
+
+  // Canonical result types do not have ARC lifetime qualifiers.
+  if (CanResultType.getQualifiers().hasObjCLifetime()) {
+Qualifiers Qs = CanResultType.getQualifiers();
+Qs.removeObjCLifetime();
+return CanQualType::CreateUnsafe(
+ getQualifiedType(CanResultType.getUnqualifiedType(), Qs));
+  }
+
+  return CanResultType;
+}
+
 QualType
 ASTContext::getFunctionType(QualType ResultTy, ArrayRef ArgArray,
 const FunctionProtoType::ExtProtoInfo ) const {
@@ -3027,14 +3042,8 @@ ASTContext::getFunctionType(QualType Res
 CanonicalEPI.HasTrailingReturn = false;
 CanonicalEPI.ExceptionSpec = FunctionProtoType::ExceptionSpecInfo();
 
-// Result types do not have ARC lifetime qualifiers.
-QualType CanResultTy = getCanonicalType(ResultTy);
-if (ResultTy.getQualifiers().hasObjCLifetime()) {
-  Qualifiers Qs = CanResultTy.getQualifiers();
-  Qs.removeObjCLifetime();
-  CanResultTy = getQualifiedType(CanResultTy.getUnqualifiedType(), Qs);
-}
-
+// Adjust the canonical function result type.
+CanQualType CanResultTy = getCanonicalFunctionResultType(ResultTy);
 Canonical = getFunctionType(CanResultTy, CanonicalArgs, CanonicalEPI);
 
 // Get the new insert position for the node we care about.

Modified: cfe/trunk/lib/Sema/SemaLambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLambda.cpp?rev=249065=249064=249065=diff
==
--- cfe/trunk/lib/Sema/SemaLambda.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLambda.cpp Thu Oct  1 15:20:47 2015
@@ -685,7 +685,8 @@ void Sema::deduceClosureReturnType(Captu
 
 QualType ReturnType =
 (RetE ? RetE->getType() : Context.VoidTy).getUnqualifiedType();
-if (Context.hasSameType(ReturnType, CSI.ReturnType))
+if (Context.getCanonicalFunctionResultType(ReturnType) ==
+  Context.getCanonicalFunctionResultType(CSI.ReturnType))
   continue;
 
 // FIXME: This is a poor diagnostic for ReturnStmts without expressions.

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=249065=249064=249065=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Thu Oct  1 15:20:47 2015
@@ -3028,8 +3028,11 @@ bool Sema::DeduceFunctionTypeFromReturnE
   //  the program is ill-formed.
   if (AT->isDeduced() && !FD->isInvalidDecl()) {
 AutoType *NewAT = Deduced->getContainedAutoType();
-if (!FD->isDependentContext() &&
-!Context.hasSameType(AT->getDeducedType(), NewAT->getDeducedType())) {
+CanQualType OldDeducedType = Context.getCanonicalFunctionResultType(
+   AT->getDeducedType());
+CanQualType NewDeducedType = 

r248949 - Don't inherit availability information when implementing a protocol requirement.

2015-09-30 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Wed Sep 30 16:27:42 2015
New Revision: 248949

URL: http://llvm.org/viewvc/llvm-project?rev=248949=rev
Log:
Don't inherit availability information when implementing a protocol requirement.

When an Objective-C method implements a protocol requirement, do not
inherit any availability information from the protocol
requirement. Rather, check that the implementation is not less
available than the protocol requirement, as we do when overriding a
method that has availability. Fixes rdar://problem/22734745.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/ARCMT/checking.m
cfe/trunk/test/SemaObjC/attr-availability.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=248949=248948=248949=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Sep 30 16:27:42 
2015
@@ -2410,15 +2410,19 @@ def warn_availability_version_ordering :
 def warn_mismatched_availability: Warning<
   "availability does not match previous declaration">, InGroup;
 def warn_mismatched_availability_override : Warning<
-  "overriding method %select{introduced after|"
-  "deprecated before|obsoleted before}0 overridden method on %1 (%2 vs. %3)">, 
-  InGroup;
+  "%select{|overriding }4method %select{introduced after|"
+  "deprecated before|obsoleted before}0 "
+  "%select{the protocol method it implements|overridden method}4 "
+  "on %1 (%2 vs. %3)">, InGroup;
 def warn_mismatched_availability_override_unavail : Warning<
-  "overriding method cannot be unavailable on %0 when its overridden method is 
"
+  "%select{|overriding }1method cannot be unavailable on %0 when "
+  "%select{the protocol method it implements|its overridden method}1 is "
   "available">,
   InGroup;
 def note_overridden_method : Note<
   "overridden method is here">;
+def note_protocol_method : Note<
+  "protocol method is here">;
 
 // Thread Safety Attributes
 def warn_invalid_capability_name : Warning<

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=248949=248948=248949=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Sep 30 16:27:42 2015
@@ -2062,6 +2062,22 @@ public:
 TypeSourceInfo *TInfo);
   bool isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New);
 
+  /// \brief Describes the kind of merge to perform for availability
+  /// attributes (including "deprecated", "unavailable", and "availability").
+  enum AvailabilityMergeKind {
+/// \brief Don't merge availability attributes at all.
+AMK_None,
+/// \brief Merge availability attributes for a redeclaration, which 
requires
+/// an exact match.
+AMK_Redeclaration,
+/// \brief Merge availability attributes for an override, which requires
+/// an exact match or a weakening of constraints.
+AMK_Override,
+/// \brief Merge availability attributes for an implementation of
+/// a protocol requirement.
+AMK_ProtocolImplementation,
+  };
+
   /// Attribute merging methods. Return true if a new attribute was added.
   AvailabilityAttr *mergeAvailabilityAttr(NamedDecl *D, SourceRange Range,
   IdentifierInfo *Platform,
@@ -2070,7 +2086,7 @@ public:
   VersionTuple Obsoleted,
   bool IsUnavailable,
   StringRef Message,
-  bool Override,
+  AvailabilityMergeKind AMK,
   unsigned AttrSpellingListIndex);
   TypeVisibilityAttr *mergeTypeVisibilityAttr(Decl *D, SourceRange Range,
TypeVisibilityAttr::VisibilityType Vis,
@@ -2099,19 +2115,6 @@ public:
   OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D, SourceRange Range,
   unsigned AttrSpellingListIndex);
 
-  /// \brief Describes the kind of merge to perform for availability
-  /// attributes (including "deprecated", "unavailable", and "availability").
-  enum AvailabilityMergeKind {
-/// \brief Don't merge availability attributes at all.
-AMK_None,
-/// \brief Merge availability attributes for a redeclaration, which 
requires
-/// an exact match.
-AMK_Redeclaration,
-/// \brief Merge availability attributes for an override, which requires
-/// an exact match or a weakening 

r248950 - Don't inherit the "unavailable" attribute from an overridden superclass method.

2015-09-30 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Wed Sep 30 16:34:33 2015
New Revision: 248950

URL: http://llvm.org/viewvc/llvm-project?rev=248950=rev
Log:
Don't inherit the "unavailable" attribute from an overridden superclass method.

Fixes rdar://problem/22922259.

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaObjC/attr-availability.m

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=248950=248949=248950=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Sep 30 16:34:33 2015
@@ -2220,12 +2220,10 @@ static bool mergeDeclAttribute(Sema ,
 // AlignedAttrs are handled separately, because we need to handle all
 // such attributes on a declaration at the same time.
 NewAttr = nullptr;
-  else if (isa(Attr)  &&
+  else if ((isa(Attr) || isa(Attr)) &&
(AMK == Sema::AMK_Override ||
 AMK == Sema::AMK_ProtocolImplementation))
 NewAttr = nullptr;
-  else if (isa(Attr) && AMK == 
Sema::AMK_ProtocolImplementation)
-NewAttr = nullptr;
   else if (Attr->duplicatesAllowed() || !DeclHasAttr(D, Attr))
 NewAttr = cast(Attr->clone(S.Context));
 

Modified: cfe/trunk/test/SemaObjC/attr-availability.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-availability.m?rev=248950=248949=248950=diff
==
--- cfe/trunk/test/SemaObjC/attr-availability.m (original)
+++ cfe/trunk/test/SemaObjC/attr-availability.m Wed Sep 30 16:34:33 2015
@@ -278,3 +278,19 @@ __attribute__((objc_root_class))
 -(void)methodB __attribute__((unavailable)) {
 }
 @end
+
+__attribute__((objc_root_class))
+@interface InheritUnavailableSuper
+-(void)method __attribute__((unavailable)); // expected-note{{'method' has 
been explicitly marked unavailable here}}
+@end
+
+@interface InheritUnavailableSub : InheritUnavailableSuper
+-(void)method;
+@end
+
+@implementation InheritUnavailableSub
+-(void)method {
+  InheritUnavailableSuper *obj = self;
+  [obj method]; // expected-error{{'method' is unavailable}}
+}
+@end


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits