[PATCH] D61350: [clang-tidy] New check calling out uses of +new in Objective-C code

Eugene Zelenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 1 16:55:30 PDT 2019


Eugene.Zelenko added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/google/AvoidNSObjectNewCheck.cpp:16
+#include "llvm/Support/FormatVariadic.h"
+
+#include <map>
----------------
Unnecessary empty line.


================
Comment at: clang-tools-extra/clang-tidy/google/AvoidNSObjectNewCheck.cpp:29
+  SourceLocation ReceiverLocation = Expr->getReceiverRange().getBegin();
+  if (ReceiverLocation.isMacroID()) {
+    return true;
----------------
Please elide braces.


================
Comment at: clang-tools-extra/clang-tidy/google/AvoidNSObjectNewCheck.cpp:34
+  SourceLocation SelectorLocation = Expr->getSelectorStartLoc();
+  if (SelectorLocation.isMacroID()) {
+    return true;
----------------
Please elide braces.


================
Comment at: clang-tools-extra/clang-tidy/google/AvoidNSObjectNewCheck.cpp:46
+    for (const auto *MethodDecl : ClassDecl->instance_methods()) {
+      if (MethodDecl->getSelector().getAsString() == "init") {
+        return !MethodDecl->isUnavailable();
----------------
Please elide braces.


================
Comment at: clang-tools-extra/clang-tidy/google/AvoidNSObjectNewCheck.cpp:94
+
+  return FixItHint(); // No known replacement available.
+}
----------------
You could return {}


================
Comment at: clang-tools-extra/clang-tidy/google/AvoidNSObjectNewCheck.cpp:115
+    // Don't warn if the call expression originates from a macro expansion.
+    if (isMessageExpressionInsideMacro(CallExpr)) {
+      return;
----------------
Please elide braces.


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/google-objc-avoid-nsobject-new.rst:27
+
+The corresponding style guide rule:
+https://google.github.io/styleguide/objcguide.html#do-not-use-new
----------------
I think you could format link in cert-env33-c.rst style.


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

https://reviews.llvm.org/D61350





More information about the cfe-commits mailing list