Skip to content

Clang format fails to indent on newline if __attribute__((...)) is present between a variable's type and its name #74784

Closed as not planned
@alanzhao1

Description

@alanzhao1

Originally reported on https://crbug.com/1462405

Style: Chromium

clang-format version:

~/src/depot_tools/clang-format --version
clang-format version 18.0.0 (https://chromium.googlesource.com/a/external/github.com/llvm/llvm-project 10664813fca8d5ccbfd90bae9e791b7062dabd7c

clang-format would wrap

RenderWidgetHostViewCocoa* __attribute__((objc_precise_lifetime)) keepSelfAlive = self;

as

RenderWidgetHostViewCocoa* __attribute__((objc_precise_lifetime))
keepSelfAlive = self;

without indenting the second line. This makes it look like the two lines are separate and that keepSelfAlive is being assigned.

Ideally, clang-format should return something like

RenderWidgetHostViewCocoa*
  __attribute__((objc_precise_lifetime)) keepSelfAlive = self;

This reproduces for C++ files as well, not just Objective-C.

Metadata

Metadata

Assignees

Labels

clang-formatobsoleteIssues with old (unsupported) versions of LLVM

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions