<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Include calling convention in function print"
   href="https://llvm.org/bugs/show_bug.cgi?id=28628">28628</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Include calling convention in function print
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>keyboardsmoke@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Unsure if the option in PrettyPrinter.h is necessary, but I wanted it in my own
space. If there was already a way to specify my intention to print the calling
convention, please inform me and close this - but I didn't see one.

Index: PrettyPrinter.h
===================================================================
--- PrettyPrinter.h    (revision 275612)
+++ PrettyPrinter.h    (working copy)
@@ -50,7 +50,7 @@
       UseVoidForZeroParams(!LO.CPlusPlus),
       TerseOutput(false), PolishForDeclaration(false),
       Half(LO.Half), MSWChar(LO.MicrosoftExt && !LO.WChar),
-      IncludeNewlines(true), MSVCFormatting(false) { }
+      IncludeNewlines(true), IncludeCallingConvention(false),
MSVCFormatting(false) { }

   /// \brief Adjust this printing policy for cases where it's known that
   /// we're printing C++ code (for instance, if AST dumping reaches a
@@ -196,6 +196,9 @@
   /// \brief When true, include newlines after statements like "break", etc.
   unsigned IncludeNewlines : 1;

+  /// \brief When true, include calling convention information for functions.
+  unsigned IncludeCallingConvention : 1;
+
   /// \brief Use whitespace and punctuation like MSVC does. In particular,
this
   /// prints anonymous namespaces as `anonymous namespace' and does not insert
   /// spaces after template arguments.


Index: DeclPrinter.cpp
===================================================================
--- DeclPrinter.cpp    (revision 275612)
+++ DeclPrinter.cpp    (working copy)
@@ -620,6 +640,68 @@
         Out << "auto " << Proto << " -> ";
         Proto.clear();
       }
+
+      //
+      if (Policy.IncludeCallingConvention)
+      {
+          CallingConv cconv = AFT->getCallConv();
+
+          std::string ccname = AFT->getNameForCallConv(cconv).str();
+
+          if (Policy.MSVCFormatting)
+          {
+              switch (cconv)
+              {
+              case CC_C:
+              case CC_X86StdCall:
+              case CC_X86FastCall:
+              case CC_X86Pascal: // Not supported anymore.
+                  ccname = "__" + ccname;
+                  break;
+              case CC_X86ThisCall:
+                  if (!D->isCXXClassMember())
+                      ccname = "__" + ccname;
+                  else
+                      ccname = ""; // __thiscall is the default (at least for
MSVC...)
+
+                  break;
+              case CC_X86VectorCall:
+                  ccname = "_" + ccname;
+                  break;
+              default:
+                  // CC_X86Pascal
+                  // CC_X86_64Win64
+                  // CC_X86_64SysV
+                  // CC_AAPCS
+                  // CC_AAPCS_VFP
+                  // CC_IntelOclBicc
+                  // CC_SpirFunction
+                  // CC_OpenCLKernel
+                  // CC_Swift
+                  // CC_PreserveMost
+                  // CC_PreserveAll
+                  ccname = ""; // Not supported.
+                  break;
+              }
+          }
+          else
+          {
+              if (cconv == CC_AAPCS)
+                  ccname = "__attribute__((pcs(\"aapcs\")))";
+              else if (cconv == CC_AAPCS_VFP)
+                  ccname = "__attribute__((pcs(\"aapcs-vfp\")))";
+              else if (cconv == CC_SpirFunction)
+                  ccname = ""; // default for OpenCL functions on SPIR target
+              else if (cconv == CC_OpenCLKernel)
+                  ccname = ""; // inferred for OpenCL kernels
+              else
+                 ccname = "__attribute__((" + ccname + "))";
+          }
+
+          if (!ccname.empty())
+              Proto = ccname + " " + Proto;
+      }
+
       AFT->getReturnType().print(Out, Policy, Proto);
       Proto.clear();
     }</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>