clang-tidy v. -Weffc++

Abierto
#54 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
30/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
cpp
Área
tooling

Línea de trabajo

Comience con la documentación de clang-tidy's readability-redundant-member-init y las discusiones enlazadas mapbox/cpp#37, wagyu#69 y wagyu#70; no se identifica ningún archivo ni prueba del repositorio. Determine un enfoque acordado para -Weffc++, las indicaciones de clang-tidy y la detección de miembros no inicializados; se considerará terminado cuando haya una recomendación y una configuración documentadas.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Context

Recent versions of clang-tidy added readability-redundant-member-init: https://clang.llvm.org/extra/clang-tidy/checks/readability-redundant-member-init.html

This is handy! When a class member has a default initializer it is redundent to initialize it in the member list.

But, because some types don't have default initializers, forgetting to initialize them in the member list (or using c++11 initialization in the class definition) can lead to serious trouble like mapbox/wagyu#69 - refs mapbox/wagyu#70.

So, this is the reason, at https://github.com/mapbox/cpp/issues/37#issuecomment-336200744, that we recommend using g++ and the -Weffc++ flag because it can catch this (note, clang++ plus -Weffc++ cannot):

-Weffc++ - useful when building with g++ (does not do much with clang++). With g++ it can catch uninitialized class members and prevent crashes like mapbox/wagyu#69 - refs mapbox/wagyu#70

Problem

  • -Weffc++ will warn on all class members not explicitly initialized in the initializer list
  • clang-tidy will automatically remove variables from the initializer list that have default constructors

So, the two will fight: causing each other warnings. For this reason I think we should likely:

  • let clang-tidy win
  • recommend no longer using g++ with -Weffc++
  • figure out what alternative way we can catch when members, without default initializers, are uninitialized (without needing to use -Weffc++). Maybe another clang-tidy check?
Lenguaje dominante
Sin datos de lenguaje
Estrellas
110
Forks
17
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de mapbox/cpp

Todos los issues de mapbox/cpp

Issues similares

Más issues de DevTools

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.