[llvm-bugs] [Bug 47461] New: [clang-format][regression] ifdef causes catch to be seen as a function

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 8 08:24:59 PDT 2020


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

            Bug ID: 47461
           Summary: [clang-format][regression] ifdef causes catch to be
                    seen as a function
           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

With .clang-format of

------
Language: Cpp
BasedOnStyle:  LLVM
BreakBeforeBraces: Custom
BraceWrapping:
    AfterFunction: true
-----

The following code

void foo()
{
  try {
  }
  catch (...) {
    // This is not a small function
    bar = 1;
  }

#ifdef NO_EXCEPTIONS
  try
#endif
  {
  }
#ifdef NO_EXCEPTIONS
  catch (...) {
    // This is not a small function
    bar = 1;
  }
#endif
}


The brace after the catch will be formatted differently for the "catch"

void foo()
{
  try {
  } catch (...) {
    // This is not a small function
    bar = 1;
  }

#ifdef NO_EXCEPTIONS
  try
#endif
  {
  }
#ifdef NO_EXCEPTIONS
  catch (...)
  {
    // This is not a small function
    bar = 1;
  }
#endif
}

I suspect it thinks catch(...) is a function as making AfterFunction: false

results in 

#ifdef NO_EXCEPTIONS
  catch (...) {
    // This is not a small function
    bar = 1;
  }
#endif

The (...) is irrelevant

This change seems to be broken from 10.0->11.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/20200908/4c6d3338/attachment.html>


More information about the llvm-bugs mailing list