[llvm-bugs] [Bug 44537] New: incorrect formatting of class in function

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jan 14 02:01:25 PST 2020


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

            Bug ID: 44537
           Summary: incorrect formatting of class in function
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: janwilmans at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

- When a class is used inside a function
- And it inherits from a base class
- And its immediately used

The formatting is really odd, notice
- the mismatched braces of OnTaskExecute
- the mis-alignment of OnTaskAttach
- the incorrect placement of // namespace Foo (its on the wrong closing curly)


Before format:

namespace Foo{

void Bar( const char *Text, const char *Title )
{
        class MyErrorBox :
                public ErrorBox,
                public Foo::CTask::Client
        {
        public:
                MyErrorBox(const char *Text, const char *Title) :
                        ErrorBox(Text, Title)
                {}

                void OnTaskExecute(const Foo::CTask *pTask, Foo::uintptr vlaue)
override
                {
                        ErrorBox::OnTaskExecute(pTask, vlaue);
                }
                void OnTaskAttach(const Foo::CTask *, bool attach) override
                {
                        if (!attach) delete this;
                }
        } *pBox = new MyErrorBox(Text, Title);

}

}

After format:

namespace Foo {

void Bar(const char * Text, const char * Title)
{
    class MyErrorBox : public ErrorBox,
                       public Foo::CTask::Client{
                           public:
                               MyErrorBox(const char * Text, const char *
Title):
                                   ErrorBox(Text, Title){}

                           void OnTaskExecute(const Foo::CTask * pTask,
Foo::uintptr vlaue) override{
                               ErrorBox::OnTaskExecute(pTask, vlaue);
}
void OnTaskAttach(const Foo::CTask *, bool attach) override
{
    if (!attach)
        delete this;
}
} // namespace Foo
*pBox = new MyErrorBox(Text, Title);
}
}

-- 
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/20200114/0d07726a/attachment-0001.html>


More information about the llvm-bugs mailing list