[PATCH] D106431: [clang-tidy] Fix cppcoreguidelines-init-variables by removing the enum FixIt, and add support for initialization check of scoped enum.

Whisperity via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 29 00:36:02 PDT 2021


whisperity added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp:85
+  if (TypePtr->isEnumeralType())
+    InitializationString = "";
+  else if (TypePtr->isIntegerType())
----------------
whisperity wrote:
> Also, if we're using //Optional//, this could also be `= nullptr` instead, and then we have the state when the //Optional// `hasValue()` but the value itself is null. In all other cases, it //both// `hasValue()` and the value is non-null.
> This would also eliminate the need for the `strlen` call.
In the StringRef case, you'd need to `emplace` a default-constructed StringRef (which has the semantics of not pointing anywhere and having length 0) into the Optional. 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106431/new/

https://reviews.llvm.org/D106431



More information about the cfe-commits mailing list