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

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

Reply via email to