<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;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@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">Thanks Richard. I’ll update the documentation and submit a new patch for review.<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">Elizabeth<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>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<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"> Keane, Erich
<br>
<b>Sent:</b> Wednesday, February 14, 2018 11:33 AM<br>
<b>To:</b> Richard Smith <richard@metafoo.co.uk>; Andrews, Elizabeth <elizabeth.andrews@intel.com><br>
<b>Cc:</b> cfe-commits <cfe-commits@lists.llvm.org><br>
<b>Subject:</b> RE: r325081 - Implement function attribute artificial<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Thanks for your comments Richard, I’ve added the author to this email so that she can take a look.<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"><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"> Richard Smith [<a href="mailto:richard@metafoo.co.uk">mailto:richard@metafoo.co.uk</a>]
<br>
<b>Sent:</b> Tuesday, February 13, 2018 5:39 PM<br>
<b>To:</b> Keane, Erich <<a href="mailto:erich.keane@intel.com">erich.keane@intel.com</a>><br>
<b>Cc:</b> cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>><br>
<b>Subject:</b> Re: r325081 - Implement function attribute artificial<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<p class="MsoNormal">On 13 February 2018 at 16:14, Erich Keane via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<p class="MsoNormal">Author: erichkeane<br>
Date: Tue Feb 13 16:14:07 2018<br>
New Revision: 325081<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=325081&view=rev" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=325081&view=rev</a><br>
Log:<br>
Implement function attribute artificial<br>
<br>
Added support in clang for GCC function attribute 'artificial'. This attribute<br>
is used to control stepping behavior of debugger with respect to inline<br>
functions.<br>
<br>
Patch By: Elizabeth Andrews (eandrews)<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D43259" target="_blank">
https://reviews.llvm.org/D43259</a><br>
<br>
<br>
Added:<br>
    cfe/trunk/test/CodeGen/artificial.c<br>
    cfe/trunk/test/Sema/artificial.c<br>
Modified:<br>
    cfe/trunk/include/clang/Basic/Attr.td<br>
    cfe/trunk/include/clang/Basic/AttrDocs.td<br>
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Basic/Attr.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=325081&r1=325080&r2=325081&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=325081&r1=325080&r2=325081&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/Attr.td (original)<br>
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Feb 13 16:14:07 2018<br>
@@ -111,6 +111,9 @@ def SharedVar : SubsetSubject<Var,<br>
 def GlobalVar : SubsetSubject<Var,<br>
                              [{S->hasGlobalStorage()}], "global variables">;<br>
<br>
+def InlineFunction : SubsetSubject<Function,<br>
+                             [{S->isInlineSpecified()}], "inline functions">;<br>
+<br>
 // FIXME: this hack is needed because DeclNodes.td defines the base Decl node<br>
 // type to be a class, not a definition. This makes it impossible to create an<br>
 // attribute subject which accepts a Decl. Normally, this is not a problem,<br>
@@ -588,6 +591,12 @@ def AlwaysInline : InheritableAttr {<br>
   let Documentation = [Undocumented];<br>
 }<br>
<br>
+def Artificial : InheritableAttr {<br>
+  let Spellings = [GCC<"artificial">];<br>
+  let Subjects = SubjectList<[InlineFunction], WarnDiag>;<br>
+  let Documentation = [ArtificialDocs];<br>
+}<br>
+<br>
 def XRayInstrument : InheritableAttr {<br>
   let Spellings = [Clang<"xray_always_instrument">,<br>
                    Clang<"xray_never_instrument">];<br>
<br>
Modified: cfe/trunk/include/clang/Basic/AttrDocs.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=325081&r1=325080&r2=325081&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=325081&r1=325080&r2=325081&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)<br>
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Tue Feb 13 16:14:07 2018<br>
@@ -3273,3 +3273,13 @@ For more information see<br>
 or `msvc documentation <<a href="https://docs.microsoft.com/pl-pl/cpp/cpp/selectany" target="_blank">https://docs.microsoft.com/pl-pl/cpp/cpp/selectany</a>>`_.<br>
 }];<br>
 }<br>
+<br>
+def ArtificialDocs : Documentation {<br>
+  let Category = DocCatFunction;<br>
+  let Content = [{<br>
+The ``artificial`` attribute is used with inline functions to treat the inline<br>
+function as a unit while debugging. For more information see GCC_ documentation.<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I find this to be hard to understand. What does "treat the inline function as a unit" actually mean? How about something like:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">The ``artificial`` attribute can be applied to an inline function. If such a function is inlined, the attribute indicates that debuggers should associate the resulting instructions with the call site, rather than with the corresponding
 line within the inlined callee.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><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-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<p class="MsoNormal">+<br>
+.. _GCC: <a href="https://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/Function-Attributes.html" target="_blank">
https://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/Function-Attributes.html</a><o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">If you still want to reference the GCC documentation, could you pick a newer version? :)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><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-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<p class="MsoNormal">+  }];<br>
+}<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=325081&r1=325080&r2=325081&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=325081&r1=325080&r2=325081&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Feb 13 16:14:07 2018<br>
@@ -3235,7 +3235,7 @@ void CGDebugInfo::EmitFunctionStart(Glob<br>
   if (Name.startswith("\01"))<br>
     Name = Name.substr(1);<br>
<br>
-  if (!HasDecl || D->isImplicit()) {<br>
+  if (!HasDecl || D->isImplicit() || D->hasAttr<ArtificialAttr>()) {<br>
     Flags |= llvm::DINode::FlagArtificial;<br>
     // Artificial functions should not silently reuse CurLoc.<br>
     CurLoc = SourceLocation();<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=325081&r1=325080&r2=325081&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=325081&r1=325080&r2=325081&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Feb 13 16:14:07 2018<br>
@@ -6057,6 +6057,9 @@ static void ProcessDeclAttribute(Sema &S<br>
   case AttributeList::AT_AlwaysInline:<br>
     handleAlwaysInlineAttr(S, D, Attr);<br>
     break;<br>
+  case AttributeList::AT_Artificial:<br>
+    handleSimpleAttribute<ArtificialAttr>(S, D, Attr);<br>
+    break;<br>
   case AttributeList::AT_AnalyzerNoReturn:<br>
     handleAnalyzerNoReturnAttr(S, D, Attr);<br>
     break;<br>
<br>
Added: cfe/trunk/test/CodeGen/artificial.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/artificial.c?rev=325081&view=auto" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/artificial.c?rev=325081&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGen/artificial.c (added)<br>
+++ cfe/trunk/test/CodeGen/artificial.c Tue Feb 13 16:14:07 2018<br>
@@ -0,0 +1,10 @@<br>
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s<br>
+<br>
+extern void foo();<br>
+// CHECK: !DISubprogram(name: "foo"<br>
+// CHECK-SAME: flags: DIFlagArtificial<br>
+inline void __attribute__((artificial)) foo() {}<br>
+<br>
+void baz() {<br>
+  foo();<br>
+}<br>
<br>
Added: cfe/trunk/test/Sema/artificial.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/artificial.c?rev=325081&view=auto" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/artificial.c?rev=325081&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Sema/artificial.c (added)<br>
+++ cfe/trunk/test/Sema/artificial.c Tue Feb 13 16:14:07 2018<br>
@@ -0,0 +1,4 @@<br>
+// RUN: %clang_cc1 -fsyntax-only -verify %s<br>
+<br>
+inline void __attribute__((artificial)) foo() {}<br>
+void __attribute__((artificial)) bar() {} // expected-warning {{'artificial' attribute only applies to inline functions}}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</body>
</html>