cppcoreguidelines-pro-bounds-constant-array-index: ignore implicit constructor
authorMatthias Gehre <M.Gehre@gmx.de>
Tue, 19 Jul 2016 17:02:54 +0000 (17:02 +0000)
committerMatthias Gehre <M.Gehre@gmx.de>
Tue, 19 Jul 2016 17:02:54 +0000 (17:02 +0000)
commitdd117cf01ddc50d53e8133a39b367dc00ece9877
tree3498edd7538c701fd6849da05d22b880feec0a8a
parentf2d02cb0f601fb7b708a4332ca0fd5e9f260e922
cppcoreguidelines-pro-bounds-constant-array-index: ignore implicit constructor

Summary:
The code

  struct A {
    int x[3];
  };

gets an compiler-generated copy constructor that uses ArraySubscriptExpr (see below).
Previously, the check would generate a warning on that copy constructor.
This commit disables the warning on implicitly generated code.
AST:

  |-CXXConstructorDecl 0x337b3c8 <col:8> col:8 implicit used constexpr A 'void (const struct A &) noexcept' inline
  | |-ParmVarDecl 0x337b510 <col:8> col:8 used 'const struct A &'
  | |-CXXCtorInitializer Field 0x3379238 'x' 'int [3]'
  | | `-ImplicitCastExpr 0x337e158 <col:8> 'int' <LValueToRValue>
  | |   `-ArraySubscriptExpr 0x337e130 <col:8> 'const int' lvalue
  | |     |-ImplicitCastExpr 0x337e118 <col:8> 'const int *' <ArrayToPointerDecay>
  | |     | `-MemberExpr 0x337dfc8 <col:8> 'int const[3]' lvalue .x 0x3379238
  | |     |   `-DeclRefExpr 0x337dfa0 <col:8> 'const struct A' lvalue ParmVar 0x337b510 '' 'const struct A &'
  | |     `-ImplicitCastExpr 0x337e098 <col:8> 'unsigned long' <LValueToRValue>
  | |       `-DeclRefExpr 0x337e070 <col:8> 'unsigned long' lvalue Var 0x337e010 '__i0' 'unsigned long'

Reviewers: alexfh, aaron.ballman

Subscribers: aemerson, nemanjai, cfe-commits

Differential Revision: https://reviews.llvm.org/D22381

llvm-svn: 275993
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp