Skip to content

#ifdef followed by constructor results in wrong code #39230

Closed as not planned
Closed as not planned
@llvmbot

Description

@llvmbot
Bugzilla Link 39883
Version unspecified
OS All
Reporter LLVM Bugzilla Contributor

Extended Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang-formatconfirmedVerified by a second partyobsoleteIssues with old (unsupported) versions of LLVM

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions