njames93 added a comment.

Why limit this to just the value type traits, makes sense to also support type 
type traits.



================
Comment at: clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp:73
+    const auto *RecordQualifier =
+        cast_if_present<ClassTemplateSpecializationDecl>(
+            Qualifier->getAsRecordDecl());
----------------
Won't this assert if a pointer is supplied but it isn't a 
ClassTemplateSpecializationDefl. Wouldn't dyn_cast be needed.
In any case a test where you access a static variable from a non template class 
needs adding to make sure no warning is emitter.


================
Comment at: clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp:82
+    auto IssuedDiag =
+        diag(MatchedDecl->getSourceRange().getEnd(), "C++11-style type trait");
+
----------------
Make the diagnostic a bit clearer.


================
Comment at: clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp:86
+    auto CurrentText = tooling::fixit::getText(*MatchedDecl, *Result.Context);
+    if (replacement_regex.match(CurrentText))
+      IssuedDiag << FixItHint::CreateReplacement(
----------------
This fixit logic looks cumbersome, just replace the qualifier loc(::)to the 
declared with an `_v`. But only iff the qualified name loc is not a macro.


================
Comment at: clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.h:34
+private:
+  std::set<StringRef> ValueTypeTraits;
+};
----------------
We don't need an ordering here, so an llvm::DenseSet<StringRef> may be more 
suited here.


================
Comment at: 
clang-tools-extra/docs/clang-tidy/checks/modernize/type-traits.rst:28
+
+.. option:: ValueTypeTraits
+
----------------
I'm not sure this option would ever be used in the wild as it would override 
all the default values in the stl.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135404

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to