Skip to content

Commit

Permalink
ci: enable check for static non-POD (envoyproxy#5602)
Browse files Browse the repository at this point in the history
Check global static non-POD in clang-tidy to avoid static initialization fiasco.
https://clang.llvm.org/extra/clang-tidy/checks/fuchsia-statically-constructed-objects.html

Risk Level: Low

Signed-off-by: Lizan Zhou <lizan@tetrate.io>
  • Loading branch information
lizan authored and htuch committed Jan 27, 2019
1 parent b51f1e4 commit 3e5b286
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Checks: 'clang-diagnostic-*,clang-analyzer-*,abseil-*,bugprone-*,modernize-*,performance-*,readability-redundant-*,readability-braces-around-statements'
Checks: 'clang-diagnostic-*,clang-analyzer-*,abseil-*,bugprone-*,modernize-*,performance-*,readability-redundant-*,readability-braces-around-statements,fuchsia-statically-constructed-objects'

#TODO(lizan): grow this list, fix possible warnings and make more checks as error
WarningsAsErrors: 'bugprone-assert-side-effect,modernize-make-shared,modernize-make-unique,readability-redundant-smartptr-get,readability-braces-around-statements,readability-redundant-string-cstr,bugprone-use-after-move'
WarningsAsErrors: 'bugprone-assert-side-effect,modernize-make-shared,modernize-make-unique,readability-redundant-smartptr-get,readability-braces-around-statements,readability-redundant-string-cstr,bugprone-use-after-move,fuchsia-statically-constructed-objects'

CheckOptions:
- key: bugprone-assert-side-effect.AssertMacros
Expand Down
8 changes: 5 additions & 3 deletions include/envoy/singleton/manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ template <const char* name_param> class RegistrationImpl : public Registration {
*/
#define SINGLETON_MANAGER_REGISTRATION(NAME) \
static constexpr char NAME##_singleton_name[] = #NAME "_singleton"; \
static Envoy::Registry::RegisterFactory< \
Envoy::Singleton::RegistrationImpl<NAME##_singleton_name>, Envoy::Singleton::Registration> \
NAME##_singleton_registered_;
static Envoy::Registry:: \
RegisterFactory</* NOLINT(fuchsia-statically-constructed-objects) */ \
Envoy::Singleton::RegistrationImpl<NAME##_singleton_name>, \
Envoy::Singleton::Registration> \
NAME##_singleton_registered_;

#define SINGLETON_MANAGER_REGISTERED_NAME(NAME) NAME##_singleton_name

Expand Down

0 comments on commit 3e5b286

Please sign in to comment.