clang-tidy v. -Weffc++
還沒有人認領這個 Issue。
- 主要語言
- 沒有語言資料
- 星號
- 110
- 分支
- 17
- PR 合併指標
- 30 天內沒有已合併 PR
描述
## 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](https://arne-mertz.de/2015/08/new-c-features-default-initializers-for-member-variables/)) 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?
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 clang-tidy's readability-redundant-member-init 文件以及連結的 mapbox/cpp#37、wagyu#69 和 wagyu#70 討論開始;未識別任何 repository 檔案或測試。確定針對 -Weffc++、clang-tidy 指南以及偵測未初始化成員的共識方案;完成條件是提出有文件記錄的建議和設定。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- cpp
- 領域
- tooling
- Issue 類型
- 功能
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 30/100