<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Presumably the right choice for you on this one is to separate the diagnostic into a new group.  Copying Aaron since he might have an idea of an existing group,
 otherwise I’ll push a commit to put it in a new one.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Thanks for the report!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">-Erich<o:p></o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></a></p>
<p class="MsoNormal"><a name="_____replyseparator"></a><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Nico Weber [mailto:thakis@chromium.org]
<br>
<b>Sent:</b> Thursday, May 30, 2019 6:15 PM<br>
<b>To:</b> Keane, Erich <erich.keane@intel.com><br>
<b>Cc:</b> cfe-commits <cfe-commits@lists.llvm.org><br>
<b>Subject:</b> Re: r362119 - Add Attribute NoThrow as an Exception Specifier Type<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Hello,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">this causes this diagnostic when building on Windows:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">In file included from ../../ui/accessibility/platform/ax_platform_node_textchildprovider_win.cc:10:<br>
../..\ui/accessibility/platform/ax_platform_node_textprovider_win.h(22,3): error: 'nothrow' attribute conflicts with exception specification; attribute ignored [-Werror,-Wignored-attributes]<br>
  END_COM_MAP()<br>
  ^<br>
..\..\third_party\depot_tools\win_toolchain\vs_files\ 818a152b3f1da991c1725d85be19a0f27af6bab4\VC\Tools\MSVC\14.16.27023\atlmfc\include\atlcom.h(2358,2): note: expanded from macro 'END_COM_MAP'<br>
        STDMETHOD(QueryInterface)( \<br>
        ^<br>
..\..\third_party\depot_tools\win_toolchain\vs_files\ 818a152b3f1da991c1725d85be19a0f27af6bab4\win_sdk\Include\10.0.17763.0\um\combaseapi.h(170,42): note: expanded from macro 'STDMETHOD'<br>
#define STDMETHOD(method)        virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE method<br>
                                         ^<br>
..\..\third_party\depot_tools\win_toolchain\vs_files\ 818a152b3f1da991c1725d85be19a0f27af6bab4\win_sdk\Include\10.0.17763.0\um\combaseapi.h(165,30): note: expanded from macro 'COM_DECLSPEC_NOTHROW'<br>
#define COM_DECLSPEC_NOTHROW DECLSPEC_NOTHROW<br>
                             ^<br>
..\..\third_party\depot_tools\win_toolchain\vs_files\ 818a152b3f1da991c1725d85be19a0f27af6bab4\win_sdk\Include\10.0.17763.0\um\winnt.h(200,39): note: expanded from macro 'DECLSPEC_NOTHROW'<br>
#define DECLSPEC_NOTHROW   __declspec(nothrow)<br>
                                      ^<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Suggestions? We don't want to use -Wno-ignored-attributes since that disables this warning for all attributes.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">All the involved macros are in system headers and we have no control over them.<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Thu, May 30, 2019 at 1:28 PM Erich Keane via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">Author: erichkeane<br>
Date: Thu May 30 10:31:54 2019<br>
New Revision: 362119<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=362119&view=rev" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=362119&view=rev</a><br>
Log:<br>
Add Attribute NoThrow as an Exception Specifier Type<br>
<br>
In response to <a href="https://bugs.llvm.org/show_bug.cgi?id=33235" target="_blank">
https://bugs.llvm.org/show_bug.cgi?id=33235</a>, it became<br>
clear that the current mechanism of hacking through checks for the<br>
exception specification of a function gets confused really quickly when<br>
there are alternate exception specifiers.<br>
<br>
This patch introcues EST_NoThrow, which is the equivilent of<br>
EST_noexcept when caused by EST_noThrow. The existing implementation is<br>
left in place to cover functions with no FunctionProtoType.<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D62435" target="_blank">
https://reviews.llvm.org/D62435</a><br>
<br>
Added:<br>
    cfe/trunk/test/SemaCXX/nothrow-vs-exception-specs.cpp   (with props)<br>
Modified:<br>
    cfe/trunk/include/clang-c/Index.h<br>
    cfe/trunk/include/clang/AST/Decl.h<br>
    cfe/trunk/include/clang/AST/Type.h<br>
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
    cfe/trunk/include/clang/Basic/ExceptionSpecificationType.h<br>
    cfe/trunk/lib/AST/ASTContext.cpp<br>
    cfe/trunk/lib/AST/JSONNodeDumper.cpp<br>
    cfe/trunk/lib/AST/Type.cpp<br>
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp<br>
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp<br>
    cfe/trunk/lib/Sema/SemaExprCXX.cpp<br>
    cfe/trunk/lib/Sema/SemaType.cpp<br>
    cfe/trunk/tools/libclang/CXType.cpp<br>
<br>
Modified: cfe/trunk/include/clang-c/Index.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=362119&r1=362118&r2=362119&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=362119&r1=362118&r2=362119&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang-c/Index.h (original)<br>
+++ cfe/trunk/include/clang-c/Index.h Thu May 30 10:31:54 2019<br>
@@ -32,7 +32,7 @@<br>
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.<br>
  */<br>
 #define CINDEX_VERSION_MAJOR 0<br>
-#define CINDEX_VERSION_MINOR 57<br>
+#define CINDEX_VERSION_MINOR 58<br>
<br>
 #define CINDEX_VERSION_ENCODE(major, minor) ( \<br>
       ((major) * 10000)                       \<br>
@@ -221,7 +221,12 @@ enum CXCursor_ExceptionSpecificationKind<br>
   /**<br>
    * The exception specification has not been parsed yet.<br>
    */<br>
-  CXCursor_ExceptionSpecificationKind_Unparsed<br>
+  CXCursor_ExceptionSpecificationKind_Unparsed,<br>
+<br>
+  /**<br>
+   * The cursor has a __declspec(nothrow) exception specification.<br>
+   */<br>
+  CXCursor_ExceptionSpecificationKind_NoThrow<br>
 };<br>
