This is an archive of the discontinued LLVM Phabricator instance.

cppcoreguidelines-pro-bounds-constant-array-index: ignore implicit constructor
ClosedPublic

Authored by mgehre on Jul 14 2016, 1:35 PM.

Details

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'

Diff Detail

Repository
rL LLVM

Event Timeline

mgehre updated this revision to Diff 64035.Jul 14 2016, 1:35 PM
mgehre retitled this revision from to cppcoreguidelines-pro-bounds-constant-array-index: ignore implicit constructor.
mgehre updated this object.
mgehre added reviewers: alexfh, aaron.ballman.
mgehre added a subscriber: cfe-commits.
alexfh accepted this revision.Jul 19 2016, 6:04 AM
alexfh edited edge metadata.

LG

This revision is now accepted and ready to land.Jul 19 2016, 6:04 AM
This revision was automatically updated to reflect the committed changes.