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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to