[PATCH] D57787: [clang-tidy] modernize-avoid-c-arrays: avoid main function (PR40604)

Jonas Toth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 5 23:33:28 PST 2019


JonasToth added inline comments.


================
Comment at: clang-tidy/modernize/AvoidCArraysCheck.cpp:35
+  const clang::DeclContext *DC = Node.getDeclContext();
+  const clang::FunctionDecl *FD = llvm::dyn_cast<clang::FunctionDecl>(DC);
+  if (!FD)
----------------
There is `FunctionDecl->castToDeclContext()` which is probably a better fit here.


================
Comment at: test/clang-tidy/modernize-avoid-c-arrays.cpp:90
+
+int not_main(int argc, char *argv[]) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: do not declare C-style arrays, use std::array<> instead
----------------
`main` has a third optional argument for environment variables. Please add test case for that, too.
Could add a test for the `char **argv`-form to ensure these are not ignored somehow?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57787





More information about the cfe-commits mailing list