diff options
author | Hans Wennborg <hans@hanshq.net> | 2019-02-07 11:04:04 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2019-02-07 11:04:04 +0000 |
commit | ed4e2ec42201e8e3c9164993d3f1b52b5d5a3951 (patch) | |
tree | 2991d4df3a302d349145bae2faed562d793b2194 /test/clang-tidy/modernize-avoid-c-arrays-ignores-main.cpp | |
parent | f41725ff15ce6971838ae569afa25f05283ab5fc (diff) |
Merging r353327:
------------------------------------------------------------------------
r353327 | lebedevri | 2019-02-06 20:17:30 +0100 (Wed, 06 Feb 2019) | 18 lines
[clang-tidy] modernize-avoid-c-arrays: avoid main function (PR40604)
Summary:
The check should ignore the main function, the program entry point.
It is not possible to use `std::array<>` for the `argv`.
The alternative is to use `char** argv`.
Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=40604 | PR40604 ]]
Reviewers: JonasToth, aaron.ballman
Reviewed By: aaron.ballman
Subscribers: xazax.hun, hans, cfe-commits
Tags: #clang-tools-extra, #clang
Differential Revision: https://reviews.llvm.org/D57787
------------------------------------------------------------------------
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/branches/release_80@353391 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/clang-tidy/modernize-avoid-c-arrays-ignores-main.cpp')
-rw-r--r-- | test/clang-tidy/modernize-avoid-c-arrays-ignores-main.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/clang-tidy/modernize-avoid-c-arrays-ignores-main.cpp b/test/clang-tidy/modernize-avoid-c-arrays-ignores-main.cpp new file mode 100644 index 00000000..6549422f --- /dev/null +++ b/test/clang-tidy/modernize-avoid-c-arrays-ignores-main.cpp @@ -0,0 +1,18 @@ +// RUN: %check_clang_tidy %s modernize-avoid-c-arrays %t + +int not_main(int argc, char *argv[]) { + // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: do not declare C-style arrays, use std::array<> instead + int f4[] = {1, 2}; + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use std::array<> instead +} + +int main(int argc, char *argv[]) { + int f5[] = {1, 2}; + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use std::array<> instead + + auto not_main = [](int argc, char *argv[]) { + // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: do not declare C-style arrays, use std::array<> instead + int f6[] = {1, 2}; + // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not declare C-style arrays, use std::array<> instead + }; +} |