missing_ctor.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef MISSING_CTOR_H_
  5. #define MISSING_CTOR_H_
  6. struct MyString {
  7. MyString();
  8. ~MyString();
  9. MyString(const MyString&);
  10. MyString(MyString&&);
  11. };
  12. template <class T>
  13. struct MyVector {
  14. MyVector();
  15. ~MyVector();
  16. MyVector(const MyVector&);
  17. MyVector(MyVector&&);
  18. };
  19. // Note: this should warn for an implicit copy constructor too, but currently
  20. // doesn't, due to a plugin bug.
  21. class MissingCtorsArentOKInHeader {
  22. public:
  23. private:
  24. MyVector<int> one_;
  25. MyVector<MyString> two_;
  26. };
  27. // Inline move ctors shouldn't be warned about. Similar to the previous test
  28. // case, this also incorrectly fails to warn for the implicit copy ctor.
  29. class InlineImplicitMoveCtorOK {
  30. public:
  31. InlineImplicitMoveCtorOK();
  32. private:
  33. // ctor weight = 12, dtor weight = 9.
  34. MyString one_;
  35. MyString two_;
  36. MyString three_;
  37. int four_;
  38. int five_;
  39. int six_;
  40. };
  41. class ExplicitlyDefaultedInlineAlsoWarns {
  42. public:
  43. ExplicitlyDefaultedInlineAlsoWarns() = default;
  44. ~ExplicitlyDefaultedInlineAlsoWarns() = default;
  45. ExplicitlyDefaultedInlineAlsoWarns(
  46. const ExplicitlyDefaultedInlineAlsoWarns&) = default;
  47. private:
  48. MyVector<int> one_;
  49. MyVector<MyString> two_;
  50. };
  51. union UnionDoesNotWarn {
  52. UnionDoesNotWarn() = default;
  53. UnionDoesNotWarn(const UnionDoesNotWarn& other) = default;
  54. int a;
  55. int b;
  56. int c;
  57. int d;
  58. int e;
  59. int f;
  60. int g;
  61. int h;
  62. int i;
  63. int j;
  64. int k;
  65. int l;
  66. int m;
  67. int n;
  68. int o;
  69. int p;
  70. int q;
  71. int r;
  72. int s;
  73. int t;
  74. int u;
  75. int v;
  76. int w;
  77. int x;
  78. int y;
  79. int z;
  80. };
  81. #endif // MISSING_CTOR_H_