@@ -107,14 +107,6 @@ void addBranchConditionTester(AnalysisASTConsumer &AnalysisConsumer,
107
107
});
108
108
}
109
109
110
- // / Add this to the \c runChecker template arguments to enable dumping the CFG
111
- // / and the ExplodedGraph for debugging a failing test case.
112
- [[maybe_unused]] void dumpCFGAndEgraph (AnalysisASTConsumer &AnalysisConsumer,
113
- AnalyzerOptions &AnOpts) {
114
- AnOpts.CheckersAndPackages .emplace_back (" debug.DumpCFG" , true );
115
- AnOpts.CheckersAndPackages .emplace_back (" debug.ViewExplodedGraph" , true );
116
- }
117
-
118
110
llvm::SmallVector<StringRef> parseEachDiag (StringRef Diags) {
119
111
llvm::SmallVector<StringRef> Fragments;
120
112
llvm::SplitString (Diags, Fragments, " \n " );
@@ -137,6 +129,19 @@ bool runChecker(const std::string &Code, std::string &Diags) {
137
129
return Res;
138
130
}
139
131
132
+ [[maybe_unused]] void dumpCFGAndEgraph (AnalysisASTConsumer &AnalysisConsumer,
133
+ AnalyzerOptions &AnOpts) {
134
+ AnOpts.CheckersAndPackages .emplace_back (" debug.DumpCFG" , true );
135
+ AnOpts.CheckersAndPackages .emplace_back (" debug.ViewExplodedGraph" , true );
136
+ }
137
+
138
+ // / Use this instead of \c runChecker to enable the debugging a test case.
139
+ template <AddCheckerFn... Fns>
140
+ [[maybe_unused]] bool debugChecker (const std::string &Code,
141
+ std::string &Diags) {
142
+ return runChecker<dumpCFGAndEgraph, Fns...>(Code, Diags);
143
+ }
144
+
140
145
std::string expected (SmallVector<StringRef> Diags) {
141
146
llvm::sort (Diags);
142
147
std::string Result;
@@ -152,6 +157,7 @@ TEST(BlockEntranceTester, FromEntryToExit) {
152
157
})cpp" ;
153
158
154
159
std::string Diags;
160
+ // Use "debugChecker" instead of "runChecker" for debugging.
155
161
EXPECT_TRUE (runChecker (Code, Diags));
156
162
EXPECT_EQ (expected ({" Within 'top' B1 -> B0" }), Diags);
157
163
}
@@ -170,6 +176,7 @@ TEST(BlockEntranceTester, SingleOpaqueIfCondition) {
170
176
})cpp" ;
171
177
172
178
std::string Diags;
179
+ // Use "debugChecker" instead of "runChecker" for debugging.
173
180
EXPECT_TRUE (runChecker (Code, Diags));
174
181
EXPECT_EQ (expected ({
175
182
" Within 'top' B1 -> B0" ,
@@ -203,6 +210,7 @@ TEST(BlockEntranceTester, TrivialIfCondition) {
203
210
})cpp" ;
204
211
205
212
std::string Diags;
213
+ // Use "debugChecker" instead of "runChecker" for debugging.
206
214
EXPECT_TRUE (runChecker (Code, Diags));
207
215
EXPECT_EQ (expected ({
208
216
" Within 'top' B1 -> B0" ,
@@ -227,6 +235,7 @@ TEST(BlockEntranceTester, AcrossFunctions) {
227
235
})cpp" ;
228
236
229
237
std::string Diags;
238
+ // Use "debugChecker" instead of "runChecker" for debugging.
230
239
EXPECT_TRUE (runChecker (Code, Diags));
231
240
EXPECT_EQ (
232
241
expected ({
@@ -273,6 +282,7 @@ TEST(BlockEntranceTester, ShortCircuitingLogicalOperator) {
273
282
// (v = x): false
274
283
275
284
std::string Diags;
285
+ // Use "debugChecker" instead of "runChecker" for debugging.
276
286
EXPECT_TRUE (runChecker (Code, Diags));
277
287
EXPECT_EQ (expected ({
278
288
" Within 'top' B1 -> B0" ,
@@ -313,6 +323,7 @@ TEST(BlockEntranceTester, Switch) {
313
323
// +----+
314
324
315
325
std::string Diags;
326
+ // Use "debugChecker" instead of "runChecker" for debugging.
316
327
EXPECT_TRUE (runChecker (Code, Diags));
317
328
EXPECT_EQ (expected ({
318
329
" Within 'top' B1 -> B0" ,
@@ -341,6 +352,7 @@ TEST(BlockEntranceTester, BlockEntranceVSBranchCondition) {
341
352
return v;
342
353
})cpp" ;
343
354
std::string Diags;
355
+ // Use "debugChecker" instead of "runChecker" for debugging.
344
356
EXPECT_TRUE ((runChecker<addBlockEntranceTester, addBranchConditionTester>(
345
357
Code, Diags)));
346
358
EXPECT_EQ (expected ({
0 commit comments