[PATCH] D117306: [clang-tidy] Add new check 'shared-ptr-array-mismatch'.

Richard via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 16 13:51:08 PST 2022


LegalizeAdulthood added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/misc/SharedPtrArrayMismatchCheck.cpp:21-26
+SharedPtrArrayMismatchCheck::SharedPtrArrayMismatchCheck(
+    StringRef Name, ClangTidyContext *Context)
+    : ClangTidyCheck(Name, Context) {}
+
+void SharedPtrArrayMismatchCheck::storeOptions(
+    ClangTidyOptions::OptionMap &Opts) {}
----------------
If you're not doing anything different in the c'tor I think you can
eliminate this definition and just lift the visibility of the base class
c'tor in the class declaration:
```
using ClangTidyCheck::ClangTidyCheck;
```


================
Comment at: clang-tools-extra/clang-tidy/misc/SharedPtrArrayMismatchCheck.cpp:39
+      cxxConstructExpr(
+          hasDeclaration(UsedConstructor), argumentCountIs(1),
+          hasArgument(0, cxxNewExpr(isArray(), hasType(pointerType(pointee(
----------------
What about the other constructor overloads?
Creating a `shared_ptr` with a deleter is quite common.


================
Comment at: clang-tools-extra/clang-tidy/misc/SharedPtrArrayMismatchCheck.cpp:104
+                                            .getLocalSourceRange();
+    D << TemplateArgumentRange;
+
----------------
I'm not sure what this is doing?


================
Comment at: clang-tools-extra/clang-tidy/misc/SharedPtrArrayMismatchCheck.cpp:106
+
+    if (isInSingleDeclStmt(VarOrField)) {
+      const SourceManager &SM = Ctx.getSourceManager();
----------------
Is this to guard against multiple variables being declared at once?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117306



More information about the cfe-commits mailing list