Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@cbracken
Copy link
Member

This updates local variable names to use clang lower_case style in the fml directory. This is one of several patches to update our variable names to a consistent style before enabling enforcement in our clang-tidy rules.

This is a formatting-only change with no intended semantic change.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

static std::atomic_size_t gLastItem;
return ++gLastItem;
static std::atomic_size_t last_item;
return ++last_item;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't seem to be consistent with scoped statics -- i.e. whether we name them the same as globals within global scope and add a g prefix, or name them the same as locals. There are semantic differences to both. Personally I think it's pretty clear that it's static, at least in this case. My guess is that most cases of function-local statics are similarly concise.

clang-tidy does support specifying static local/field formatting/prefixes if we want to give these special treatment. Opinions?

Copy link
Member Author

@cbracken cbracken Sep 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For static const we consistently tend to prefix as kFooBar.

For static fields it looks like typically we don't prefix:

  • common/graphics/persistent_cache.h:145: static std::atomic cache_sksl_;
  • common/graphics/persistent_cache.h:149: static std::atomic strategy_set_;
  • display_list/display_list_complexity_metal.h:95: static DisplayListMetalComplexityCalculator* instance_;

For static locals I see a mix:

  • display_list/display_list_unittests.cc:684: static DisplayListBuilder builder;
  • flow/flow_test_utils.cc:9:static std::string gGoldenDir;
  • flow/flow_test_utils.cc:10:static std::string gFontFile;
  • impeller/aiks/aiks_unittests.cc:121: static float alpha = 1.0;
  • impeller/aiks/aiks_unittests.cc:133: static Matrix matrix = {
  • impeller/display_list/display_list_unittests.cc:344: static bool draw_circle = true;
  • impeller/display_list/display_list_unittests.cc:345: static bool add_clip = true;

Looks like most code doesn't prefix with g when I grep with git grep 'static '|grep -v 'static const' | grep -v '('

This updates local variable names to use clang `lower_case` style in the
fml directory. This is one of several patches to update our variable
names to a consistent style before enabling enforcement in our
clang-tidy rules.

This is a formatting-only change with no intended semantic change.
@cbracken cbracken merged commit e0ae83f into flutter:main Sep 14, 2022
@cbracken cbracken deleted the fix-locals-fml branch September 14, 2022 22:47
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 15, 2022
Oleh-Sv pushed a commit to Oleh-Sv/engine that referenced this pull request Sep 28, 2022
)

This updates local variable names to use clang `lower_case` style in the
fml directory. This is one of several patches to update our variable
names to a consistent style before enabling enforcement in our
clang-tidy rules.

This is a formatting-only change with no intended semantic change.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants