[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Analysis / checker-plugins.c
blob92a48de87f7724d5d49a0978b6618bf2672c3b00
1 // REQUIRES: plugins
3 // FIXME: This test fails on clang-stage2-cmake-RgSan,
4 // see also https://reviews.llvm.org/D62445#1613268
5 // UNSUPPORTED: target={{.*darwin.*}}
7 // RUN: %clang_analyze_cc1 -verify %s \
8 // RUN: -load %llvmshlibdir/SampleAnalyzerPlugin%pluginext \
9 // RUN: -analyzer-checker='example.MainCallChecker'
11 // Test that the MainCallChecker example analyzer plugin loads and runs.
13 int main();
15 void caller() {
16 main(); // expected-warning {{call to main}}
19 // RUN: %clang_analyze_cc1 %s \
20 // RUN: -load %llvmshlibdir/CheckerDependencyHandlingAnalyzerPlugin%pluginext\
21 // RUN: -analyzer-checker=example.DependendentChecker \
22 // RUN: -analyzer-list-enabled-checkers \
23 // RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-IMPLICITLY-ENABLED
25 // CHECK-IMPLICITLY-ENABLED: example.Dependency
26 // CHECK-IMPLICITLY-ENABLED: example.DependendentChecker
28 // RUN: %clang_analyze_cc1 %s \
29 // RUN: -load %llvmshlibdir/CheckerDependencyHandlingAnalyzerPlugin%pluginext\
30 // RUN: -analyzer-checker=example.DependendentChecker \
31 // RUN: -analyzer-disable-checker=example.Dependency \
32 // RUN: -analyzer-list-enabled-checkers \
33 // RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-IMPLICITLY-DISABLED
35 // CHECK-IMPLICITLY-DISABLED-NOT: example.Dependency
36 // CHECK-IMPLICITLY-DISABLED-NOT: example.DependendentChecker
38 // RUN: %clang_analyze_cc1 %s \
39 // RUN: -load %llvmshlibdir/CheckerOptionHandlingAnalyzerPlugin%pluginext\
40 // RUN: -analyzer-checker=example.MyChecker \
41 // RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-CHECKER-OPTION-OUTPUT
43 // CHECK-CHECKER-OPTION-OUTPUT: Example option is set to false
45 // RUN: %clang_analyze_cc1 %s \
46 // RUN: -load %llvmshlibdir/CheckerOptionHandlingAnalyzerPlugin%pluginext\
47 // RUN: -analyzer-checker=example.MyChecker \
48 // RUN: -analyzer-config example.MyChecker:ExampleOption=true \
49 // RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-CHECKER-OPTION-OUTPUT-TRUE
51 // CHECK-CHECKER-OPTION-OUTPUT-TRUE: Example option is set to true
53 // RUN: %clang_analyze_cc1 %s \
54 // RUN: -load %llvmshlibdir/CheckerOptionHandlingAnalyzerPlugin%pluginext\
55 // RUN: -analyzer-checker=example.MyChecker \
56 // RUN: -analyzer-checker=debug.ConfigDumper \
57 // RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-CHECKER-OPTION
59 // CHECK-CHECKER-OPTION: example.MyChecker:ExampleOption = false
61 // RUN: %clang_analyze_cc1 %s \
62 // RUN: -load %llvmshlibdir/CheckerOptionHandlingAnalyzerPlugin%pluginext\
63 // RUN: -analyzer-checker=example.MyChecker \
64 // RUN: -analyzer-checker=debug.ConfigDumper \
65 // RUN: -analyzer-config example.MyChecker:ExampleOption=true \
66 // RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-CHECKER-OPTION-TRUE
68 // CHECK-CHECKER-OPTION-TRUE: example.MyChecker:ExampleOption = true
70 // RUN: not %clang_analyze_cc1 -verify %s \
71 // RUN: -load %llvmshlibdir/CheckerOptionHandlingAnalyzerPlugin%pluginext\
72 // RUN: -analyzer-checker=example.MyChecker \
73 // RUN: -analyzer-config example.MyChecker:Example=true \
74 // RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-NON-EXISTENT-CHECKER-OPTION
76 // CHECK-NON-EXISTENT-CHECKER-OPTION: (frontend): checker 'example.MyChecker'
77 // CHECK-NON-EXISTENT-CHECKER-OPTION-SAME: has no option called 'Example'
79 // RUN: not %clang_analyze_cc1 -verify %s \
80 // RUN: -load %llvmshlibdir/CheckerOptionHandlingAnalyzerPlugin%pluginext\
81 // RUN: -analyzer-checker=example.MyChecker \
82 // RUN: -analyzer-config-compatibility-mode=true \
83 // RUN: -analyzer-config example.MyChecker:Example=true
86 // RUN: not %clang_analyze_cc1 -verify %s \
87 // RUN: -load %llvmshlibdir/CheckerOptionHandlingAnalyzerPlugin%pluginext\
88 // RUN: -analyzer-checker=example.MyChecker \
89 // RUN: -analyzer-config example.MyChecker:ExampleOption=example \
90 // RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-INVALID-BOOL-VALUE
92 // CHECK-INVALID-BOOL-VALUE: (frontend): invalid input for checker option
93 // CHECK-INVALID-BOOL-VALUE-SAME: 'example.MyChecker:ExampleOption', that
94 // CHECK-INVALID-BOOL-VALUE-SAME: expects a boolean value
96 // RUN: not %clang_analyze_cc1 -verify %s \
97 // RUN: -load %llvmshlibdir/CheckerOptionHandlingAnalyzerPlugin%pluginext\
98 // RUN: -analyzer-checker=example.MyChecker \
99 // RUN: -analyzer-config-compatibility-mode=true \
100 // RUN: -analyzer-config example.MyChecker:ExampleOption=example
102 // RUN: %clang_analyze_cc1 %s \
103 // RUN: -load %llvmshlibdir/CheckerOptionHandlingAnalyzerPlugin%pluginext\
104 // RUN: -analyzer-checker=example.MyChecker \
105 // RUN: -analyzer-checker=debug.ConfigDumper \
106 // RUN: -analyzer-config-compatibility-mode=true \
107 // RUN: -analyzer-config example.MyChecker:ExampleOption=example \
108 // RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-CORRECTED-BOOL-VALUE
110 // CHECK-CORRECTED-BOOL-VALUE: example.MyChecker:ExampleOption = false
112 // RUN: %clang_analyze_cc1 %s \
113 // RUN: -load %llvmshlibdir/CheckerOptionHandlingAnalyzerPlugin%pluginext\
114 // RUN: -analyzer-checker=example.MyChecker \
115 // RUN: -analyzer-checker-option-help \
116 // RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-CHECKER-OPTION-HELP
118 // CHECK-CHECKER-OPTION-HELP: example.MyChecker:ExampleOption (bool) This is an
119 // CHECK-CHECKER-OPTION-HELP-SAME: example checker opt. (default:
120 // CHECK-CHECKER-OPTION-HELP-NEXT: false)