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

            Bug ID: 39883
           Summary: #ifdef followed by constructor results in wrong code
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangb...@nondot.org
          Reporter: s6jas...@uni-bonn.de
                CC: djas...@google.com, kli...@google.com,
                    llvm-bugs@lists.llvm.org

The following code is scrambled after formatting it with clang-format:

namespace a {

class A {
 public:
  void foo() {
#ifdef RANDOM_INIT
    { randomize(); }
#endif
  }

  A() {}
};

} // namespace a

When the constructor "A() { }" or the brackets around "randomize();" are
removed the formatting is as expected. (The brackets are there, because I have
a #pragma for the block.)

clang-format --version
clang-format version 8.0.0 (tags/google/stable/2018-10-04)

Content of .clang-format:

BasedOnStyle: Chromium

Language: Cpp
AlignConsecutiveAssignments: true
AlignOperands: true
FixNamespaceComments: true

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to