Home | History | Annotate | Download | only in tests
      1 // Copyright (c) 2012 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 
      5 #ifndef INLINE_CTOR_H_
      6 #define INLINE_CTOR_H_
      7 
      8 #include <string>
      9 #include <vector>
     10 
     11 class InlineCtorsArentOKInHeader {
     12  public:
     13   InlineCtorsArentOKInHeader() {}
     14   ~InlineCtorsArentOKInHeader() {}
     15 
     16  private:
     17   std::vector<int> one_;
     18   std::vector<std::string> two_;
     19 };
     20 
     21 #define INLINE_CTORS_IN_A_MACRO(CLASS_NAME) \
     22   class CLASS_NAME {                        \
     23    public:                                  \
     24     CLASS_NAME() {}                         \
     25     ~CLASS_NAME() {}                        \
     26                                             \
     27    private:                                 \
     28     std::vector<int> one_;                  \
     29     std::vector<std::string> two_;          \
     30   }
     31 INLINE_CTORS_IN_A_MACRO(InlineCtorsBehindAMacroArentOKInHeader);
     32 MACRO_FROM_CPP;
     33 
     34 class DeletedMembersInHeaderAreOKThough {
     35  public:
     36   DeletedMembersInHeaderAreOKThough() = delete;
     37   ~DeletedMembersInHeaderAreOKThough() = delete;
     38   DeletedMembersInHeaderAreOKThough(const DeletedMembersInHeaderAreOKThough&) =
     39       delete;
     40 
     41  private:
     42   std::vector<int> one_;
     43   std::vector<std::string> two_;
     44 };
     45 
     46 class ExplicitlyInlinedIsAlsoOK {
     47   ExplicitlyInlinedIsAlsoOK();
     48   ~ExplicitlyInlinedIsAlsoOK();
     49   ExplicitlyInlinedIsAlsoOK(const ExplicitlyInlinedIsAlsoOK&);
     50 
     51  private:
     52   std::vector<int> one_;
     53   std::vector<std::string> two_;
     54 };
     55 
     56 inline ExplicitlyInlinedIsAlsoOK::ExplicitlyInlinedIsAlsoOK() {
     57 }
     58 
     59 inline ExplicitlyInlinedIsAlsoOK::~ExplicitlyInlinedIsAlsoOK() {
     60 }
     61 
     62 inline ExplicitlyInlinedIsAlsoOK::ExplicitlyInlinedIsAlsoOK(
     63     const ExplicitlyInlinedIsAlsoOK&) {
     64 }
     65 
     66 struct TrivialStruct {
     67   int something_;
     68 };
     69 
     70 struct NonTrivialStruct {
     71   NonTrivialStruct();
     72   ~NonTrivialStruct();
     73 
     74   int something_;
     75 };
     76 
     77 // Plugin doesn't warn about inlining trivial member dtor calls.
     78 struct FourTrivialMembers {
     79   ~FourTrivialMembers();
     80 
     81   TrivialStruct a;
     82   TrivialStruct b;
     83   TrivialStruct c;
     84   TrivialStruct d;
     85 };
     86 
     87 // Plugin doesn't warn about inlining three ctor/dtor calls.
     88 struct ThreeNonTrivialMembers {
     89   NonTrivialStruct a;
     90   NonTrivialStruct b;
     91   NonTrivialStruct c;
     92 };
     93 
     94 // Plugin does warn about inlining four ctor/dtor calls.
     95 struct FourNonTrivialMembers {
     96   NonTrivialStruct a;
     97   NonTrivialStruct b;
     98   NonTrivialStruct c;
     99   NonTrivialStruct d;
    100 };
    101 
    102 #endif  // INLINE_CTOR_H_
    103