[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 8 06:58:28 PDT 2017


aaron.ballman added inline comments.


================
Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:140
+
+  assert(CheckExecuted == true &&
+         "Non of the subroutines did execute, logic error in matcher!");
----------------
Can assert `CheckExecuted` and drop the explicit equality test.


================
Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:141
+  assert(CheckExecuted == true &&
+         "Non of the subroutines did execute, logic error in matcher!");
+}
----------------
did execute, -> executed;


================
Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:206
+    diag(OwnerInitializer->getSourceLocation(),
+         "expected initializing of owner member variable with value of type "
+         "'gsl::owner<>'; got %0")
----------------
initializing -> intialization


================
Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:303-305
+    // diag(DeclaredOwnerMember->getLocStart(), "declared owner as member here",
+    // DiagnosticIDs::Note)
+    //<< DeclaredOwnerMember->getSourceRange();
----------------
Please remove the commented-out lines.


================
Comment at: test/clang-tidy/cppcoreguidelines-owning-memory.cpp:39
+  return new int(42);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: returning a 'gsl::owner<>' from a function but not declaring it; return type is 'int *'
+}
----------------
This diagnostic confuses me -- there's no gsl::owner<> involved anywhere; am I missing something?


https://reviews.llvm.org/D36354





More information about the cfe-commits mailing list