20
20
#include " abstract-parser.hh"
21
21
#include " cwe-mapper.hh"
22
22
#include " deflookup.hh"
23
- #include " defqueue.hh"
24
23
#include " gcc-parser.hh"
25
24
#include " instream.hh"
26
25
#include " json-writer.hh"
@@ -141,57 +140,6 @@ void ParsingRulesDecorator::handleDef(const Defect &defOrig)
141
140
agent_->handleDef (def);
142
141
}
143
142
144
- class OrphanWriter {
145
- public:
146
- OrphanWriter (AbstractWriter &writer):
147
- writer_ (writer)
148
- {
149
- }
150
-
151
- bool operator ()(const Defect &def) {
152
- writer_.handleDef (def);
153
- return /* continue */ true ;
154
- }
155
-
156
- private:
157
- AbstractWriter &writer_;
158
- };
159
-
160
- bool writeMappedDefects (
161
- AbstractWriter &writer,
162
- DefQueue &defQueue,
163
- std::istream &input,
164
- const std::string &fName )
165
- {
166
- DefQueryParser qParser (input, fName );
167
- DefQueryParser::QRow row;
168
- while (qParser.getNext (row)) {
169
- Defect def;
170
- if (!defQueue.lookup (def, row.checker , row.fileName )) {
171
- std::cerr
172
- << fName << " : warning: defect lookup failed, cid = "
173
- << row.cid << " \n " ;
174
-
175
- DefEvent evt;
176
- evt.fileName = row.fileName ;
177
- evt.event = " defect_lookup_failed" ;
178
- evt.msg = " unmatched defect in " ;
179
- evt.msg += row.fnc ;
180
-
181
- def = Defect ();
182
- def.checker = row.checker ;
183
- def.events .push_back (evt);
184
- }
185
-
186
- def.defectId = row.cid ;
187
- def.function = row.fnc ;
188
- writer.handleDef (def);
189
- }
190
-
191
- OrphanWriter visitor (writer);
192
- return defQueue.walk (visitor);
193
- }
194
-
195
143
template <class TVal , class TVar >
196
144
inline TVal valueOf (const TVar &var)
197
145
{
@@ -221,8 +169,6 @@ int main(int argc, char *argv[])
221
169
" mark reports from the specified list as important" )
222
170
(" inifile" , po::value<string>(),
223
171
" load scan properties from the given INI file" )
224
- (" mapfile" , po::value<string>(),
225
- " load defect IDs from comma-separated mapfile" )
226
172
(" reapply-parsing-rules" , " canonicalize data originally parsed "
227
173
" by an older version of the parser" )
228
174
(" quiet,q" , " do not report non-fatal errors" )
@@ -263,7 +209,6 @@ int main(int argc, char *argv[])
263
209
const string fnCwe = valueOf<string>(vm[" cwelist" ]);
264
210
const string fnImp = valueOf<string>(vm[" implist" ]);
265
211
const string fnIni = valueOf<string>(vm[" inifile" ]);
266
- const string fnMap = valueOf<string>(vm[" mapfile" ]);
267
212
const bool silent = vm.count (" quiet" );
268
213
269
214
const po::variables_map::const_iterator it = vm.find (" input-file" );
@@ -283,8 +228,6 @@ int main(int argc, char *argv[])
283
228
if (vm.count (" reapply-parsing-rules" ))
284
229
writer = new ParsingRulesDecorator (writer);
285
230
286
- DefQueue defQueue;
287
-
288
231
bool hasError = false ;
289
232
290
233
if (!fnCwe.empty ()) {
@@ -336,16 +279,8 @@ int main(int argc, char *argv[])
336
279
hasError = true ;
337
280
}
338
281
339
- if (fnMap.empty ()) {
340
- // no .map file given
341
- writer->handleFile (pErr, fnErr);
342
- }
343
- else {
344
- // load defects from .err
345
- Defect def;
346
- while (pErr.getNext (&def))
347
- defQueue.hashDefect (def);
348
- }
282
+ // process a single input file
283
+ writer->handleFile (pErr, fnErr);
349
284
350
285
hasError |= pErr.hasError ();
351
286
}
@@ -355,19 +290,6 @@ int main(int argc, char *argv[])
355
290
}
356
291
}
357
292
358
- if (!fnMap.empty ()) {
359
- try {
360
- // process the given .map file
361
- InStream strMap (fnMap.c_str ());
362
- if (!writeMappedDefects (*writer, defQueue, strMap.str (), fnMap))
363
- hasError = true ;
364
- }
365
- catch (const InFileException &e) {
366
- printError (e);
367
- hasError = true ;
368
- }
369
- }
370
-
371
293
writer->flush ();
372
294
delete writer;
373
295
return hasError;
0 commit comments