[llvm-bugs] [Bug 44340] New: [clang-format] C# attributes and inheritance cause issues with formatting

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Dec 19 05:39:15 PST 2019


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

            Bug ID: 44340
           Summary: [clang-format] C# attributes and inheritance cause
                    issues with formatting
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mydeveloperday at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

The following

clang-format version 10.0.0 (https://github.com/llvm/llvm-project
8b5f6c16476c7a8f50b660fb6e1b549759a783b6)

namespace Foo
{
    [Test]
    public class Bar : Base
    {
        public Bar()
        {
        }
    }

    [Test]
    public class Baz
    {
        public Baz()
        {
        }
    }
}

Gets formatted as:

namespace Foo
{
    [Test]
    public class Bar : Base{ public Bar(){} }

                       [Test]
                       public class Baz
    {
        public Baz()
        {
        }
    }
}


If I remove the ': Base' its fine

namespace Foo
{
    [Test]
    public class Bar
    {
        public Bar()
        {
        }
    }

    [Test]
    public class Baz
    {
        public Baz()
        {
        }
    }
}

This is not the case if the second class 'Baz' does not have an attribute

The smallest example that shows this is

namespace Foo
{
    public class Bar : Base
    {
    }

    [Test]
    public class Baz
    {
        public Baz()
        {
        }
    }
}

With the following .clang-format gives

---
Language: CSharp
BasedOnStyle: Microsoft

IndentWidth:     4
NamespaceIndentation: All
...

namespace Foo
{
public class Bar : Base{}

                   [Test]
                   public class Baz
{
    public Baz()
    {
    }
}
}

-- 
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/20191219/2dad5016/attachment-0001.html>


More information about the llvm-bugs mailing list