2020#include " abstract-parser.hh"
2121#include " cwe-mapper.hh"
2222#include " deflookup.hh"
23- #include " defqueue.hh"
2423#include " gcc-parser.hh"
2524#include " instream.hh"
2625#include " json-writer.hh"
@@ -141,57 +140,6 @@ void ParsingRulesDecorator::handleDef(const Defect &defOrig)
141140 agent_->handleDef (def);
142141}
143142
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-
195143template <class TVal , class TVar >
196144inline TVal valueOf (const TVar &var)
197145{
@@ -221,8 +169,6 @@ int main(int argc, char *argv[])
221169 " mark reports from the specified list as important" )
222170 (" inifile" , po::value<string>(),
223171 " load scan properties from the given INI file" )
224- (" mapfile" , po::value<string>(),
225- " load defect IDs from comma-separated mapfile" )
226172 (" reapply-parsing-rules" , " canonicalize data originally parsed "
227173 " by an older version of the parser" )
228174 (" quiet,q" , " do not report non-fatal errors" )
@@ -263,7 +209,6 @@ int main(int argc, char *argv[])
263209 const string fnCwe = valueOf<string>(vm[" cwelist" ]);
264210 const string fnImp = valueOf<string>(vm[" implist" ]);
265211 const string fnIni = valueOf<string>(vm[" inifile" ]);
266- const string fnMap = valueOf<string>(vm[" mapfile" ]);
267212 const bool silent = vm.count (" quiet" );
268213
269214 const po::variables_map::const_iterator it = vm.find (" input-file" );
@@ -283,8 +228,6 @@ int main(int argc, char *argv[])
283228 if (vm.count (" reapply-parsing-rules" ))
284229 writer = new ParsingRulesDecorator (writer);
285230
286- DefQueue defQueue;
287-
288231 bool hasError = false ;
289232
290233 if (!fnCwe.empty ()) {
@@ -336,16 +279,8 @@ int main(int argc, char *argv[])
336279 hasError = true ;
337280 }
338281
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);
349284
350285 hasError |= pErr.hasError ();
351286 }
@@ -355,19 +290,6 @@ int main(int argc, char *argv[])
355290 }
356291 }
357292
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-
371293 writer->flush ();
372294 delete writer;
373295 return hasError;
0 commit comments