reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
  140
  141
  142
  143
  144
  145
  146
  147
  148
  149
  150
// RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.UninitializedObject \
// RUN:   -analyzer-config optin.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \
// RUN:   -analyzer-config optin.cplusplus.UninitializedObject:IgnoreRecordsWithField="[Tt]ag|[Kk]ind" \
// RUN:   -std=c++11 -verify  %s

// RUN: not %clang_analyze_cc1 -verify %s \
// RUN:   -analyzer-checker=core \
// RUN:   -analyzer-checker=optin.cplusplus.UninitializedObject \
// RUN:   -analyzer-config \
// RUN:     optin.cplusplus.UninitializedObject:IgnoreRecordsWithField="([)]" \
// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-UNINIT-INVALID-REGEX

// CHECK-UNINIT-INVALID-REGEX: (frontend): invalid input for checker option
// CHECK-UNINIT-INVALID-REGEX-SAME: 'optin.cplusplus.UninitializedObject:IgnoreRecordsWithField',
// CHECK-UNINIT-INVALID-REGEX-SAME: that expects a valid regex, building failed
// CHECK-UNINIT-INVALID-REGEX-SAME: with error message "parentheses not
// CHECK-UNINIT-INVALID-REGEX-SAME: balanced"


// expected-no-diagnostics

// Both type and name contains "kind".
struct UnionLikeStruct1 {
  enum Kind {
    volume,
    area
  } kind;

  int Volume;
  int Area;

  UnionLikeStruct1(Kind kind, int Val) : kind(kind) {
    switch (kind) {
    case volume:
      Volume = Val;
      break;
    case area:
      Area = Val;
      break;
    }
  }
};

void fUnionLikeStruct1() {
  UnionLikeStruct1 t(UnionLikeStruct1::volume, 10);
}

// Only name contains "kind".
struct UnionLikeStruct2 {
  enum Type {
    volume,
    area
  } kind;

  int Volume;
  int Area;

  UnionLikeStruct2(Type kind, int Val) : kind(kind) {
    switch (kind) {
    case volume:
      Volume = Val;
      break;
    case area:
      Area = Val;
      break;
    }
  }
};

void fUnionLikeStruct2() {
  UnionLikeStruct2 t(UnionLikeStruct2::volume, 10);
}

// Only type contains "kind".
struct UnionLikeStruct3 {
  enum Kind {
    volume,
    area
  } type;

  int Volume;
  int Area;

  UnionLikeStruct3(Kind type, int Val) : type(type) {
    switch (type) {
    case volume:
      Volume = Val;
      break;
    case area:
      Area = Val;
      break;
    }
  }
};

void fUnionLikeStruct3() {
  UnionLikeStruct3 t(UnionLikeStruct3::volume, 10);
}

// Only type contains "tag".
struct UnionLikeStruct4 {
  enum Tag {
    volume,
    area
  } type;

  int Volume;
  int Area;

  UnionLikeStruct4(Tag type, int Val) : type(type) {
    switch (type) {
    case volume:
      Volume = Val;
      break;
    case area:
      Area = Val;
      break;
    }
  }
};

void fUnionLikeStruct4() {
  UnionLikeStruct4 t(UnionLikeStruct4::volume, 10);
}

// Both name and type name contains but does not equal to tag/kind.
struct UnionLikeStruct5 {
  enum WhateverTagBlahBlah {
    volume,
    area
  } FunnyKindName;

  int Volume;
  int Area;

  UnionLikeStruct5(WhateverTagBlahBlah type, int Val) : FunnyKindName(type) {
    switch (FunnyKindName) {
    case volume:
      Volume = Val;
      break;
    case area:
      Area = Val;
      break;
    }
  }
};

void fUnionLikeStruct5() {
  UnionLikeStruct5 t(UnionLikeStruct5::volume, 10);
}