<br>
 /**<br>
<br>
Modified: cfe/trunk/include/clang/AST/Decl.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=362119&r1=362118&r2=362119&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=362119&r1=362118&r2=362119&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/AST/Decl.h (original)<br>
+++ cfe/trunk/include/clang/AST/Decl.h Thu May 30 10:31:54 2019<br>
@@ -2330,6 +2330,14 @@ public:<br>
     return T->castAs<FunctionType>()->getReturnType();<br>
   }<br>
<br>
+  /// Gets the ExceptionSpecificationType as declared.<br>
+  ExceptionSpecificationType getExceptionSpecType() const {<br>
+    auto *TSI = getTypeSourceInfo();<br>
+    QualType T = TSI ? TSI->getType() : getType();<br>
+    const auto *FPT = T->getAs<FunctionProtoType>();<br>
+    return FPT ? FPT->getExceptionSpecType() : EST_None;<br>
+  }<br>
+<br>
   /// Attempt to compute an informative source range covering the<br>
   /// function exception specification, if any.<br>
   SourceRange getExceptionSpecSourceRange() const;<br>
<br>
Modified: cfe/trunk/include/clang/AST/Type.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=362119&r1=362118&r2=362119&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=362119&r1=362118&r2=362119&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/AST/Type.h (original)<br>
+++ cfe/trunk/include/clang/AST/Type.h Thu May 30 10:31:54 2019<br>
@@ -3855,6 +3855,7 @@ private:<br>
     case EST_MSAny:<br>
     case EST_BasicNoexcept:<br>
     case EST_Unparsed:<br>
+    case EST_NoThrow:<br>
       return {0, 0, 0};<br>
<br>
     case EST_Dynamic:<br>
<br>
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=362119&r1=362118&r2=362119&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=362119&r1=362118&r2=362119&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)<br>
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu May 30 10:31:54 2019<br>
@@ -2792,6 +2792,9 @@ def warn_dllimport_dropped_from_inline_f<br>
   InGroup<IgnoredAttributes>;<br>
 def warn_attribute_ignored : Warning<"%0 attribute ignored">,<br>
   InGroup<IgnoredAttributes>;<br>
+def warn_nothrow_attribute_ignored : Warning<"'nothrow' attribute conflicts with"<br>
+  " exception specification; attribute ignored">,<br>
+  InGroup<IgnoredAttributes>;<br>
 def warn_attribute_ignored_on_inline :<br>
   Warning<"%0 attribute ignored on inline function">,<br>
   InGroup<IgnoredAttributes>;<br>
<br>
Modified: cfe/trunk/include/clang/Basic/ExceptionSpecificationType.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/ExceptionSpecificationType.h?rev=362119&r1=362118&r2=362119&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/ExceptionSpecificationType.h?rev=362119&r1=362118&r2=362119&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/ExceptionSpecificationType.h (original)<br>
+++ cfe/trunk/include/clang/Basic/ExceptionSpecificationType.h Thu May 30 10:31:54 2019<br>
@@ -22,6 +22,7 @@ enum ExceptionSpecificationType {<br>
   EST_DynamicNone,      ///< throw()<br>
   EST_Dynamic,          ///< throw(T1, T2)<br>
   EST_MSAny,            ///< Microsoft throw(...) extension<br>
+  EST_NoThrow,          ///< Microsoft __declspec(nothrow) extension<br>
   EST_BasicNoexcept,    ///< noexcept<br>
   EST_DependentNoexcept,///< noexcept(expression), value-dependent<br>
   EST_NoexceptFalse,    ///< noexcept(expression), evals to 'false'<br>
@@ -41,7 +42,8 @@ inline bool isComputedNoexcept(Exception<br>
 }<br>
<br>
 inline bool isNoexceptExceptionSpec(ExceptionSpecificationType ESpecType) {<br>
-  return ESpecType == EST_BasicNoexcept || isComputedNoexcept(ESpecType);<br>
+  return ESpecType == EST_BasicNoexcept || ESpecType == EST_NoThrow ||<br>
+         isComputedNoexcept(ESpecType);<br>
 }<br>
<br>
 inline bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType) {<br>
<br>
Modified: cfe/trunk/lib/AST/ASTContext.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=362119&r1=362118&r2=362119&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=362119&r1=362118&r2=362119&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/ASTContext.cpp (original)<br>
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu May 30 10:31:54 2019<br>
@@ -3742,7 +3742,10 @@ QualType ASTContext::getFunctionTypeInte<br>
         break;<br>
       }<br>
<br>
-      case EST_DynamicNone: case EST_BasicNoexcept: case EST_NoexceptTrue:<br>
+      case EST_DynamicNone:<br>
+      case EST_BasicNoexcept:<br>
+      case EST_NoexceptTrue:<br>
+      case EST_NoThrow:<br>
         CanonicalEPI.ExceptionSpec.Type = EST_BasicNoexcept;<br>
         break;<br>
<br>
<br>
Modified: cfe/trunk/lib/AST/JSONNodeDumper.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/JSONNodeDumper.cpp?rev=362119&r1=362118&r2=362119&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/JSONNodeDumper.cpp?rev=362119&r1=362118&r2=362119&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/JSONNodeDumper.cpp (original)<br>
+++ cfe/trunk/lib/AST/JSONNodeDumper.cpp Thu May 30 10:31:54 2019<br>
@@ -464,7 +464,9 @@ void JSONNodeDumper::VisitFunctionProtoT<br>
     //JOS.attributeWithCall("exceptionSpecExpr",<br>
     //                    [this, E]() { Visit(E.ExceptionSpec.NoexceptExpr); });<br>
     break;<br>
-<br>
+  case EST_NoThrow:<br>
+    JOS.attribute("exceptionSpec", "nothrow");<br>
+    break;<br>
   // FIXME: I cannot find a way to trigger these cases while dumping the AST. I<br>
   // suspect you can only run into them when executing an AST dump from within<br>
   // the debugger, which is not a use case we worry about for the JSON dumping<br>
<br>
Modified: cfe/trunk/lib/AST/Type.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=362119&r1=362118&r2=362119&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=362119&r1=362118&r2=362119&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/Type.cpp (original)<br>
+++ cfe/trunk/lib/AST/Type.cpp Thu May 30 10:31:54 2019<br>
@@ -3077,6 +3077,7 @@ CanThrowResult FunctionProtoType::canThr<br>
   case EST_DynamicNone:<br>
   case EST_BasicNoexcept:<br>
   case EST_NoexceptTrue:<br>
+  case EST_NoThrow:<br>
     return CT_Cannot;<br>
<br>
   case EST_None:<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=362119&r1=362118&r2=362119&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=362119&r1=362118&r2=362119&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu May 30 10:31:54 2019<br>
@@ -6853,7 +6853,8 @@ static void ProcessDeclAttribute(Sema &S<br>
     handleNoCfCheckAttr(S, D, AL);<br>
     break;<br>
   case ParsedAttr::AT_NoThrow:<br>
-    handleSimpleAttribute<NoThrowAttr>(S, D, AL);<br>
+    if (!AL.isUsedAsTypeAttr())<br>
+      handleSimpleAttribute<NoThrowAttr>(S, D, AL);<br>
     break;<br>
   case ParsedAttr::AT_CUDAShared:<br>
     handleSharedAttr(S, D, AL);<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=362119&r1=362118&r2=362119&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=362119&r1=362118&r2=362119&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu May 30 10:31:54 2019<br>
@@ -192,6 +192,7 @@ Sema::ImplicitExceptionSpecification::Ca<br>
   // If this function has a basic noexcept, it doesn't affect the outcome.<br>
   case EST_BasicNoexcept:<br>
   case EST_NoexceptTrue:<br>
+  case EST_NoThrow:<br>
     return;<br>
   // If we're still at noexcept(true) and there's a throw() callee,<br>
   // change to that specification.<br>
@@ -15457,6 +15458,7 @@ bool Sema::checkThisInStaticMemberFuncti<br>
   case EST_Uninstantiated:<br>
   case EST_Unevaluated:<br>
   case EST_BasicNoexcept:<br>
+  case EST_NoThrow:<br>
   case EST_DynamicNone:<br>
   case EST_MSAny:<br>
   case EST_None:<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=362119&r1=362118&r2=362119&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=362119&r1=362118&r2=362119&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu May 30 10:31:54 2019<br>
@@ -6045,6 +6045,8 @@ mergeExceptionSpecs(Sema &S, FunctionPro<br>
   if (EST2 == EST_NoexceptFalse) return ESI2;<br>
<br>
   // If either of them is non-throwing, the result is the other.<br>
+  if (EST1 == EST_NoThrow) return ESI2;<br>
+  if (EST2 == EST_NoThrow) return ESI1;<br>
   if (EST1 == EST_DynamicNone) return ESI2;<br>
   if (EST2 == EST_DynamicNone) return ESI1;<br>
   if (EST1 == EST_BasicNoexcept) return ESI2;<br>
@@ -6073,6 +6075,7 @@ mergeExceptionSpecs(Sema &S, FunctionPro<br>
   case EST_DependentNoexcept:<br>
   case EST_NoexceptFalse:<br>
   case EST_NoexceptTrue:<br>
+  case EST_NoThrow:<br>
     llvm_unreachable("handled above");<br>
<br>
   case EST_Dynamic: {<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaType.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=362119&r1=362118&r2=362119&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=362119&r1=362118&r2=362119&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaType.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaType.cpp Thu May 30 10:31:54 2019<br>
@@ -130,6 +130,7 @@ static void diagnoseBadTypeAttribute(Sem<br>
   case ParsedAttr::AT_Regparm:                                                 \<br>
   case ParsedAttr::AT_AnyX86NoCallerSavedRegisters:                            \<br>
   case ParsedAttr::AT_AnyX86NoCfCheck:                                         \<br>
+  case ParsedAttr::AT_NoThrow:                                                 \<br>
     CALLING_CONV_ATTRS_CASELIST<br>
<br>
 // Microsoft-specific type qualifiers.<br>
@@ -4516,7 +4517,7 @@ static TypeSourceInfo *GetFullTypeForDec<br>
       // If the function declarator has a prototype (i.e. it is not () and<br>
       // does not have a K&R-style identifier list), then the arguments are part<br>
       // of the type, otherwise the argument list is ().<br>
-      const DeclaratorChunk::FunctionTypeInfo &FTI = DeclType.Fun;<br>
+      DeclaratorChunk::FunctionTypeInfo &FTI = DeclType.Fun;<br>
       IsQualifiedFunction =<br>
           FTI.hasMethodTypeQualifiers() || FTI.hasRefQualifier();<br>
<br>
@@ -6945,6 +6946,61 @@ static bool handleFunctionTypeAttr(TypeP<br>
     return true;<br>
   }<br>
<br>
+  if (attr.getKind() == ParsedAttr::AT_NoThrow) {<br>
+    if (S.CheckAttrNoArgs(attr))<br>
+      return true;<br>
+<br>
+    // Delay if this is not a function type.<br>
+    if (!unwrapped.isFunctionType())<br>
+      return false;<br>
+<br>
+    // Otherwise we can process right away.<br>
+    auto *Proto = unwrapped.get()->getAs<FunctionProtoType>();<br>
+<br>
+    // In the case where this is a FunctionNoProtoType instead of a<br>
+    // FunctionProtoType, let the existing NoThrowAttr implementation do its<br>
+    // thing.<br>
+    if (!Proto)<br>
+      return false;<br>
+<br>
+    attr.setUsedAsTypeAttr();<br>
+<br>
+    // MSVC ignores nothrow if it is in conflict with an explicit exception<br>
+    // specification.<br>
+    if (Proto->hasExceptionSpec()) {<br>
+      switch (Proto->getExceptionSpecType()) {<br>
+      case EST_None:<br>
+        llvm_unreachable("This doesn't have an exception spec!");<br>
+        LLVM_FALLTHROUGH;<br>
+      case EST_DynamicNone:<br>
+      case EST_BasicNoexcept:<br>
+      case EST_NoexceptTrue:<br>
+      case EST_NoThrow:<br>
+        // Exception spec doesn't conflict with nothrow, so don't warn.<br>
+        break;<br>
+<br>
+      case EST_Dynamic:<br>
+      case EST_MSAny:<br>
+      case EST_NoexceptFalse:<br>
+      case EST_DependentNoexcept:<br>
+      case EST_Unevaluated:<br>
+      case EST_Uninstantiated:<br>
+      case EST_Unparsed:<br>
+        S.Diag(attr.getLoc(), diag::warn_nothrow_attribute_ignored);<br>
+        break;<br>
+      }<br>
+      return true;<br>
+    }<br>
+<br>
+    type = unwrapped.wrap(<br>
+        S, S.Context<br>
+               .getFunctionTypeWithExceptionSpec(<br>
+                   QualType{Proto, 0},<br>
+                   FunctionProtoType::ExceptionSpecInfo{EST_NoThrow})<br>
+               ->getAs<FunctionType>());<br>
+    return true;<br>
+  }<br>
+<br>
   // Delay if the type didn't work out to a function.<br>
   if (!unwrapped.isFunctionType()) return false;<br>
<br>
<br>
Added: cfe/trunk/test/SemaCXX/nothrow-vs-exception-specs.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/nothrow-vs-exception-specs.cpp?rev=362119&view=auto" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/nothrow-vs-exception-specs.cpp?rev=362119&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaCXX/nothrow-vs-exception-specs.cpp (added)<br>
+++ cfe/trunk/test/SemaCXX/nothrow-vs-exception-specs.cpp Thu May 30 10:31:54 2019<br>
@@ -0,0 +1,55 @@<br>
+// RUN: %clang_cc1 %s -fcxx-exceptions -fdeclspec -fsyntax-only -Wexceptions -verify -std=c++14<br>
+// RUN: %clang_cc1 %s -fcxx-exceptions -fdeclspec -fsyntax-only -Wexceptions -verify -std=c++17 -DCPP17<br>
+<br>
+__attribute__((nothrow)) void f1();<br>
+static_assert(noexcept(f1()), "");<br>
+void f1() noexcept;<br>
+// expected-error@+2 {{exception specification in declaration does not match previous declaration}}<br>
+// expected-note@-2 {{previous declaration is here}}<br>
+void f1() noexcept(false);<br>
+<br>
+__attribute__((nothrow)) void f2();<br>
+static_assert(noexcept(f2()), "");<br>
+// expected-error@+2 {{exception specification in declaration does not match previous declaration}}<br>
+// expected-note@-3 {{previous declaration is here}}<br>
+void f2() noexcept(false);<br>
+<br>
+void f3() __attribute__((nothrow));<br>
+static_assert(noexcept(f3()), "");<br>
+void f3() noexcept;<br>
+// expected-error@+2 {{exception specification in declaration does not match previous declaration}}<br>
+// expected-note@-2 {{previous declaration is here}}<br>
+void f3() noexcept(false);<br>
+<br>
+// Still noexcept due to throw()<br>
+__attribute__((nothrow)) void f4() throw();<br>
+static_assert(noexcept(f4()), "");<br>
+<br>
+// Still noexcept due to noexcept<br>
+__attribute__((nothrow)) void f5() noexcept;<br>
+static_assert(noexcept(f5()), "");<br>
+<br>
+// Still noexcept due to noexcept(true)<br>
+__attribute__((nothrow)) void f6() noexcept(true);<br>
+static_assert(noexcept(f6()), "");<br>
+<br>
+#ifndef CPP17<br>
+// Doesn't override C++ implementation.<br>
+// expected-warning@+1{{'nothrow' attribute conflicts with exception specification; attribute ignored}}<br>
+__attribute__((nothrow)) void f7() throw(int);<br>
+static_assert(!noexcept(f7()), "");<br>
+#endif<br>
+<br>
+// Doesn't override C++ implementation.<br>
+// expected-warning@+1{{'nothrow' attribute conflicts with exception specification; attribute ignored}}<br>
+__attribute__((nothrow)) void f8() noexcept(false);<br>
+static_assert(!noexcept(f8()), "");<br>
+<br>
+__declspec(nothrow) void foo1() noexcept;<br>
+__declspec(nothrow) void foo2() noexcept(true);<br>
+// expected-warning@+1{{'nothrow' attribute conflicts with exception specification; attribute ignored}}<br>
+__declspec(nothrow) void foo3() noexcept(false);<br>
+__declspec(nothrow) void foo4() noexcept(noexcept(foo1()));<br>
+__declspec(nothrow) void foo5() noexcept(noexcept(foo2()));<br>
+// expected-warning@+1{{'nothrow' attribute conflicts with exception specification; attribute ignored}}<br>
+__declspec(nothrow) void foo6() noexcept(noexcept(foo3()));<br>
<br>
Propchange: cfe/trunk/test/SemaCXX/nothrow-vs-exception-specs.cpp<br>
------------------------------------------------------------------------------<br>
    svn:eol-style = native<br>
<br>
Propchange: cfe/trunk/test/SemaCXX/nothrow-vs-exception-specs.cpp<br>
------------------------------------------------------------------------------<br>
    svn:keywords = Author Date Id Rev URL<br>
<br>
Propchange: cfe/trunk/test/SemaCXX/nothrow-vs-exception-specs.cpp<br>
------------------------------------------------------------------------------<br>
    svn:mime-type = text/plain<br>
<br>
Modified: cfe/trunk/tools/libclang/CXType.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXType.cpp?rev=362119&r1=362118&r2=362119&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXType.cpp?rev=362119&r1=362118&r2=362119&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/tools/libclang/CXType.cpp (original)<br>
+++ cfe/trunk/tools/libclang/CXType.cpp Thu May 30 10:31:54 2019<br>
@@ -742,6 +742,8 @@ getExternalExceptionSpecificationKind(Ex<br>
     return CXCursor_ExceptionSpecificationKind_MSAny;<br>
   case EST_BasicNoexcept:<br>
     return CXCursor_ExceptionSpecificationKind_BasicNoexcept;<br>
+  case EST_NoThrow:<br>
+    return CXCursor_ExceptionSpecificationKind_NoThrow;<br>
   case EST_NoexceptFalse:<br>
   case EST_NoexceptTrue:<br>
   case EST_DependentNoexcept:<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><o:p></o:p></p>
</blockquote>
</div>
</div>
</body>
</html>