Clang Project

clang_source_code/test/Analysis/plist-diagnostics-template-record.cpp
1// RUN: %clang_analyze_cc1 -analyzer-output=plist -o %t.plist -std=c++11 -analyzer-checker=core %s
2// RUN: FileCheck --input-file=%t.plist %s
3
4bool ret();
5
6template <class A, class B, class C, int N>
7struct DivByZero {
8  int i;
9  DivByZero(bool b) {
10    if (ret())
11      i = 50 / (b - 1);
12  }
13};
14
15template <class B, class C, int N>
16struct DivByZero<char, B, C, N> {
17  int i;
18  DivByZero(bool b) {
19    if (ret())
20      i = 50 / (b - 1);
21  }
22};
23
24template <typename... Args>
25struct DivByZeroVariadic {
26  int i;
27  DivByZeroVariadic(bool b) {
28    if (ret())
29      i = 50 / (b - 1);
30  }
31};
32
33int main() {
34  DivByZero<int, float, double, 0> a(1);
35  DivByZero<char, float, double, 0> a2(1);
36  DivByZeroVariadic<char, float, double, decltype(nullptr)> a3(1);
37}
38
39// CHECK:      <string>Calling constructor for &apos;DivByZero&lt;int, float, double, 0&gt;&apos;</string>
40// CHECK:      <string>Calling constructor for &apos;DivByZero&lt;char, float, double, 0&gt;&apos;</string>
41// CHECK:      <string>Calling constructor for &apos;DivByZeroVariadic&lt;char, float, double, nullptr_t&gt;&apos;</string>
42
43