Skip to content

Presence of .clangd causes editors using clangd to emit incorrect errors #154064

@cbracken

Description

@cbracken

The presence of the current .clangd file at the root of our repo breaks local development workflows on the macOS and iOS embedders (e.g. using clangd editor/IDE integration) because it configures CompileFlags to remove -f* which will, in particular, disable -fobjc-arc causing editors to emit errors on the use of ARC language features such as __weak. I imagine this isn't limited to just the -fobjc-arc flag, so we should probably avoid removing any flags in general and just allow clangd to rely on the default -- i.e. what's specified in compile_commands.json.

Ideally we should delete the checked-in file and have the //tools/clangd_check test itself write the file to that location before running analysis. If we need to have it checked in, we should ensure that it's correct/valid for local development.

Example errors I see when running clangd on the macOS FlutterViewController (similar errors arise for iOS):

  1 shell/platform/darwin/macos/framework/Source/FlutterViewController.mm|6 col 9-96 error| In included file: cannot create __weak reference in file using manual reference counting
  2 shell/platform/darwin/macos/framework/Source/FlutterViewController.mm|21 col 9-97 error| In included file: cannot create __weak reference in file using manual reference counting
  3 shell/platform/darwin/macos/framework/Source/FlutterViewController.mm|252 col 33-44 error| Cannot create __weak reference in file using manual reference counting
  4 shell/platform/darwin/macos/framework/Source/FlutterViewController.mm|260 col 5-16 error| '_controller' is unavailable
  5 shell/platform/darwin/macos/framework/Source/FlutterViewController.mm|278 col 54-65 error| '_controller' is unavailable
  6 shell/platform/darwin/macos/framework/Source/FlutterViewController.mm|360 col 3-9 error| Cannot create __weak reference in file using manual reference counting
  7 shell/platform/darwin/macos/framework/Source/FlutterViewController.mm|454 col 1-2 error| Method possibly missing a [super dealloc] call
  8 shell/platform/darwin/macos/framework/Source/FlutterViewController.mm|574 col 26-32 error| Cannot create __weak reference in file using manual reference counting
  9 shell/platform/darwin/macos/framework/Source/FlutterViewController.mm|903 col 11-28 error| '__bridge_transfer' casts have no effect when not using ARC (fix available)

Related: #141640
Related: #141641

clangd_check was added in:

Metadata

Metadata

Assignees

Labels

c: contributor-productivityTeam-specific productivity, code health, technical debt.e: local-engine-developmentLocal builds of the engine working betterengineflutter/engine related. See also e: labels.platform-iosiOS applications specificallyplatform-macBuilding on or for macOS specificallyteam-engineOwned by Engine team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions