[llvm-bugs] [Bug 28615] New: Fix ordering of function attributes under MSVCFormatting policy in DeclPrinter

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jul 19 08:26:52 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=28615

            Bug ID: 28615
           Summary: Fix ordering of function attributes under
                    MSVCFormatting policy in DeclPrinter
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: keyboardsmoke at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

This fix would place the attributes at the beginning of a function (but after
specifiers).
Ideally, I'd like them to be after the return type is declared, but this is
acceptable by MSVC standards.

I am not intimately familiar with clang's rules regarding just jamming in space
characters like that, but since other strings are being appended to out in a
similar fashion I thought it would be acceptable.

Index: DeclPrinter.cpp
===================================================================
--- DeclPrinter.cpp    (revision 275612)
+++ DeclPrinter.cpp    (working copy)
@@ -474,6 +474,13 @@
   SubPolicy.SuppressSpecifiers = false;
   std::string Proto = D->getNameInfo().getAsString();

+  if (Policy.MSVCFormatting) {
+    prettyPrintAttributes(D);
+
+    if (D->attr_begin() != D->attr_end())
+      Out << " ";
+  }
+
   QualType Ty = D->getType();
   while (const ParenType *PT = dyn_cast<ParenType>(Ty)) {
     Proto = '(' + Proto + ')';
@@ -628,7 +635,8 @@
     Ty.print(Out, Policy, Proto);
   }

-  prettyPrintAttributes(D);
+  if (!Policy.MSVCFormatting)
+    prettyPrintAttributes(D);

   if (D->isPure())
     Out << " = 0";

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160719/7325bf99/attachment.html>


More information about the llvm-bugs mailing list