| author | noe\swadi |
| Mon, 26 Apr 2010 16:28:13 +0530 | |
| changeset 3 | ebe3f8f03b59 |
| parent 0 | 638b9c697799 |
| child 12 | a0eee409ff14 |
| permissions | -rw-r--r-- |
| 0 | 1 |
/* |
2 |
* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#include "CmdGlobals.h" |
|
20 |
#ifdef __WIN__ |
|
21 |
#pragma warning(disable:4786) |
|
22 |
#endif |
|
23 |
#include <time.h> |
|
24 |
#include <map> |
|
25 |
#include <list> |
|
26 |
#include <algorithm> |
|
27 |
#include <assert.h> |
|
28 |
#include <fstream> |
|
29 |
#include <stdlib.h> |
|
30 |
#include <boost/thread.hpp> |
|
31 |
#include <boost/bind.hpp> |
|
32 |
||
33 |
#ifdef __WIN__ |
|
34 |
#include <io.h> |
|
35 |
#include <direct.h> |
|
36 |
#include <windows.h> |
|
37 |
#else |
|
38 |
#include <unistd.h> |
|
39 |
#endif |
|
40 |
#include "Analyser.h" |
|
41 |
#include "CPPParser.h" |
|
42 |
#include "CommandLine.h" |
|
43 |
#include "CommandFile.h" |
|
44 |
#include "BBCFileUtils.h" |
|
45 |
#include "HAException.h" |
|
46 |
#include "BBCAnalyser.h" |
|
47 |
#include "AnalyserParams.h" |
|
48 |
#include "MacroAnalyser.h" |
|
49 |
#include "Utils.h" |
|
50 |
#include "PlatformData.h" |
|
51 |
||
52 |
const int KMaxDirLength=1024; |
|
53 |
||
54 |
boost::mutex m; |
|
55 |
boost::mutex::scoped_lock lock(m,false); //for synchronizing creation & destruction of threads in gHeaderThreads |
|
56 |
||
57 |
boost::thread_group gComponentThreads; |
|
58 |
boost::thread_group gHeaderThreads; |
|
59 |
||
60 |
boost::thread* gpComponentThreads[MAX_THREAD_COUNT]; |
|
61 |
boost::thread* gpHeaderThreads[MAX_THREAD_COUNT2]; |
|
62 |
||
63 |
XERCES_CPP_NAMESPACE_USE |
|
64 |
typedef pair<string,string> stringpair; |
|
65 |
//the total number of files to be processed |
|
66 |
static int _total_files = 0; |
|
67 |
//the number of files that have been processed |
|
68 |
static int _current_files = 0; |
|
69 |
||
70 |
// make sure globbing is turned off when GCC is used |
|
71 |
int _CRT_glob = 0; |
|
72 |
||
73 |
// Fill the headers having API Info in global vector, so that report generator can access it. |
|
74 |
vector<pair<string,stringpair> > HeaderInfoList; // vector<pair< headerfile name, pair<API name, API category>>> |
|
75 |
||
76 |
// ---------------------------------------------------------------------------- |
|
77 |
// Analyser::Analyser |
|
78 |
// Constructor |
|
79 |
// ---------------------------------------------------------------------------- |
|
80 |
// |
|
81 |
Analyser::Analyser(char** args, int argc) : iCPPParser(NULL) |
|
82 |
{
|
|
83 |
iCmdLine = new CommandLine(args, argc); |
|
84 |
iUseBaselinePlatformData = false; |
|
85 |
iUseCurrentPlatformData = false; |
|
86 |
iBasePlatformData = 0; |
|
87 |
iProductPlatformData = 0; |
|
88 |
} |
|
89 |
||
90 |
// ---------------------------------------------------------------------------- |
|
91 |
// Analyser::Analyser |
|
92 |
// Constructor |
|
93 |
// ---------------------------------------------------------------------------- |
|
94 |
// |
|
95 |
Analyser::Analyser() |
|
96 |
{
|
|
97 |
||
98 |
} |
|
99 |
||
100 |
// ---------------------------------------------------------------------------- |
|
101 |
// Analyser::Analyser |
|
102 |
// Destructor |
|
103 |
// ---------------------------------------------------------------------------- |
|
104 |
// |
|
105 |
Analyser::~Analyser() |
|
106 |
{
|
|
107 |
delete iCmdLine; |
|
108 |
iCmdLine = NULL; |
|
109 |
if (iCPPParser != NULL) |
|
110 |
{
|
|
111 |
delete iCPPParser; |
|
112 |
iCPPParser = NULL; |
|
113 |
} |
|
114 |
if (iBasePlatformData) |
|
115 |
{
|
|
116 |
delete iBasePlatformData; |
|
117 |
iBasePlatformData = 0; |
|
118 |
} |
|
119 |
if ( iProductPlatformData) |
|
120 |
{
|
|
121 |
delete iProductPlatformData; |
|
122 |
iProductPlatformData = 0; |
|
123 |
} |
|
124 |
} |
|
125 |
||
126 |
// ---------------------------------------------------------------------------- |
|
127 |
// Analyser::validateHeaders |
|
128 |
// validates header for include guards |
|
129 |
// ---------------------------------------------------------------------------- |
|
130 |
// |
|
131 |
void Analyser::validateHeaders(vector<pair<string, string> >& aFiles, vector<pair<string, string> >& aUnsuccessful) |
|
132 |
{
|
|
133 |
int count = 0; |
|
134 |
string input; |
|
135 |
string files[2]; |
|
136 |
bool exists[2]; |
|
137 |
string guard[2]; |
|
138 |
vector<string> guards[2]; |
|
139 |
||
140 |
vector< pair<string, string> >::iterator fileStart = aFiles.begin(); |
|
141 |
vector< pair<string, string> >::iterator fileEnd = aFiles.end(); |
|
142 |
//vector used to temporarily hold file pairs with include guards |
|
143 |
vector< pair<string, string> > temp; |
|
144 |
while(fileStart != fileEnd ) |
|
145 |
{
|
|
146 |
files[0] = fileStart->first; |
|
147 |
files[1] = fileStart->second; |
|
148 |
for(int i=0; i<2; i++) |
|
149 |
{
|
|
150 |
||
151 |
//check for include guard in Base header |
|
152 |
exists[i] = guardExists(files[i], guard[i]); |
|
153 |
} |
|
154 |
//if either Base or Current header in the PAIR do not have include guards |
|
155 |
//add the file pair to RemovedFiles list. |
|
156 |
if( !exists[0] || !exists[1] ) |
|
157 |
aUnsuccessful.push_back(*fileStart); |
|
158 |
else |
|
159 |
{
|
|
160 |
if ( find(guards[0].begin(),guards[0].end(),guard[0]) == guards[0].end() && find(guards[1].begin(),guards[1].end(),guard[1]) == guards[1].end()) |
|
161 |
{
|
|
162 |
guards[0].push_back(guard[0]); |
|
163 |
guards[1].push_back(guard[1]); |
|
164 |
temp.push_back(*fileStart); |
|
165 |
} |
|
166 |
else |
|
167 |
{
|
|
168 |
aUnsuccessful.push_back(*fileStart); |
|
169 |
} |
|
170 |
} |
|
171 |
||
172 |
++fileStart; |
|
173 |
} |
|
174 |
guards[0].clear(); |
|
175 |
guards[1].clear(); |
|
176 |
aFiles.clear(); |
|
177 |
aFiles = temp; |
|
178 |
} |
|
179 |
||
180 |
// ---------------------------------------------------------------------------- |
|
181 |
// Analyser::guardExists |
|
182 |
// guard Exists checs to see if the input file has include guards |
|
183 |
// ---------------------------------------------------------------------------- |
|
184 |
// |
|
185 |
bool Analyser::guardExists(const string& aFile, string& aGuard) |
|
186 |
{
|
|
187 |
bool exists = false; |
|
188 |
string guard("");
|
|
189 |
string input("");
|
|
190 |
string temp("");
|
|
191 |
//macro used in the #ifndef line |
|
192 |
pair<string,string> macroOne; |
|
193 |
//macro #defined subsequently |
|
194 |
pair<string,string> macroTwo; |
|
195 |
int linenum = 0; |
|
196 |
//linenum containing the #ifndef statement |
|
197 |
int ifndefline = 0; |
|
198 |
||
199 |
ifstream fileRead(aFile.c_str(), ios::in); |
|
200 |
if( !fileRead.is_open()) |
|
201 |
throw HAException("Header file does not exist");;
|
|
202 |
while( !fileRead.eof() ) |
|
203 |
{
|
|
204 |
linenum++; |
|
205 |
temp = getLine(fileRead); |
|
206 |
input = trimWhiteSpace(temp); |
|
207 |
// Check if #ifndef are being used |
|
208 |
// Get the MACRO string if they are present |
|
209 |
if(input.substr(0,7) == "#ifndef") |
|
210 |
{
|
|
211 |
macroOne = MacroAnalyser::FindMacro(input); |
|
212 |
ifndefline = linenum; |
|
213 |
} |
|
214 |
// checks for the usage of #if (!defined ...) in include guard defns |
|
215 |
else if (input.substr(0,3) == "#if") |
|
216 |
{
|
|
217 |
string tempstr("!defined");
|
|
218 |
//strip all braces from the Macro string |
|
219 |
while(input.find("(") < input.length())
|
|
220 |
{
|
|
221 |
replaceChar(input,'(',' ');
|
|
222 |
replaceChar(input,')',' '); |
|
223 |
} |
|
224 |
//get the actual MACRO string after required temp modifications |
|
225 |
string::size_type index = input.find(tempstr); |
|
226 |
if (index == string::npos) |
|
227 |
continue; |
|
228 |
index = index + tempstr.length(); |
|
229 |
tempstr = input.substr( index ); |
|
230 |
input = trimWhiteSpace(tempstr); |
|
231 |
pair<string,string> temppair(input, ""); |
|
232 |
macroOne = temppair; |
|
233 |
ifndefline = linenum; |
|
234 |
} |
|
235 |
// Check if #define is used |
|
236 |
else if (input.substr(0, 7) == "#define") |
|
237 |
{
|
|
238 |
macroTwo = MacroAnalyser::FindMacro(input); |
|
239 |
//if macro strings used in both #ifndef and #define are same |
|
240 |
//consider that include guard exists |
|
241 |
//also verify that #define follows #if |
|
242 |
if( macroTwo.first == macroOne.first && macroTwo.second == macroOne.second && ifndefline < linenum ) |
|
243 |
{
|
|
244 |
exists = true; |
|
245 |
aGuard = macroOne.first; |
|
246 |
} |
|
247 |
break; |
|
248 |
} |
|
249 |
// additional statement will be used for early termination of the loop |
|
250 |
// in cases with no "include" guards |
|
251 |
else if( input.substr(0, 8) == "#include") |
|
252 |
{
|
|
253 |
exists = false; |
|
254 |
break; |
|
255 |
} |
|
256 |
} |
|
257 |
fileRead.close(); |
|
258 |
return exists; |
|
259 |
} |
|
260 |
||
261 |
// ---------------------------------------------------------------------------- |
|
262 |
// Analyser::readParameters |
|
263 |
// readParameters should be called so that first is called baseline command |
|
264 |
// and after that current command, otherwise it doesn't work |
|
265 |
// ---------------------------------------------------------------------------- |
|
266 |
// |
|
267 |
void Analyser::readParameters(basetype type, list<pair<string, string> >& files, string& forcedheaders) |
|
268 |
{
|
|
269 |
string headerset; |
|
270 |
string dir; |
|
271 |
string file; |
|
272 |
string platform; |
|
273 |
string forcedheadersfile; |
|
274 |
string forcedheaders_file; |
|
275 |
string version; |
|
276 |
string versionstr; |
|
277 |
BBCFileUtils* fileUtils = NULL; |
|
278 |
static basetype first = type; |
|
279 |
||
280 |
if (first != EBase) |
|
281 |
{
|
|
282 |
cout << "Error: Parameter read has been called in wrong order."; |
|
283 |
exit(3); |
|
284 |
} |
|
285 |
||
286 |
switch(type) |
|
287 |
{
|
|
288 |
case EBase: |
|
289 |
dir = BASELINEDIR; |
|
290 |
file = BASELINE; |
|
291 |
platform = BASELINEPLAT; |
|
292 |
forcedheadersfile = BASEFORCEDHEADERSFILE; |
|
293 |
version = BASELINEVERSION; |
|
294 |
versionstr = "BASELINE"; |
|
295 |
break; |
|
296 |
case ECurrent: |
|
297 |
dir = CURRENTDIR; |
|
298 |
file = CURRENT; |
|
299 |
platform = CURRENTPLAT; |
|
300 |
forcedheadersfile = CURRENTFORCEDHEADERSFILE; |
|
301 |
version = CURRENTVERSION; |
|
302 |
versionstr = "CURRENT"; |
|
303 |
break; |
|
304 |
default: |
|
305 |
cout << "Error: Unknown type (not baseline, nor current)."; |
|
306 |
exit(3); |
|
307 |
} |
|
308 |
||
309 |
// Query the baseline-related command line parameters |
|
310 |
// since validation has passed, none of these should really |
|
311 |
// cause an exception |
|
312 |
try |
|
313 |
{
|
|
314 |
if( iParams.parameterExists(BASEPLATFORMDATA)) |
|
315 |
{
|
|
316 |
iUseBaselinePlatformData = true; |
|
317 |
string pfdir(BBCFileUtils::getFullPath(iParams.getParameter(BASEPLATFORMDATA))); |
|
318 |
if (!BBCFileUtils::isValidFilename(pfdir)) |
|
319 |
{
|
|
320 |
throw HAException("Baseline platform data file '" + pfdir + "' is not valid.");
|
|
321 |
} |
|
322 |
iParams.storeParameter(BASEPLATFORMDATA, pfdir); |
|
323 |
} |
|
324 |
if( iParams.parameterExists(CURRENTPLATFORMDATA)) |
|
325 |
{
|
|
326 |
iUseCurrentPlatformData = true; |
|
327 |
string pfdir(BBCFileUtils::getFullPath(iParams.getParameter(CURRENTPLATFORMDATA))); |
|
328 |
if (!BBCFileUtils::isValidFilename(pfdir)) |
|
329 |
{
|
|
330 |
throw HAException("Current platform data file '" + pfdir + "' is not valid.");
|
|
331 |
} |
|
332 |
iParams.storeParameter(CURRENTPLATFORMDATA, pfdir); |
|
333 |
} |
|
334 |
if (iParams.parameterExists(TEMPDIR)) |
|
335 |
{
|
|
336 |
string tempdir(BBCFileUtils::getFullPath(iParams.getParameter(TEMPDIR))); |
|
337 |
iParams.storeParameter(TEMPDIR, tempdir); |
|
338 |
if (!BBCFileUtils::isValidDirectory(tempdir)) |
|
339 |
{
|
|
340 |
throw HAException("Temporary directory '" + tempdir + "' is not valid directory.");
|
|
341 |
} |
|
342 |
} |
|
343 |
if (iParams.parameterExists(REPORTFILE)) |
|
344 |
{
|
|
345 |
string reportfile(BBCFileUtils::getFullPath(iParams.getParameter(REPORTFILE))); |
|
346 |
iParams.storeParameter(REPORTFILE, reportfile); |
|
347 |
if (rightmostDirSeparatorIndex(reportfile) == reportfile.length() - 1 || BBCFileUtils::isValidDirectory(reportfile)) |
|
348 |
{
|
|
349 |
throw HAException("No filename given for report file.");
|
|
350 |
} |
|
351 |
string reportdir = reportfile.substr(0, rightmostDirSeparatorIndex(reportfile)); |
|
352 |
||
353 |
if (reportdir.size() == ANALYSER_REPORT_DIR_SIZE) |
|
354 |
{
|
|
355 |
reportdir += DIR_SEPARATOR; |
|
356 |
} |
|
357 |
if (!BBCFileUtils::isValidDirectory(reportdir)) |
|
358 |
{
|
|
359 |
throw HAException("Directory for report file is non-existent.");
|
|
360 |
} |
|
361 |
} |
|
362 |
if (iParams.parameterExists(HEADERSET)) |
|
363 |
{
|
|
364 |
iHeaderSetInUse = true; |
|
365 |
} |
|
366 |
if (iParams.parameterExists(USETHREAD)) |
|
367 |
{
|
|
368 |
iUseThread = true; |
|
369 |
} |
|
370 |
if (iParams.parameterExists(dir)) |
|
371 |
{
|
|
372 |
// START -- Support for multiple header directories |
|
373 |
// Validate the ; separated header paths and store them |
|
374 |
list<pair<string, string> > dirs = BBCFileUtils::extractFilenames(iParams.getParameter(dir)); |
|
375 |
list<pair<string, string> >::iterator dirbegin = dirs.begin(); |
|
376 |
string tempval = ""; |
|
377 |
||
378 |
for(; dirbegin != dirs.end(); dirbegin++) |
|
379 |
{
|
|
380 |
if (dirbegin != dirs.begin()) |
|
381 |
{
|
|
382 |
tempval += ";"; |
|
383 |
} |
|
384 |
string header = BBCFileUtils::getFullPath(dirbegin->first); |
|
385 |
||
386 |
if (header.length() != ANALYSER_HEADER_MAX_LENGTH && header.at(header.length() - 1) == DIR_SEPARATOR) |
|
387 |
{
|
|
388 |
header.resize(header.length() - 1); |
|
389 |
} |
|
390 |
||
391 |
if (!BBCFileUtils::isValidDirectory(header)) |
|
392 |
{
|
|
393 |
string::size_type pos = rightmostDirSeparatorIndex(header); |
|
394 |
string tempvar; |
|
395 |
if (pos != header.length() - 1) |
|
396 |
{
|
|
397 |
tempvar = header.substr(pos + 1); |
|
398 |
header.resize(pos); |
|
399 |
} |
|
400 |
||
401 |
if (header.size() == ANALYSER_HEADER_SIZE) |
|
402 |
{
|
|
403 |
header += DIR_SEPARATOR; |
|
404 |
} |
|
405 |
||
406 |
if (!BBCFileUtils::isValidDirectory(header) || tempvar.find_first_of("*?") == string::npos)
|
|
407 |
{
|
|
408 |
string errormsg; |
|
409 |
errormsg = "Non-existent "; |
|
410 |
if (type == EBase) |
|
411 |
{
|
|
412 |
errormsg += "base"; |
|
413 |
} else |
|
414 |
{
|
|
415 |
errormsg += "current"; |
|
416 |
} |
|
417 |
errormsg += " directory '" + header + DIR_SEPARATOR + tempvar + "'.\n"; |
|
418 |
throw HAException(errormsg); |
|
419 |
} |
|
420 |
} |
|
421 |
if (header.at(header.length() - 1) == DIR_SEPARATOR) |
|
422 |
{
|
|
423 |
header.resize(header.length() - 1); |
|
424 |
} |
|
425 |
tempval += header; |
|
426 |
} |
|
427 |
iParams.storeParameter(dir, tempval); |
|
428 |
// END -- Support for multiple header directories |
|
429 |
} |
|
430 |
else |
|
431 |
{
|
|
432 |
iParams.storeParameter(file, BBCFileUtils::getFullPath(iParams.getParameter(file))); |
|
433 |
} |
|
434 |
||
435 |
// Location of baseline's platform headers |
|
436 |
list<pair<string, string> > platformheaders = BBCFileUtils::extractFilenames(iParams.getParameter(platform)); |
|
437 |
list<pair<string, string> >::iterator platformbegin = platformheaders.begin(); |
|
438 |
string tempval = ""; |
|
439 |
for(; platformbegin != platformheaders.end(); platformbegin++) |
|
440 |
{
|
|
441 |
if (platformbegin != platformheaders.begin()) |
|
442 |
{
|
|
443 |
tempval += ";"; |
|
444 |
} |
|
445 |
string header = BBCFileUtils::getFullPath(platformbegin->first); |
|
446 |
||
447 |
if (header.length() != ANALYSER_HEADER_MAX_LENGTH && header.at(header.length() - 1) == DIR_SEPARATOR) |
|
448 |
{
|
|
449 |
header.resize(header.length() - 1); |
|
450 |
} |
|
451 |
||
452 |
tempval += header; |
|
453 |
} |
|
454 |
iParams.storeParameter(platform, tempval); |
|
455 |
||
456 |
// Location of forced headers file (containing full names of headers that |
|
457 |
// will be included to preprocessing and processing phases, e.g. e32base.h) |
|
458 |
if (iParams.parameterExists(forcedheadersfile)) |
|
459 |
{
|
|
460 |
// START -- Support for multiple forced headers |
|
461 |
list<pair<string, string> > fheaders = BBCFileUtils::extractFilenames(iParams.getParameter(forcedheadersfile)); |
|
462 |
list<pair<string, string> >::iterator fheadersbegin = fheaders.begin(); |
|
463 |
string tempval = ""; |
|
464 |
||
465 |
//for each forced header, get the full path before storing it |
|
466 |
for(; fheadersbegin != fheaders.end(); fheadersbegin++) |
|
467 |
{
|
|
468 |
if (fheadersbegin != fheaders.begin()) |
|
469 |
{
|
|
470 |
tempval += ";"; |
|
471 |
} |
|
472 |
tempval += BBCFileUtils::getFullPath(fheadersbegin->first); |
|
473 |
} |
|
474 |
iParams.storeParameter(forcedheadersfile, tempval); |
|
475 |
forcedheaders = iParams.getParameter(forcedheadersfile); |
|
476 |
// END -- Support for multiple forced headers |
|
477 |
} |
|
478 |
||
479 |
if (!iParams.parameterExists(version)) |
|
480 |
{
|
|
481 |
iParams.storeParameter(version, versionstr); |
|
482 |
} |
|
483 |
} catch (HAException& e) |
|
484 |
{
|
|
485 |
cout << "Error: "<<e.errorMessage()<<"\n"; |
|
486 |
exit(2); |
|
487 |
} |
|
488 |
||
489 |
// Instantiate file utilities that generate the file lists based on |
|
490 |
// commandline parameters. In this try/catch block, we're |
|
491 |
// handling the baseline files |
|
492 |
try |
|
493 |
{
|
|
494 |
if (iParams.parameterExists(dir)) |
|
495 |
{
|
|
496 |
// baselinedir/currentdir commandline parameters given |
|
497 |
fileUtils = new BBCFileUtils(iParams.getParameter(dir)); |
|
498 |
fileUtils->setTemp(iParams.getParameter(TEMPDIR)); |
|
499 |
string wildcard; |
|
500 |
list<stringpair > sets; |
|
501 |
list<stringpair > discarddirs; |
|
502 |
list<stringpair > foundfiles; |
|
503 |
list<stringpair > completefilenames; // Filenames that are complete, i.e no wildcards used. |
|
504 |
vector<string> wildcardsinset; |
|
505 |
||
506 |
if (type == EBase) |
|
507 |
{
|
|
508 |
// We are reading the parameters of the baseline platform |
|
509 |
||
510 |
if(iHeaderSetInUse) |
|
511 |
{
|
|
512 |
// the files to be analysed are defined using 'set' parameter. |
|
513 |
sets = fileUtils->extractFilenames(iParams.getParameter(HEADERSET)); |
|
514 |
} |
|
515 |
else |
|
516 |
{
|
|
517 |
// 'set' parameter is absent. Use default file types in the files to be analysed. |
|
518 |
sets = fileUtils->extractFilenames(WILDCARD_DEFAULT); |
|
519 |
} |
|
520 |
||
521 |
sets = canonicalizeFilename(sets); |
|
522 |
||
523 |
for(list<stringpair >::iterator s = sets.begin(); s != sets.end(); ++s ) |
|
524 |
{
|
|
525 |
if( s->first.find_first_of("*?") != string::npos )
|
|
526 |
{
|
|
527 |
// Wildcard is used in filename. |
|
528 |
std::string wc(s->first); |
|
529 |
wildcardsinset.push_back(wc); |
|
530 |
list<stringpair > tmpfiles(fileUtils->getFilesInDir(wc, "")); |
|
531 |
files.insert(files.end(), tmpfiles.begin(), tmpfiles.end()); |
|
532 |
} |
|
533 |
else |
|
534 |
{
|
|
535 |
completefilenames.push_back(*s); |
|
536 |
} |
|
537 |
} |
|
538 |
||
539 |
files.sort(LessStringPair);// Sort files |
|
540 |
files.unique(); // Remove duplicates |
|
541 |
||
542 |
// Remove trailing directory separator from the filenames, that were found using the wildcard, |
|
543 |
// to be able to build <code>foundfiles</code> list for later use. |
|
544 |
list<stringpair> foundwithwildcard(files); |
|
545 |
std::for_each(foundwithwildcard.begin(), foundwithwildcard.end(),RemoveTrailingDirSeparator<stringpair>()); |
|
546 |
||
547 |
// Find files given with complete filename |
|
548 |
list<stringpair> tempcompletefiles(completefilenames); |
|
549 |
list<stringpair > tmplist(fileUtils->getFilesInDir(tempcompletefiles, "",foundfiles)); |
|
550 |
||
551 |
// Add files found with wildcard to <code>foundfiles</code> |
|
552 |
foundfiles.sort(LessStringPair); |
|
553 |
foundfiles.merge(foundwithwildcard, LessStringPair); |
|
554 |
foundfiles.unique(); // Remove duplicates |
|
555 |
||
556 |
// Merge all found files: |
|
557 |
tmplist.sort( LessStringPair ); |
|
558 |
files.merge(tmplist, LessStringPair); |
|
559 |
files.unique(); // Remove duplicates |
|
560 |
if (iParams.parameterExists(DISCARDDIRS)) |
|
561 |
{
|
|
562 |
discarddirs = BBCFileUtils::extractFilenames(iParams.getParameter(DISCARDDIRS)); |
|
563 |
} |
|
564 |
} else if (type == ECurrent) |
|
565 |
{
|
|
566 |
// We are reading the parameters of the current platform |
|
567 |
// and the files to be analysed are defined using 'set' parameter. |
|
568 |
wildcard = WILDCARD_ALLFILES; |
|
569 |
files = fileUtils->getFilesInDir(wildcard, ""); |
|
570 |
if (iParams.parameterExists(DISCARDDIRS)) |
|
571 |
{
|
|
572 |
discarddirs = BBCFileUtils::extractFilenames(iParams.getParameter(DISCARDDIRS)); |
|
573 |
} |
|
574 |
} else |
|
575 |
{
|
|
576 |
// No 'set' parameter used |
|
577 |
wildcard = iParams.getParameter(BASELINE); |
|
578 |
files = fileUtils->getFilesInDir(wildcard, ""); |
|
579 |
if (iParams.parameterExists(DISCARDDIRS)) |
|
580 |
{
|
|
581 |
discarddirs = BBCFileUtils::extractFilenames(iParams.getParameter(DISCARDDIRS)); |
|
582 |
} |
|
583 |
} |
|
584 |
if (iParams.parameterExists(RECURSIVE)) |
|
585 |
{
|
|
586 |
list<pair<string, string> > dirs = fileUtils->getDirsInDir("",discarddirs);
|
|
587 |
while(!dirs.empty()) |
|
588 |
{
|
|
589 |
string dir = dirs.front().first; |
|
590 |
dirs.pop_front(); |
|
591 |
list<pair<string, string> > morefiles; |
|
592 |
if (type == EBase) |
|
593 |
{
|
|
594 |
// Read files which were given as complete names in the -set parameter: |
|
595 |
morefiles = fileUtils->getFilesInDir(completefilenames, dir,foundfiles); |
|
596 |
||
597 |
// Read files which were given as wildcards in the -set parameter: |
|
598 |
for( vector<string>::iterator wc = wildcardsinset.begin(); wc != wildcardsinset.end(); ++wc) |
|
599 |
{
|
|
600 |
list<pair<string, string> > tmpfiles = fileUtils->getFilesInDir(*wc, dir); |
|
601 |
morefiles.insert(morefiles.end(), tmpfiles.begin(), tmpfiles.end()); |
|
602 |
} |
|
603 |
} |
|
604 |
else |
|
605 |
{
|
|
606 |
morefiles = fileUtils->getFilesInDir(wildcard, dir); |
|
607 |
} |
|
608 |
morefiles.sort(LessStringPair); |
|
609 |
morefiles.unique(); |
|
610 |
list<pair<string, string> >::const_iterator file = morefiles.begin(); |
|
611 |
list<pair<string, string> >::const_iterator fileend = morefiles.end(); |
|
612 |
for(; file != fileend; file++) |
|
613 |
{
|
|
614 |
files.push_back(*file); |
|
615 |
} |
|
616 |
list<pair<string, string> > moredirs = fileUtils->getDirsInDir(dir,discarddirs); |
|
617 |
while(!moredirs.empty()) |
|
618 |
{
|
|
619 |
pair<string, string> direntry = moredirs.front(); |
|
620 |
moredirs.pop_front(); |
|
621 |
dirs.push_back(direntry); |
|
622 |
} |
|
623 |
} |
|
624 |
} |
|
625 |
if (type == EBase) |
|
626 |
{
|
|
627 |
list<pair<string, string> > notfound; |
|
628 |
diffs(files, sets, notfound); |
|
629 |
if (!notfound.empty()) |
|
630 |
{
|
|
631 |
string errormessage = "Following files could not be found in baseline:\n"; |
|
632 |
list<pair<string, string> >::iterator file = notfound.begin(); |
|
633 |
list<pair<string, string> >::iterator fileend = notfound.end(); |
|
634 |
for(; file != fileend; file++) |
|
635 |
{
|
|
636 |
errormessage += file->first; |
|
637 |
errormessage += "\n"; |
|
638 |
} |
|
639 |
//this case has now been redefined as a input error that can be handled |
|
640 |
//the file is removed from the list to be analysed, and execution continues |
|
641 |
//throw HAException(errormessage); |
|
642 |
} |
|
643 |
} |
|
644 |
} |
|
645 |
else |
|
646 |
{
|
|
647 |
// baseline/current commandline parameters given |
|
648 |
string file_val = iParams.getParameter(file); |
|
649 |
string f = getFilenameWithoutDir(file_val); |
|
650 |
iParams.storeParameter(file, f); |
|
651 |
file_val.resize(file_val.length() - f.length() - 1); |
|
652 |
iParams.storeParameter(dir, file_val); |
|
653 |
fileUtils = new BBCFileUtils(iParams.getParameter(dir)); |
|
654 |
fileUtils->setTemp(iParams.getParameter(TEMPDIR)); |
|
655 |
pair<string, string> tempvar(f, toLowerCaseWin(f)); |
|
656 |
files.push_back(tempvar); |
|
657 |
} |
|
658 |
} catch (HAException& e) |
|
659 |
{
|
|
660 |
// something went wrong. Make a clean exit |
|
661 |
if (fileUtils != NULL) |
|
662 |
{
|
|
663 |
delete fileUtils; |
|
664 |
fileUtils = NULL; |
|
665 |
} |
|
666 |
cout << "Error: " << e.errorMessage() << "\n"; |
|
667 |
exit(2); |
|
668 |
} |
|
669 |
||
670 |
delete fileUtils; |
|
671 |
fileUtils = NULL; |
|
672 |
||
673 |
} |
|
674 |
||
675 |
// ---------------------------------------------------------------------------- |
|
676 |
// Analyser::processParameters |
|
677 |
// processParameters |
|
678 |
// ---------------------------------------------------------------------------- |
|
679 |
// |
|
680 |
int Analyser::processParameters() |
|
681 |
{
|
|
682 |
string err = ""; |
|
683 |
||
684 |
// Validate command-line parameters. |
|
685 |
// If they are not sound and complete, break off with an error message. |
|
686 |
try |
|
687 |
{
|
|
688 |
err = iCmdLine->validateParameters(); |
|
689 |
} catch (HAException& e) |
|
690 |
{
|
|
691 |
cout << "ERROR: Bad parameters, quitting. Type ha -? for help.\n"; |
|
692 |
cout << e.errorMessage(); |
|
693 |
cout << "\n"; |
|
694 |
return (2); |
|
695 |
} |
|
696 |
||
697 |
if (err.size() > 0) |
|
698 |
{
|
|
699 |
cout << "ERROR: Parameter validation fail. Type ha -? for help.\n"; |
|
700 |
cout << err << "\n"; |
|
701 |
return (2); |
|
702 |
} |
|
703 |
||
704 |
map<string, string> params = iCmdLine->getParameters(); |
|
705 |
map<string, string>::iterator begin = params.begin(); |
|
706 |
map<string, string>::iterator end = params.end(); |
|
707 |
while (begin != end) |
|
708 |
{
|
|
709 |
iParams.storeParameter((*begin).first,(*begin).second, true); |
|
710 |
++begin; |
|
711 |
} |
|
712 |
||
713 |
// readParameters should be called so that first is called baseline command |
|
714 |
// and after that current command, otherwise it doesn't work |
|
715 |
||
716 |
// Read base dependent parameters |
|
717 |
readParameters(EBase, iFiles, iForcedBaselineHeaders); |
|
718 |
// ..and current ones |
|
719 |
readParameters(ECurrent, iFiles2, iForcedCurrentHeaders); |
|
720 |
||
721 |
#if defined(_DEBUG) || defined(DEBUG) |
|
722 |
if(iParams.parameterExists(COMMANDLINETEST)) |
|
723 |
{
|
|
724 |
map<string, string> params = iParams.getGivenParameters(); |
|
725 |
map<string, string>::iterator begin = params.begin(); |
|
726 |
map<string, string>::iterator end = params.end(); |
|
727 |
while (begin != end) |
|
728 |
{
|
|
729 |
cout << "Param: '" << (*begin).first << "' Value: '" << (*begin).second << "'\n"; |
|
730 |
begin++; |
|
731 |
} |
|
732 |
exit(100); |
|
733 |
} |
|
734 |
#endif |
|
735 |
||
736 |
return 0; |
|
737 |
} |
|
738 |
||
739 |
// ---------------------------------------------------------------------------- |
|
740 |
// Analyser::analyseTrees |
|
741 |
// processParameters |
|
742 |
// ---------------------------------------------------------------------------- |
|
743 |
// |
|
744 |
int Analyser::analyseTrees(DOMNode* baseline, DOMNode* current, const list< pair<string,string> >& files, ReportGenerator& report) |
|
745 |
{
|
|
746 |
int ret = 0; |
|
747 |
//print progress information for files which have compiled |
|
748 |
list< pair<string,string> >::const_iterator begin = files.begin(); |
|
749 |
list< pair<string,string> >::const_iterator end = files.end(); |
|
750 |
||
751 |
while (begin != end) |
|
752 |
{
|
|
753 |
_current_files++; |
|
754 |
cout << "\nAnalysing files (" << _current_files << "/" << _total_files << "): " << (*begin).first <<" => "<< (*begin).second << endl;
|
|
755 |
begin++; |
|
756 |
} |
|
757 |
||
758 |
BBCAnalyser analyser(report); |
|
759 |
ret = analyser.analyseTrees(baseline, current, files, iMacroFiles); |
|
760 |
||
761 |
return ret; |
|
762 |
} |
|
763 |
||
764 |
// ---------------------------------------------------------------------------- |
|
765 |
// Analyser::handleBundlesizeParam |
|
766 |
// Get bundlesize value |
|
767 |
// ---------------------------------------------------------------------------- |
|
768 |
// |
|
769 |
int Analyser::handleBundlesizeParam() |
|
770 |
{
|
|
771 |
int bundlesize=1; |
|
772 |
||
773 |
if (iParams.parameterExists(BUNDLESIZE)) |
|
774 |
{
|
|
775 |
string tempstr = iParams.getParameter(BUNDLESIZE); |
|
776 |
if (tempstr.length() > 0) |
|
777 |
{
|
|
778 |
bundlesize = atoi(tempstr.c_str()); |
|
779 |
if (bundlesize < 1) |
|
780 |
{
|
|
781 |
bundlesize = 1; |
|
782 |
} |
|
783 |
else if (bundlesize > MAX_BUNDLESIZE) |
|
784 |
{
|
|
785 |
bundlesize = MAX_BUNDLESIZE; |
|
786 |
} |
|
787 |
} |
|
788 |
} |
|
789 |
||
790 |
if (bundlesize >= BUNDLESIZE_WARNING) |
|
791 |
{
|
|
792 |
cout << "Note: Processing in large bundles, this may have a negative " |
|
793 |
<< "performance impact and/or produce unwanted artifacts.\n"; |
|
794 |
} |
|
795 |
return bundlesize; |
|
796 |
} |
|
797 |
||
798 |
// ---------------------------------------------------------------------------- |
|
799 |
// Analyser::getReplaceParam |
|
800 |
// Get Replace parameter value |
|
801 |
// ---------------------------------------------------------------------------- |
|
802 |
// |
|
803 |
string Analyser::getReplaceParam() |
|
804 |
{
|
|
805 |
string replace; |
|
806 |
// File renames |
|
807 |
if (iParams.parameterExists(FILEREPLACE)) |
|
808 |
{
|
|
809 |
replace = iParams.getParameter(FILEREPLACE); |
|
810 |
} else |
|
811 |
{
|
|
812 |
replace = ""; |
|
813 |
} |
|
814 |
||
815 |
return replace; |
|
816 |
} |
|
817 |
||
818 |
||
819 |
||
820 |
PlatformHeaders::iterator FindHeaderPair(const string& ID, PlatformHeaders& pfHeaders) |
|
821 |
{
|
|
822 |
for( PlatformHeaders::iterator i = pfHeaders.begin(); i != pfHeaders.end(); ++i ) |
|
823 |
{
|
|
824 |
if( i->first->ID() == ID ) |
|
825 |
{
|
|
826 |
return i; |
|
827 |
} |
|
828 |
} |
|
829 |
return pfHeaders.end(); |
|
830 |
} |
|
831 |
// ---------------------------------------------------------------------------- |
|
832 |
// Analyzes one component at a time. |
|
833 |
// |
|
834 |
// |
|
835 |
// ---------------------------------------------------------------------------- |
|
836 |
// |
|
837 |
void Analyser::AnalyzePlatforms(PlatformHeaders& pfHeaders, PlatformHeaders& unsuccessfulHdrs, ReportGenerator& report, int& issues, bool createThread) |
|
838 |
{
|
|
839 |
string epocRoot("epoc32");
|
|
840 |
epocRoot += DIR_SEPARATOR + string("include");
|
|
841 |
// START -- Support for multiple header directories |
|
842 |
list<pair<string, bool> > baseEpocRoot = BBCFileUtils::MergeDirs(iParams.getParameter(BASELINEDIR), epocRoot); |
|
843 |
list<pair<string, bool> > currEpocRoot = BBCFileUtils::MergeDirs(iParams.getParameter(CURRENTDIR), epocRoot); |
|
844 |
// END -- Support for multiple header directories |
|
845 |
for( PlatformHeaders::iterator pfHdr = pfHeaders.begin(); pfHdr != pfHeaders.end(); ++pfHdr ) |
|
846 |
{
|
|
847 |
if( pfHdr->first->Status() == Header::HDR_STATUS_TO_BE_ANALYZED /*|| pfHdr->first->Status() == Header::HDR_STATUS_INVALID*/) |
|
848 |
{
|
|
849 |
stringvector baseIncPaths; // This contains include paths needed to compile baseline headers |
|
850 |
stringvector currIncPaths; // This contains include paths needed to compile product headers |
|
851 |
||
852 |
baseIncPaths.clear(); |
|
853 |
currIncPaths.clear(); |
|
854 |
||
855 |
iBaseFilenames.clear(); |
|
856 |
iCurrFilenames.clear(); |
|
857 |
iBaseIncludes.clear(); |
|
858 |
iCurrIncludes.clear(); |
|
859 |
iInvalidFiles.clear(); |
|
860 |
||
861 |
// All headers in the (baseline platform) component: |
|
862 |
FileList& baseCmpHeaders = pfHdr->first->GetComponent()->Headers(); |
|
863 |
iBaseFilenames.reserve(baseCmpHeaders.size()); |
|
864 |
iCurrFilenames.reserve(baseCmpHeaders.size()); |
|
865 |
||
866 |
// Make sure that the epoc32/include directory is always in include paths: |
|
867 |
// START -- Support for multiple header directories |
|
868 |
list<pair<string, bool> >::iterator iter1 = baseEpocRoot.begin(); |
|
869 |
for(; iter1 != baseEpocRoot.end(); iter1++) |
|
870 |
{
|
|
871 |
if( iter1->second ) |
|
872 |
{
|
|
873 |
baseIncPaths.push_back(iter1->first); |
|
874 |
} |
|
875 |
} |
|
876 |
list<pair<string, bool> >::iterator iter2 = currEpocRoot.begin(); |
|
877 |
for(; iter2 != currEpocRoot.end(); iter2++) |
|
878 |
{
|
|
879 |
if( iter2->second ) |
|
880 |
{
|
|
881 |
currIncPaths.push_back(iter2->first); |
|
882 |
} |
|
883 |
} |
|
884 |
// END -- Support for multiple header directories |
|
885 |
||
886 |
string forcedHeader; |
|
887 |
char* base = new char[KMaxDirLength+1]; |
|
888 |
getcwd(base, KMaxDirLength); |
|
889 |
||
890 |
vector< stringpair > tmpfiles; |
|
891 |
vector< stringpair > invalid; |
|
892 |
// Loop all the headers that are in the same component: |
|
893 |
for( FileList::iterator bH = baseCmpHeaders.begin(); bH != baseCmpHeaders.end(); ++bH ) |
|
894 |
{
|
|
895 |
Header* baseHdr = dynamic_cast<Header*>(*bH); |
|
896 |
||
897 |
PlatformHeaders::iterator pairIter = FindHeaderPair(baseHdr->ID(), pfHeaders); |
|
898 |
if(pairIter != pfHeaders.end() && pairIter->second != 0) |
|
899 |
{
|
|
900 |
// If analysing in bundle, get the headers to be anaysed to validate for include guard before addition to bundle. |
|
901 |
if( (pfHeaders.size() > 1) && baseHdr && (baseHdr->Status() == Header::HDR_STATUS_TO_BE_ANALYZED) ) |
|
902 |
{
|
|
903 |
stringpair tmp(baseHdr->ID(), pairIter->second->ID()); |
|
904 |
tmpfiles.push_back(tmp); |
|
905 |
} |
|
906 |
} |
|
907 |
} |
|
908 |
||
909 |
if(tmpfiles.size()) |
|
910 |
{
|
|
911 |
// If analysing in bundle, validate for include guard before addition to bundle. |
|
912 |
validateHeaders(tmpfiles, invalid); |
|
913 |
// Exclude "iInvalidFiles" from bundle analysis. Analyse them only singly. |
|
914 |
if( invalid.size() ) |
|
915 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
916 |
for( int i=0 ; i < (int)invalid.size() ; i++ ) |
| 0 | 917 |
{
|
918 |
||
919 |
PlatformHeaders::iterator pairIter = FindHeaderPair(invalid[i].first, pfHeaders); |
|
920 |
//No need to check if the invalid file exists in pfHeaders, as it already done above. |
|
921 |
HeaderPair temp(pairIter->first, pairIter->second); |
|
922 |
if(find(iInvalidFiles.begin(), iInvalidFiles.end(), temp) == iInvalidFiles.end()) |
|
923 |
iInvalidFiles.push_back(temp); |
|
924 |
pairIter->first->SetStatus(Header::HDR_STATUS_INVALID); |
|
925 |
} |
|
926 |
} |
|
927 |
} |
|
928 |
||
929 |
for( FileList::iterator bH = baseCmpHeaders.begin(); bH != baseCmpHeaders.end(); ++bH ) |
|
930 |
{
|
|
931 |
Header* baseHdr = dynamic_cast<Header*>(*bH); |
|
932 |
||
933 |
PlatformHeaders::iterator pairIter = FindHeaderPair(baseHdr->ID(), pfHeaders); |
|
934 |
if(pairIter != pfHeaders.end() && pairIter->second != 0) |
|
935 |
{
|
|
936 |
||
937 |
// If the status is "to be analyzed" , get this header to the bundle too |
|
938 |
if( baseHdr && |
|
939 |
(baseHdr->Status() == Header::HDR_STATUS_TO_BE_ANALYZED )) |
|
940 |
{
|
|
941 |
// Find all additional includes that are needed in compilation of this header: |
|
942 |
const vector<string>& bIncs = iBasePlatformData->IncludesForHeader(baseHdr); |
|
943 |
forcedHeader.clear(); |
|
944 |
forcedHeader = baseHdr->CachedForcedInclude(); |
|
945 |
// Find all include paths that are needed in compilation of this header: |
|
946 |
const vector<string>& bPaths = iBasePlatformData->IncludePathsForHeader(baseHdr); |
|
947 |
||
948 |
// Add include paths for baseline platform headers: |
|
949 |
// START -- Support for multiple header directories |
|
950 |
for( vector<string>::const_iterator i = bPaths.begin(); i != bPaths.end(); ++i ) |
|
951 |
{
|
|
952 |
list<pair<string, bool> > fullIncPath = BBCFileUtils::MergeDirs(iParams.getParameter(BASELINEDIR), *i); |
|
953 |
list<pair<string, bool> >::iterator fulliterbegin = fullIncPath.begin(); |
|
954 |
for(; fulliterbegin != fullIncPath.end(); fulliterbegin++) |
|
955 |
{
|
|
956 |
if( find(baseIncPaths.begin(), baseIncPaths.end(), fulliterbegin->first) == baseIncPaths.end() ) |
|
957 |
{
|
|
958 |
baseIncPaths.push_back(fulliterbegin->first); |
|
959 |
} |
|
960 |
} |
|
961 |
} |
|
962 |
||
963 |
// Add additional include directives to header list: |
|
964 |
for( vector<string>::const_iterator i = bIncs.begin(); i != bIncs.end(); ++i ) |
|
965 |
{
|
|
966 |
// Make sure the header exists, because we don't want to generate new compilation errors... |
|
967 |
bool exists = false; |
|
968 |
// Test that header exists by merging the header name with include paths: |
|
969 |
for( stringvector::iterator ip = baseIncPaths.begin(); ip != baseIncPaths.end(); ++ip ) |
|
970 |
{
|
|
971 |
list<pair<string, bool> > fullIncPath = BBCFileUtils::MergeDirs( *ip, *i ); |
|
972 |
list<pair<string, bool> >::iterator fulliterbegin = fullIncPath.begin(); |
|
973 |
for(; fulliterbegin != fullIncPath.end(); fulliterbegin++) |
|
974 |
{
|
|
975 |
if( find(iBaseIncludes.begin(), iBaseIncludes.end(), fulliterbegin->first) == iBaseIncludes.end() ) |
|
976 |
{
|
|
977 |
if( BBCFileUtils::FileExists(fulliterbegin->first) ) |
|
978 |
{
|
|
979 |
iBaseIncludes.push_back(fulliterbegin->first); |
|
980 |
exists = true; |
|
981 |
break; |
|
982 |
} |
|
983 |
} |
|
984 |
} |
|
985 |
} |
|
986 |
if( exists == false ) |
|
987 |
{
|
|
988 |
// Try to find the included header from the same directory than the header itself is: |
|
989 |
list<pair<string, bool> > fullIncPath = |
|
990 |
BBCFileUtils::MergeDirs(iParams.getParameter(BASELINEDIR), baseHdr->Path() + DIR_SEPARATOR + *i); |
|
991 |
||
992 |
list<pair<string, bool> >::iterator fulliterbegin = fullIncPath.begin(); |
|
993 |
for(; fulliterbegin != fullIncPath.end(); fulliterbegin++) |
|
994 |
{
|
|
995 |
if( BBCFileUtils::FileExists(fulliterbegin->first) ) |
|
996 |
{
|
|
997 |
iBaseIncludes.push_back(fulliterbegin->first); |
|
998 |
} |
|
999 |
} |
|
1000 |
} |
|
1001 |
} |
|
1002 |
// END -- Support for multiple header directories |
|
1003 |
||
1004 |
// Add this header to the list of headers that are needed for compilation: |
|
1005 |
if( find(iBaseIncludes.begin(), iBaseIncludes.end(), baseHdr->ID()) == iBaseIncludes.end()) |
|
1006 |
{
|
|
1007 |
iBaseIncludes.push_back(baseHdr->ID()); |
|
1008 |
} |
|
1009 |
||
1010 |
// Add headers to the list of headers that are to be analyzed: |
|
1011 |
iBaseFilenames.push_back(baseHdr->ID()); |
|
1012 |
iCurrFilenames.push_back(pairIter->second->ID()); |
|
1013 |
baseHdr->SetStatus(Header::HDR_STATUS_READY); |
|
1014 |
||
1015 |
forcedHeader = DIR_SEPARATOR + forcedHeader; |
|
1016 |
forcedHeader = base + forcedHeader; |
|
1017 |
if( BBCFileUtils::isValidFilename(forcedHeader) ) |
|
1018 |
if( find(iBaseIncludes.begin(), iBaseIncludes.end(), forcedHeader) == iBaseIncludes.end()) |
|
1019 |
iBaseIncludes.insert(iBaseIncludes.begin(),forcedHeader); |
|
1020 |
||
1021 |
||
1022 |
// Then we need to find corresponding headers from the product (current) platform: |
|
1023 |
||
1024 |
Header* currHeader = pairIter->second; //Current header |
|
1025 |
||
1026 |
// Find additional includes and include paths for the current platform's header: |
|
1027 |
const vector<string>& cIncs = iProductPlatformData->IncludesForHeader(currHeader, baseHdr); |
|
1028 |
forcedHeader.clear(); |
|
1029 |
forcedHeader =currHeader->CachedForcedInclude(); |
|
1030 |
const vector<string>& cPaths =iProductPlatformData->IncludePathsForHeader(currHeader); |
|
1031 |
||
1032 |
// Add include paths to the list, if it does not exist there yet: |
|
1033 |
for( vector<string>::const_iterator i = cPaths.begin(); i != cPaths.end(); ++i ) |
|
1034 |
{
|
|
1035 |
// SART -- Support for multiple header directories |
|
1036 |
list<pair<string, bool> > fullIncPath = BBCFileUtils::MergeDirs(iParams.getParameter(CURRENTDIR), *i); |
|
1037 |
list<pair<string, bool> >::iterator fulliterbegin = fullIncPath.begin(); |
|
1038 |
for(; fulliterbegin != fullIncPath.end(); fulliterbegin++) |
|
1039 |
{
|
|
1040 |
if( find(currIncPaths.begin(), currIncPaths.end(), fulliterbegin->first) == currIncPaths.end() ) |
|
1041 |
{
|
|
1042 |
currIncPaths.push_back(fulliterbegin->first); |
|
1043 |
} |
|
1044 |
} |
|
1045 |
// END -- Support for multiple header directories |
|
1046 |
} |
|
1047 |
||
1048 |
// Add additional include directives to header list: |
|
1049 |
for( vector<string>::const_iterator i = cIncs.begin(); i != cIncs.end(); ++i ) |
|
1050 |
{
|
|
1051 |
bool exists = false; |
|
1052 |
// Make sure the header exists, because we don't want to generate new compilation errors... |
|
1053 |
for( stringvector::iterator ip = currIncPaths.begin(); ip != currIncPaths.end(); ++ip ) |
|
1054 |
{
|
|
1055 |
// START -- Support for multiple header directories |
|
1056 |
list<pair<string, bool> > fullIncPath = BBCFileUtils::MergeDirs( *ip, *i ); |
|
1057 |
list<pair<string, bool> >::iterator fulliterbegin = fullIncPath.begin(); |
|
1058 |
for(; fulliterbegin != fullIncPath.end(); fulliterbegin++) |
|
1059 |
{
|
|
1060 |
if( find(iCurrIncludes.begin(), iCurrIncludes.end(), fulliterbegin->first) == iCurrIncludes.end() ) |
|
1061 |
{
|
|
1062 |
if( BBCFileUtils::FileExists(fulliterbegin->first) ) |
|
1063 |
{
|
|
1064 |
iCurrIncludes.push_back(fulliterbegin->first); |
|
1065 |
exists = true; |
|
1066 |
break; |
|
1067 |
} |
|
1068 |
} |
|
1069 |
} |
|
1070 |
// END -- Support for multiple header directories |
|
1071 |
} |
|
1072 |
if( exists == false ) |
|
1073 |
{
|
|
1074 |
// Try to find the included header from the same directory than the header itself is: |
|
1075 |
// START -- Support for multiple header directories |
|
1076 |
list<pair<string, bool> > fullIncPath = |
|
1077 |
BBCFileUtils::MergeDirs(iParams.getParameter(CURRENTDIR), currHeader->Path() + DIR_SEPARATOR + *i); |
|
1078 |
list<pair<string, bool> >::iterator fulliterbegin = fullIncPath.begin(); |
|
1079 |
for(; fulliterbegin != fullIncPath.end(); fulliterbegin++) |
|
1080 |
{
|
|
1081 |
if( BBCFileUtils::FileExists(fulliterbegin->first) ) |
|
1082 |
{
|
|
1083 |
iCurrIncludes.push_back(fulliterbegin->first); |
|
1084 |
} |
|
1085 |
} |
|
1086 |
// END -- Support for multiple header directories |
|
1087 |
} |
|
1088 |
} |
|
1089 |
// Add this header to the list: |
|
1090 |
if( find(iCurrIncludes.begin(), iCurrIncludes.end(), currHeader->ID()) == iCurrIncludes.end()) |
|
1091 |
{
|
|
1092 |
iCurrIncludes.push_back(currHeader->ID()); |
|
1093 |
} |
|
1094 |
||
1095 |
forcedHeader = DIR_SEPARATOR + forcedHeader; |
|
1096 |
forcedHeader = base + forcedHeader; |
|
1097 |
if( BBCFileUtils::isValidFilename(forcedHeader) ) |
|
1098 |
if( find(iCurrIncludes.begin(), iCurrIncludes.end(), forcedHeader) == iCurrIncludes.end()) |
|
1099 |
iCurrIncludes.insert(iCurrIncludes.begin(),forcedHeader); |
|
1100 |
||
1101 |
} |
|
1102 |
} |
|
1103 |
} |
|
1104 |
// Build include paths for parser objects: |
|
1105 |
string bIP; |
|
1106 |
for( stringvector::iterator i = baseIncPaths.begin(); i != baseIncPaths.end(); ++i ) |
|
1107 |
{
|
|
1108 |
if( i != baseIncPaths.begin() ) |
|
1109 |
bIP += ";"; |
|
1110 |
||
1111 |
bIP += *i; |
|
1112 |
} |
|
1113 |
||
1114 |
string cIP; |
|
1115 |
for( stringvector::iterator i = currIncPaths.begin(); i != currIncPaths.end(); ++i ) |
|
1116 |
{
|
|
1117 |
if( i != currIncPaths.begin() ) |
|
1118 |
cIP += ";"; |
|
1119 |
||
1120 |
cIP += *i; |
|
1121 |
} |
|
1122 |
||
1123 |
// Construct parsers: |
|
1124 |
auto_ptr<CPPParser> parser(new CPPParser(bIP)); |
|
1125 |
auto_ptr<CPPParser> parser2(new CPPParser(cIP)); |
|
1126 |
||
1127 |
// Set temp directories for parsers |
|
1128 |
parser->setTemp(iParams.getParameter(TEMPDIR)); |
|
1129 |
parser2->setTemp(iParams.getParameter(TEMPDIR)); |
|
1130 |
||
1131 |
// Set forced headers |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1132 |
parser->setForcedHeaders(iForcedBaselineHeaders); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1133 |
parser2->setForcedHeaders(iForcedCurrentHeaders); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1134 |
|
| 0 | 1135 |
if (createThread) |
1136 |
{
|
|
1137 |
//if the number of threads in this group has reached pre-defined max count, destroy all the threads in this group before creating one. |
|
1138 |
//boost::thread_group object does not destroy a thread when it goes to completion. if the threads are not destroyed lot of memory will be eaten up unneccessarily |
|
1139 |
if(gHeaderThreads.size() >= MAX_THREAD_COUNT) |
|
1140 |
{
|
|
1141 |
||
1142 |
gHeaderThreads.join_all(); |
|
1143 |
int size = gHeaderThreads.size(); |
|
1144 |
for(int i=0;i<size;i++) |
|
1145 |
{
|
|
1146 |
gHeaderThreads.remove_thread(gpComponentThreads[i]); |
|
1147 |
gpComponentThreads[i]->~thread(); |
|
1148 |
} |
|
1149 |
} |
|
1150 |
||
1151 |
//create a copy of the Analyser object for the new thread |
|
1152 |
Analyser* obj = new Analyser(); |
|
1153 |
*obj = *this; |
|
1154 |
int size = gHeaderThreads.size(); |
|
1155 |
gpComponentThreads[size]=gHeaderThreads.create_thread(boost::bind(&Analyser::Wrapper,obj, boost::ref(report), boost::ref(issues), *(parser.get()), *(parser2.get()), boost::ref(pfHeaders), boost::ref(unsuccessfulHdrs))); |
|
1156 |
} |
|
1157 |
else //do not create different thread for the second time when AnalyzePlatforms is called recurssively |
|
1158 |
{
|
|
1159 |
Wrapper(report, issues, *(parser.get()), *(parser2.get()), pfHeaders, unsuccessfulHdrs); |
|
1160 |
} |
|
1161 |
} |
|
1162 |
} |
|
1163 |
||
1164 |
} |
|
1165 |
||
1166 |
// ---------------------------------------------------------------------------- |
|
1167 |
// Analyser::InitializePlatforms |
|
1168 |
// |
|
1169 |
// |
|
1170 |
// ---------------------------------------------------------------------------- |
|
1171 |
// |
|
1172 |
void Analyser::InitializePlatforms(PlatformHeaders& pfHeaders, vector<pair<string, string> >& headers, |
|
1173 |
vector<pair<string, string> >& excludeheaders, vector<pair<string, string> >& resourcevector) |
|
1174 |
{
|
|
1175 |
if( iBasePlatformData ) |
|
1176 |
delete iBasePlatformData; |
|
1177 |
if( iProductPlatformData ) |
|
1178 |
delete iProductPlatformData; |
|
1179 |
||
1180 |
iBasePlatformData = new PlatformData(iParams.getParameter(BASELINEVERSION), |
|
1181 |
iParams.getParameter(BASELINEDIR)); |
|
1182 |
iProductPlatformData = new PlatformData(iParams.getParameter(CURRENTVERSION), |
|
1183 |
iParams.getParameter(CURRENTDIR)); |
|
1184 |
||
1185 |
if( iUseBaselinePlatformData ) |
|
1186 |
iBasePlatformData->Initialize(iParams.getParameter(BASEPLATFORMDATA)); |
|
1187 |
if( iUseCurrentPlatformData ) |
|
1188 |
iProductPlatformData->Initialize(iParams.getParameter(CURRENTPLATFORMDATA)); |
|
1189 |
||
1190 |
vector<pair<string, string> > updatedHdrs; |
|
1191 |
updatedHdrs.reserve(headers.size()); |
|
1192 |
||
1193 |
// Mark the platform header objects with status 'HDR_STATUS_TO_BE_ANALYZED': |
|
1194 |
vector<pair<string, string> >::const_iterator hdr = headers.begin(); |
|
1195 |
||
1196 |
for( ;hdr != headers.end(); ++hdr ) |
|
1197 |
{
|
|
1198 |
pair<string,stringpair> headerInfo; |
|
1199 |
bool is_Resource = false; |
|
1200 |
int loc = -1; |
|
1201 |
pair<string,string> resource; |
|
1202 |
Header* baseHdrObj = 0; |
|
1203 |
Header* currHdrObj = 0; |
|
1204 |
string hdrTest(hdr->first); |
|
1205 |
toLower(hdrTest); |
|
1206 |
||
1207 |
// Check whether the header is a resource file. If, so add it to resource vector instead of pfheaders. |
|
1208 |
if( (loc = int(hdrTest.find_last_of("."))) != string::npos &&
|
|
1209 |
hdrTest.substr(loc,string::npos) == RH_EXTENSION ) |
|
1210 |
{
|
|
1211 |
is_Resource = true; |
|
1212 |
resource.first = hdrTest; |
|
1213 |
} |
|
1214 |
CFileMap::const_iterator bI = iBasePlatformData->HeadersById().find(hdrTest); |
|
1215 |
if( bI != iBasePlatformData->HeadersById().end() ) |
|
1216 |
{
|
|
1217 |
baseHdrObj = dynamic_cast<Header*>((*bI).second); |
|
1218 |
} |
|
1219 |
||
1220 |
hdrTest = hdr->second; |
|
1221 |
toLower(hdrTest); |
|
1222 |
if(is_Resource == true) |
|
1223 |
{
|
|
1224 |
resource.second = hdrTest; |
|
1225 |
resourcevector.push_back(resource); |
|
1226 |
} |
|
1227 |
||
1228 |
CFileMap::const_iterator cI = iProductPlatformData->HeadersById().find(hdrTest); |
|
1229 |
if( cI != iProductPlatformData->HeadersById().end() ) |
|
1230 |
{
|
|
1231 |
currHdrObj = dynamic_cast<Header*>((*cI).second); |
|
1232 |
} |
|
1233 |
||
1234 |
if(baseHdrObj && baseHdrObj->Status()== Header::HDR_STATUS_IGNORE ) |
|
1235 |
{
|
|
1236 |
excludeheaders.push_back(*hdr); |
|
1237 |
} |
|
1238 |
else if( baseHdrObj && currHdrObj ) |
|
1239 |
{
|
|
1240 |
if( is_Resource == false) |
|
1241 |
{
|
|
1242 |
pfHeaders.push_back(HeaderPair(baseHdrObj, currHdrObj)); |
|
1243 |
baseHdrObj->SetStatus(Header::HDR_STATUS_TO_BE_ANALYZED); |
|
1244 |
currHdrObj->SetStatus(Header::HDR_STATUS_TO_BE_ANALYZED); |
|
1245 |
} |
|
1246 |
||
1247 |
// get API info from current header |
|
1248 |
if(currHdrObj->APIinfo().first.size() > 0) |
|
1249 |
{
|
|
1250 |
headerInfo.first = currHdrObj->ID(); |
|
1251 |
headerInfo.second.first = currHdrObj->APIinfo().first; // API NAME |
|
1252 |
headerInfo.second.second = currHdrObj->APIinfo().second; // API REL. CATEGORY |
|
1253 |
} |
|
1254 |
||
1255 |
} |
|
1256 |
else |
|
1257 |
{
|
|
1258 |
// get API info from base header |
|
1259 |
if(baseHdrObj && baseHdrObj->APIinfo().first.size() > 0) |
|
1260 |
{
|
|
1261 |
headerInfo.first = baseHdrObj->ID(); |
|
1262 |
headerInfo.second.first = baseHdrObj->APIinfo().first; // API NAME |
|
1263 |
headerInfo.second.second = baseHdrObj->APIinfo().second; // API REL. CATEGORY |
|
1264 |
||
1265 |
} |
|
1266 |
// get API info from current header |
|
1267 |
else if(currHdrObj && currHdrObj->APIinfo().first.size() > 0) |
|
1268 |
{
|
|
1269 |
headerInfo.first = currHdrObj->ID(); |
|
1270 |
headerInfo.second.first = currHdrObj->APIinfo().first; // API NAME |
|
1271 |
headerInfo.second.second = currHdrObj->APIinfo().second; // API REL. CATEGORY |
|
1272 |
} |
|
1273 |
// No info found from platform data, so use common include paths and |
|
1274 |
// other common compile-time parameters for this header: |
|
1275 |
if( is_Resource == false) |
|
1276 |
updatedHdrs.push_back(*hdr); |
|
1277 |
} |
|
1278 |
// Fill the headers having API Info in global vector, so that report generator can access it. |
|
1279 |
if(headerInfo.first.size() > 0) |
|
1280 |
{
|
|
1281 |
HeaderInfoList.push_back(headerInfo); |
|
1282 |
} |
|
1283 |
} |
|
1284 |
headers = updatedHdrs; |
|
1285 |
} |
|
1286 |
||
1287 |
// ---------------------------------------------------------------------------- |
|
1288 |
// Analyser::analyse |
|
1289 |
// Do the actual analyse of headers |
|
1290 |
// Create analysis report |
|
1291 |
// ---------------------------------------------------------------------------- |
|
1292 |
// |
|
1293 |
int Analyser::analyse() |
|
1294 |
{
|
|
1295 |
// Local variable instantiation |
|
1296 |
int ret = 0; |
|
1297 |
iHeaderSetInUse = false; |
|
1298 |
iUseThread = false; |
|
1299 |
string epocroot; |
|
1300 |
int bundlesize = 1; |
|
1301 |
unsigned int amount, amount2; |
|
1302 |
iOnlySystemIncludeRequired = false; |
|
1303 |
unsigned int excludedHeaderSize; |
|
1304 |
||
1305 |
if (processParameters() == 2) return 2; |
|
1306 |
||
1307 |
// Get the bundle size (as string) and convert it to an integer |
|
1308 |
bundlesize = handleBundlesizeParam(); |
|
1309 |
||
1310 |
// Get replace parameter for file renaming |
|
1311 |
string replace = getReplaceParam(); |
|
1312 |
||
1313 |
// Update the amount of found files |
|
1314 |
amount = (unsigned int)iFiles.size(); |
|
1315 |
// Update the amount of found files |
|
1316 |
amount2 = (unsigned int)iFiles2.size(); |
|
1317 |
||
1318 |
// Vector that holds the merge results and if it can't find baseline |
|
1319 |
// file from current file it will put empty string as current file |
|
1320 |
vector<pair<string,string> > mergeVector; |
|
1321 |
mergeVector.reserve(amount); |
|
1322 |
||
1323 |
// List holds files which were found in current but not in baseline. |
|
1324 |
// Full path |
|
1325 |
list<string> addedFiles; |
|
1326 |
||
1327 |
// List holds files which were in baseline file list but |
|
1328 |
// weren't in current file list, ie they were removed. |
|
1329 |
// Contains full path with filename |
|
1330 |
list<string> removedFiles; |
|
1331 |
try |
|
1332 |
{
|
|
1333 |
// Merges baseline and current files into one vector |
|
1334 |
MergeFiles(iFiles, iFiles2, replace, mergeVector); |
|
1335 |
||
1336 |
// Finds removed files |
|
1337 |
fileDiffs(mergeVector, removedFiles); |
|
1338 |
} |
|
1339 |
catch (HAException e) |
|
1340 |
{
|
|
1341 |
cout << "Error in processing file lists:\n" << e.errorMessage() << "\n"; |
|
1342 |
exit(4); |
|
1343 |
} |
|
1344 |
||
1345 |
// Mergemap now contains pairs of following type: |
|
1346 |
// baseline complex filename (w/ absolute path) -> current version complex filename (w/ absolute path) |
|
1347 |
_total_files = (unsigned int)mergeVector.size(); |
|
1348 |
||
1349 |
cout << "\nTotal baseline files: " << amount << "\nTotal current files: " << amount2 << "\nFile pairs found: " |
|
1350 |
<< _total_files << "\n"; |
|
1351 |
||
1352 |
cout << "\nComparing " << _total_files << " matching files between\n " << iParams.getParameter(BASELINEDIR) |
|
1353 |
<< " (Version " << iParams.getParameter(BASELINEVERSION) << ")\nand\n " << iParams.getParameter(CURRENTDIR) |
|
1354 |
<< " (Version " << iParams.getParameter(CURRENTVERSION) << ")\n\n\n\n"; |
|
1355 |
||
1356 |
||
1357 |
ReportGenerator report(iParams.getParameter(REPORTFILE)); |
|
1358 |
report.setCmdLineParms(iParams.getGivenParameters()); |
|
1359 |
report.setVersions(iParams.getParameter(BASELINEVERSION),iParams.getParameter(CURRENTVERSION)); |
|
1360 |
report.setXSL("BBCResults.xsl",false);
|
|
1361 |
||
1362 |
||
1363 |
report.startReport(); |
|
1364 |
// start the timer |
|
1365 |
time_t starttime; |
|
1366 |
time_t endtime; |
|
1367 |
starttime = time(NULL); |
|
1368 |
||
1369 |
PlatformHeaders pfHeaders; |
|
1370 |
pfHeaders.reserve(mergeVector.size()); |
|
1371 |
||
1372 |
// Vector that holds the the headers those should be excluded from analysis. |
|
1373 |
// These header files are mentioned in platform headers |
|
1374 |
vector<pair<string,string> > excludeHeaders; |
|
1375 |
excludeHeaders.reserve(mergeVector.size()); |
|
1376 |
||
1377 |
||
1378 |
// Headers that are found from platform data are inserted in pfHeaders. |
|
1379 |
// Others are left to mergeVector. |
|
1380 |
vector<pair<string, string> > resourceVector; |
|
1381 |
resourceVector.reserve(mergeVector.size()); |
|
1382 |
||
1383 |
if(mergeVector.size() > 0 ) |
|
1384 |
InitializePlatforms(pfHeaders, mergeVector,excludeHeaders,resourceVector); |
|
1385 |
excludedHeaderSize = int(excludeHeaders.size()); |
|
1386 |
||
1387 |
endtime = time(NULL); |
|
1388 |
time_t pfInitTime = endtime - starttime; |
|
1389 |
time_t originalStartTime = starttime; |
|
1390 |
starttime = time(NULL); |
|
1391 |
||
1392 |
//Now analyse Resource Header RH files using text parser |
|
1393 |
if(resourceVector.size()>0) |
|
1394 |
ParseAndCompareResourceFiles(resourceVector, report); |
|
1395 |
||
1396 |
// Process each removed filename from removedMap |
|
1397 |
list<string>::iterator removedbegin = removedFiles.begin(); |
|
1398 |
list<string>::iterator removedend = removedFiles.end(); |
|
1399 |
for(; removedbegin != removedend; removedbegin++) |
|
1400 |
{
|
|
1401 |
string filename = *removedbegin; |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1402 |
report.addIssue(filename, "", EIssueIdentityFile, EIssueTypeRemoval, ESeverityBBCBreak, ESeveritySCBreak, "", 0,"", "",""); |
| 0 | 1403 |
} |
1404 |
||
1405 |
int issues = 0; |
|
1406 |
PlatformHeaders unsuccessfulHeaders; |
|
1407 |
vector<pair<string, string> > unsuccessfulHeaderNames; |
|
1408 |
vector<pair<string, string> > platformUnsuccessfulHeaderNames; |
|
1409 |
int compErrors = 0; |
|
1410 |
||
1411 |
//validate if the headers have include guards, |
|
1412 |
//move ones without guards for individual compilation |
|
1413 |
validateHeaders(mergeVector, unsuccessfulHeaderNames); |
|
1414 |
||
1415 |
boost::thread_group mainThreads; |
|
1416 |
int mergeVectorCompErrs = 0; |
|
1417 |
int unsuccessfulCompErrs = 0; |
|
1418 |
int platformUnsuccessfulCompErrs = 0; |
|
1419 |
||
1420 |
// Analyse headers that were not found from platform data: |
|
1421 |
if( mergeVector.size() > 0 ) |
|
1422 |
{
|
|
1423 |
//create copy of Analyser object for the new thread |
|
1424 |
Analyser* obj1=new Analyser(); |
|
1425 |
*obj1=*this; |
|
1426 |
//analyse mergeVector in different thread |
|
1427 |
mainThreads.create_thread(boost::bind(&Analyser::AnalyseHeaders,obj1,boost::ref(mergeVector),bundlesize,boost::ref(report),boost::ref(issues),boost::ref(mergeVectorCompErrs))); |
|
1428 |
} |
|
1429 |
||
1430 |
// Compile unsuccessful headers one by one, because it is unlikely that they |
|
1431 |
// will be compiled successfully here either: |
|
1432 |
if( unsuccessfulHeaderNames.size() > 0 ) |
|
1433 |
{
|
|
1434 |
//create copy of Analyser object for the new thread |
|
1435 |
Analyser* obj2 = new Analyser(); |
|
1436 |
*obj2=*this; |
|
1437 |
//analyse unsuccessfulHeaderNames in different thread |
|
1438 |
mainThreads.create_thread(boost::bind(&Analyser::AnalyseHeaders,obj2,boost::ref(unsuccessfulHeaderNames),1,boost::ref(report),boost::ref(issues),boost::ref(unsuccessfulCompErrs))); |
|
1439 |
} |
|
1440 |
||
1441 |
if(pfHeaders.size() > 0) |
|
1442 |
{
|
|
1443 |
AnalyzePlatforms(pfHeaders, unsuccessfulHeaders, report, issues, iUseThread); |
|
1444 |
if (iUseThread) |
|
1445 |
{
|
|
1446 |
gHeaderThreads.join_all(); // wait for all threads in gHeaderThreads to complete |
|
1447 |
gComponentThreads.join_all(); // wait for all threads in gComponentThreads to complete |
|
1448 |
||
1449 |
//destroy the thredas in gHeaderThreads |
|
1450 |
int size = gHeaderThreads.size(); |
|
1451 |
for (int i=0;i<size;i++) |
|
1452 |
{
|
|
1453 |
gHeaderThreads.remove_thread(gpComponentThreads[i]); |
|
1454 |
gpComponentThreads[i]->~thread(); |
|
1455 |
} |
|
1456 |
||
1457 |
//destroy the thredas in gComponentThreads |
|
1458 |
size=gComponentThreads.size(); |
|
1459 |
for (int i=0;i<size;i++) |
|
1460 |
{
|
|
1461 |
gComponentThreads.remove_thread(gpHeaderThreads[i]); |
|
1462 |
gpHeaderThreads[i]->~thread(); |
|
1463 |
} |
|
1464 |
} |
|
1465 |
||
1466 |
for( PlatformHeaders::iterator i = unsuccessfulHeaders.begin(); i != unsuccessfulHeaders.end(); ++i ) |
|
1467 |
{
|
|
1468 |
// Build list of headers that could not be compiled with platform data: |
|
1469 |
platformUnsuccessfulHeaderNames.push_back(pair<string, string>(i->first->ID(), i->second->ID())); |
|
1470 |
} |
|
1471 |
||
1472 |
if(platformUnsuccessfulHeaderNames.size() >0) |
|
1473 |
AnalyseHeaders(platformUnsuccessfulHeaderNames, 1, report, issues, platformUnsuccessfulCompErrs); |
|
1474 |
} |
|
1475 |
||
1476 |
mainThreads.join_all(); // wait for all threads in mainThreads to complete |
|
1477 |
compErrors += mergeVectorCompErrs + unsuccessfulCompErrs + platformUnsuccessfulCompErrs; |
|
1478 |
report.finishReport(); |
|
1479 |
||
1480 |
// List number of files which had compilation errors and could not be compiled |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1481 |
if ( _current_files + (int)excludedHeaderSize < _total_files ) |
| 0 | 1482 |
cout << "\n" << ( _total_files - (_current_files + excludedHeaderSize) ) <<" files out of " << _total_files << " had some issues and could not be analysed.\n" << endl; |
1483 |
||
1484 |
// Wrap up the run and print statistics |
|
1485 |
unsigned int count = _total_files * 2; |
|
1486 |
||
1487 |
endtime = time(NULL); |
|
1488 |
time_t runningtime = endtime - starttime; |
|
1489 |
double timedelta = 0.0; |
|
1490 |
if (count > 0) |
|
1491 |
{
|
|
1492 |
timedelta = (double)runningtime/(double)count; |
|
1493 |
} |
|
1494 |
cout << "\n"; |
|
1495 |
cout << "---------------------------------------------" << endl; |
|
1496 |
cout << "Finished!" << endl; |
|
1497 |
cout << "Files processed: " << count << endl; |
|
1498 |
cout << "Total time: " << endtime - originalStartTime << " seconds." << endl; |
|
1499 |
cout << "Platform data initialization time: " << pfInitTime << " seconds.\n"; |
|
1500 |
cout << "Compilation and analysis time: " << (long)runningtime << " seconds (Average: "<<timedelta<<" seconds per file).\n"; |
|
1501 |
cout << "Compilation errors: " << compErrors << endl; |
|
1502 |
if(excludedHeaderSize > 0 ) |
|
1503 |
cout << "No of excluded headers: " << excludedHeaderSize << endl; |
|
1504 |
cout << "---------------------------------------------" << endl; |
|
1505 |
||
1506 |
if (iNotRemovedFiles.size() != 0) |
|
1507 |
{
|
|
1508 |
cout << iNotRemovedFiles.size() << "\n"; |
|
1509 |
list<string> tempvar; |
|
1510 |
list<string>::iterator removefile = iNotRemovedFiles.begin(); |
|
1511 |
list<string>::iterator fileend = iNotRemovedFiles.end(); |
|
1512 |
for(; removefile != fileend; removefile++) |
|
1513 |
{
|
|
1514 |
CPPParser::RemoveFile(*removefile, tempvar); |
|
1515 |
} |
|
1516 |
if (tempvar.size() != 0) |
|
1517 |
{
|
|
1518 |
iNotRemovedFiles = tempvar; |
|
1519 |
} else |
|
1520 |
{
|
|
1521 |
iNotRemovedFiles.clear(); |
|
1522 |
} |
|
1523 |
} |
|
1524 |
||
1525 |
if (ret == 0 && issues != 0) |
|
1526 |
{
|
|
1527 |
ret = 1; |
|
1528 |
} |
|
1529 |
return ret; |
|
1530 |
} |
|
1531 |
||
1532 |
void Analyser::AnalyseHeaders(const vector<pair<string, string> >& headerList, int bundlesize, ReportGenerator& report, int& issues, int& compErrors) |
|
1533 |
{
|
|
1534 |
unsigned int processedcount = 1; |
|
1535 |
stringvector basefilenames; |
|
1536 |
stringvector curfilenames; |
|
1537 |
vector<pair<string, string> > unsuccessfulHeaders; |
|
1538 |
||
1539 |
vector<pair<string, string> >::const_iterator fnmapiter = headerList.begin(); |
|
1540 |
while (fnmapiter != headerList.end()) |
|
1541 |
{
|
|
1542 |
// Push the pair's members to their respective vectors |
|
1543 |
// for bundle handling |
|
1544 |
basefilenames.push_back(fnmapiter->first); |
|
1545 |
curfilenames.push_back(fnmapiter->second); |
|
1546 |
||
1547 |
// If a bundle is full or the item is the last one to process, |
|
1548 |
// we parse the current file lists to xml files |
|
1549 |
if ((processedcount > 0 && (processedcount % bundlesize == 0)) || |
|
1550 |
processedcount == headerList.size()) |
|
1551 |
{
|
|
1552 |
if (!AnalyseBundle(basefilenames,curfilenames,report, issues)) |
|
1553 |
{
|
|
1554 |
//If there where parsing errors in a bundle, we try to compile each header |
|
1555 |
// one by one |
|
1556 |
stringvector::iterator basebegin = basefilenames.begin(); |
|
1557 |
stringvector::iterator baseend = basefilenames.end(); |
|
1558 |
stringvector::iterator currentbegin = curfilenames.begin(); |
|
1559 |
||
1560 |
if( basefilenames.size() == 1 || |
|
1561 |
bundlesize == 1 ) |
|
1562 |
||
1563 |
{
|
|
1564 |
if( basebegin != baseend ) |
|
1565 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1566 |
//Add compilation error to the report |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1567 |
string compilationError = iCompErrTxt; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1568 |
report.addIssue((*basebegin), "", EIssueIdentityFile, EIssueTypeCompilationError, ESeverityBBCBreak, ESeveritySCBreak, "", 0,"", |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1569 |
(*currentbegin),compilationError); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1570 |
issues++; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1571 |
|
| 0 | 1572 |
compErrors++; |
1573 |
} |
|
1574 |
} |
|
1575 |
else |
|
1576 |
{
|
|
1577 |
while(basebegin != baseend ) |
|
1578 |
{
|
|
1579 |
stringvector basefilename; |
|
1580 |
stringvector curfilename; |
|
1581 |
basefilename.push_back(*basebegin); |
|
1582 |
curfilename.push_back(*currentbegin); |
|
1583 |
if (!AnalyseBundle(basefilename,curfilename,report, issues)) |
|
1584 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1585 |
//Add compilation error to the report |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1586 |
string compilationError = iCompErrTxt; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1587 |
report.addIssue((*basebegin), "", EIssueIdentityFile, EIssueTypeCompilationError, ESeverityBBCBreak, ESeveritySCBreak, "", 0,"", |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1588 |
(*currentbegin),compilationError); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1589 |
issues++; |
| 0 | 1590 |
compErrors++; |
1591 |
} |
|
1592 |
basebegin++; |
|
1593 |
currentbegin++; |
|
1594 |
} |
|
1595 |
} |
|
1596 |
} |
|
1597 |
basefilenames.clear(); |
|
1598 |
curfilenames.clear(); |
|
1599 |
} |
|
1600 |
||
1601 |
fnmapiter++; |
|
1602 |
processedcount++; |
|
1603 |
} |
|
1604 |
||
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1605 |
if (iNotRemovedFiles.size() != 0) |
| 0 | 1606 |
{
|
1607 |
list<string> tempvar; |
|
1608 |
list<string>::iterator removefile = iNotRemovedFiles.begin(); |
|
1609 |
list<string>::iterator fileend = iNotRemovedFiles.end(); |
|
1610 |
for(; removefile != fileend; removefile++) |
|
1611 |
{
|
|
1612 |
CPPParser::RemoveFile(*removefile, tempvar); |
|
1613 |
} |
|
1614 |
if (tempvar.size() != 0) |
|
1615 |
{
|
|
1616 |
iNotRemovedFiles = tempvar; |
|
1617 |
} |
|
1618 |
else |
|
1619 |
{
|
|
1620 |
iNotRemovedFiles.clear(); |
|
1621 |
} |
|
1622 |
} |
|
1623 |
||
1624 |
} |
|
1625 |
||
1626 |
// ---------------------------------------------------------------------------- |
|
1627 |
// Analyser::AnalyseBundle |
|
1628 |
// ---------------------------------------------------------------------------- |
|
1629 |
// |
|
1630 |
//bool Analyser::AnalyseBundle(const stringvector& basefilenames, const stringvector& curfilenames, ReportGenerator& report, int& issues) |
|
1631 |
bool Analyser::AnalyseBundle(const stringvector& basefilenames, |
|
1632 |
const stringvector& curfilenames, |
|
1633 |
ReportGenerator& report, |
|
1634 |
int& issues, |
|
1635 |
CPPParser* baseParser, |
|
1636 |
CPPParser* currParser, |
|
1637 |
stringvector* basecompileset, |
|
1638 |
stringvector* currcompileset) |
|
1639 |
{
|
|
1640 |
auto_ptr<CPPParser> baseAutoPtr; |
|
1641 |
auto_ptr<CPPParser> currAutoPtr; |
|
1642 |
CPPParser* parser = 0; |
|
1643 |
CPPParser* parser2 = 0; |
|
1644 |
||
1645 |
if( baseParser ) |
|
1646 |
{
|
|
1647 |
// This function does not own the pointer, so no auto_ptr used here. |
|
1648 |
parser = baseParser; |
|
1649 |
} |
|
1650 |
else |
|
1651 |
{
|
|
1652 |
parser = new CPPParser(iParams.getParameter(BASELINEPLAT)); |
|
1653 |
// Set temp directory for parser |
|
1654 |
parser->setTemp(iParams.getParameter(TEMPDIR)); |
|
1655 |
// Set forced headers |
|
1656 |
parser->setForcedHeaders(iForcedBaselineHeaders); |
|
1657 |
// Wrap allocated memory to an auto_ptr to get it deallocated properly. |
|
1658 |
baseAutoPtr.reset(parser); |
|
1659 |
} |
|
1660 |
if( currParser ) |
|
1661 |
{
|
|
1662 |
// This function does not own the pointer, so no auto_ptr used here. |
|
1663 |
parser2 = currParser; |
|
1664 |
} |
|
1665 |
else |
|
1666 |
{
|
|
1667 |
parser2 = new CPPParser(iParams.getParameter(CURRENTPLAT)); |
|
1668 |
// Set temp directory for parser |
|
1669 |
parser2->setTemp(iParams.getParameter(TEMPDIR)); |
|
1670 |
// Set forced headers |
|
1671 |
parser2->setForcedHeaders(iForcedCurrentHeaders); |
|
1672 |
// Wrap allocated memory to an auto_ptr to get it deallocated properly. |
|
1673 |
currAutoPtr.reset(parser2); |
|
1674 |
} |
|
1675 |
||
1676 |
try |
|
1677 |
{
|
|
1678 |
// Parse the filename vectors into XML and eventually into a DOM format |
|
1679 |
DOMNode* root = 0; |
|
1680 |
DOMNode* root2 = 0; |
|
1681 |
if(basecompileset && basecompileset->size() != 0 ) |
|
1682 |
{
|
|
1683 |
root = parser->parse(*basecompileset, "base", iParams.getParameter(BASELINEDIR), iNotRemovedFiles); |
|
1684 |
} |
|
1685 |
else |
|
1686 |
{
|
|
1687 |
root = parser->parse(basefilenames, "base", iParams.getParameter(BASELINEDIR), iNotRemovedFiles); |
|
1688 |
} |
|
1689 |
if(currcompileset && currcompileset->size() != 0 ) |
|
1690 |
{
|
|
1691 |
root2 = parser2->parse(*currcompileset, "current", iParams.getParameter(CURRENTDIR), iNotRemovedFiles); |
|
1692 |
} |
|
1693 |
else |
|
1694 |
{
|
|
1695 |
root2 = parser2->parse(curfilenames, "current", iParams.getParameter(CURRENTDIR), iNotRemovedFiles); |
|
1696 |
} |
|
1697 |
||
1698 |
MacroAnalyser macros(parser->getMacroFilename(), parser2->getMacroFilename(), basefilenames, curfilenames); |
|
1699 |
||
1700 |
macros.Analyse(iMacroFiles); |
|
1701 |
||
1702 |
#if !defined(_DEBUG) && !defined(DEBUG) |
|
1703 |
parser->RemoveFile(parser->getMacroFilename(), iNotRemovedFiles); |
|
1704 |
parser2->RemoveFile(parser2->getMacroFilename(), iNotRemovedFiles); |
|
1705 |
parser->RemoveFile(parser->getCompErrFile(), iNotRemovedFiles); |
|
1706 |
parser2->RemoveFile(parser2->getCompErrFile(), iNotRemovedFiles); |
|
1707 |
#endif |
|
1708 |
// Merged macros |
|
1709 |
// |
|
1710 |
list<pair<string,string> > mergedfiles; |
|
1711 |
stringvector::const_iterator basebegin = basefilenames.begin(); |
|
1712 |
stringvector::const_iterator baseend = basefilenames.end(); |
|
1713 |
stringvector::const_iterator currentbegin = curfilenames.begin(); |
|
1714 |
while(basebegin != baseend) |
|
1715 |
{
|
|
1716 |
mergedfiles.push_back(pair<string,string>(*basebegin,*currentbegin)); |
|
1717 |
basebegin++; |
|
1718 |
currentbegin++; |
|
1719 |
} |
|
1720 |
if(mergedfiles.size() > 0) |
|
1721 |
{
|
|
1722 |
issues += analyseTrees(root, root2,mergedfiles,report); |
|
1723 |
} |
|
1724 |
||
1725 |
// Duplicated macros |
|
1726 |
// |
|
1727 |
// Base duplicates |
|
1728 |
map<string, vector<pair<string,string> > >& duplicatedMacros = macros.getBaseDuplicates(); |
|
1729 |
map<string, vector<pair<string,string> > >::iterator duplicatedbegin = duplicatedMacros.begin(); |
|
1730 |
map<string, vector<pair<string,string> > >::iterator duplicatedend = duplicatedMacros.end(); |
|
1731 |
for(; duplicatedbegin != duplicatedend; duplicatedbegin++) |
|
1732 |
{
|
|
1733 |
string filename = duplicatedbegin->first; |
|
1734 |
// Process each duplicated macro from duplicatedMacros |
|
1735 |
vector<pair<string,string> >::iterator duplicatedbegin2 = duplicatedbegin->second.begin(); |
|
1736 |
vector<pair<string,string> >::iterator duplicatedend2 = duplicatedbegin->second.end(); |
|
1737 |
for(; duplicatedbegin2 != duplicatedend2; duplicatedbegin2++) |
|
1738 |
{
|
|
1739 |
string macroname = duplicatedbegin2->first; |
|
1740 |
int lineNo = atoi(duplicatedbegin2->second.c_str()); |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1741 |
report.addIssue(filename, macroname, EIssueIdentityMacro, EIssueTypeNotAnalysed, ESeverityInformative, ESeveritySCInformative, "", lineNo, "","", ""); |
| 0 | 1742 |
issues++; |
1743 |
} |
|
1744 |
} |
|
1745 |
||
1746 |
// Current |
|
1747 |
map<string, vector<pair<string,string> > >& currDuplicatedMacros = macros.getCurrentDuplicates(); |
|
1748 |
duplicatedbegin = currDuplicatedMacros.begin(); |
|
1749 |
duplicatedend = currDuplicatedMacros.end(); |
|
1750 |
for(; duplicatedbegin != duplicatedend; duplicatedbegin++) |
|
1751 |
{
|
|
1752 |
string filename = duplicatedbegin->first; |
|
1753 |
// Process each duplicated macro from duplicatedMacros |
|
1754 |
vector<pair<string,string> >::iterator duplicatedbegin2 = duplicatedbegin->second.begin(); |
|
1755 |
vector<pair<string,string> >::iterator duplicatedend2 = duplicatedbegin->second.end(); |
|
1756 |
for(; duplicatedbegin2 != duplicatedend2; duplicatedbegin2++) |
|
1757 |
{
|
|
1758 |
string macroname = duplicatedbegin2->first; |
|
1759 |
int lineNo = atoi(duplicatedbegin2->second.c_str()); |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1760 |
report.addIssue("", macroname, EIssueIdentityMacro, EIssueTypeNotAnalysed, ESeverityInformative, ESeveritySCInformative, "", lineNo,"", filename, "");
|
| 0 | 1761 |
issues++; |
1762 |
} |
|
1763 |
} |
|
1764 |
||
1765 |
// Removed macros |
|
1766 |
// |
|
1767 |
map<string, TChange<list<pair<string,string> > > >& removedMacros = macros.getRemoved(); |
|
1768 |
map<string, TChange<list<pair<string,string> > > >::iterator removedbegin = removedMacros.begin(); |
|
1769 |
map<string, TChange<list<pair<string,string> > > >::iterator removedend = removedMacros.end(); |
|
1770 |
for(; removedbegin != removedend; removedbegin++) |
|
1771 |
{
|
|
1772 |
string basefilename = removedbegin->second.GetBase(); |
|
1773 |
string currentfilename = removedbegin->second.GetCurrent(); |
|
1774 |
// Process each removed macro from removedMacros |
|
1775 |
list<pair<string,string> >::iterator removedbegin2 = removedbegin->second.GetValue().begin(); |
|
1776 |
list<pair<string,string> >::iterator removedend2 = removedbegin->second.GetValue().end(); |
|
1777 |
for(; removedbegin2 != removedend2; removedbegin2++) |
|
1778 |
{
|
|
1779 |
string macroname = removedbegin2->first; |
|
1780 |
//int lineNo = atoi(removedbegin2->second.c_str()); |
|
1781 |
// No need to pass the line no in removed case. |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1782 |
report.addIssue(basefilename, macroname, EIssueIdentityMacro, EIssueTypeRemoval, ESeverityPossibleBBCBreak, ESeveritySCBreak, "", 0,"", currentfilename, ""); |
| 0 | 1783 |
issues++; |
1784 |
} |
|
1785 |
} |
|
1786 |
||
1787 |
// Changed macros |
|
1788 |
// |
|
1789 |
map<string, TChange<map<string, pair<pair<string,string>,string> > > >& changedMacros = macros.getChanged(); |
|
1790 |
map<string, TChange<map<string, pair<pair<string,string>,string> > > >::iterator changedbegin = changedMacros.begin(); |
|
1791 |
map<string, TChange<map<string, pair<pair<string,string>,string> > > >::iterator changedend = changedMacros.end(); |
|
1792 |
for(; changedbegin != changedend; changedbegin++) |
|
1793 |
{
|
|
1794 |
string basefilename = changedbegin->second.GetBase(); |
|
1795 |
string currentfilename = changedbegin->second.GetCurrent(); |
|
1796 |
// Process each changed macro from changedMacros |
|
1797 |
map<string, pair<pair<string,string>,string> >::iterator changedbegin2 = changedbegin->second.GetValue().begin(); |
|
1798 |
map<string, pair<pair<string,string>,string> >::iterator changedend2 = changedbegin->second.GetValue().end(); |
|
1799 |
for(; changedbegin2 != changedend2; changedbegin2++) |
|
1800 |
{
|
|
1801 |
string macroname = changedbegin2->first; |
|
1802 |
string newcode = changedbegin2->second.first.second; |
|
1803 |
int lineNo = atoi(changedbegin2->second.second.c_str()); |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1804 |
report.addIssue(basefilename, macroname, EIssueIdentityMacro, EIssueTypeChange, ESeverityPossibleBBCBreak, ESeveritySCNULL, newcode, lineNo, "",currentfilename, ""); |
| 0 | 1805 |
issues++; |
1806 |
} |
|
1807 |
} |
|
1808 |
||
1809 |
||
1810 |
//clear the last set of files with macros |
|
1811 |
iMacroFiles.clear(); |
|
1812 |
} catch (HAException e) |
|
1813 |
{
|
|
1814 |
#if !defined(_DEBUG) && !defined(DEBUG) |
|
1815 |
parser->RemoveFile(parser->getMacroFilename(), iNotRemovedFiles); |
|
1816 |
parser2->RemoveFile(parser2->getMacroFilename(), iNotRemovedFiles); |
|
1817 |
#endif |
|
1818 |
||
1819 |
//header has failed compilation with gccxml. get the compilation error text. |
|
1820 |
if (parser2->getCompErrFile()!="") |
|
1821 |
{
|
|
1822 |
iCompErrTxt = BBCFileUtils::getCompilationError(parser2->getCompErrFile()); |
|
1823 |
if (iCompErrTxt == "") |
|
1824 |
iCompErrTxt = BBCFileUtils::getCompilationError(parser->getCompErrFile()); |
|
1825 |
} |
|
1826 |
else |
|
1827 |
{
|
|
1828 |
if(parser->getCompErrFile()!="") |
|
1829 |
iCompErrTxt = BBCFileUtils::getCompilationError(parser->getCompErrFile()); |
|
1830 |
} |
|
1831 |
#if !defined(_DEBUG) && !defined(DEBUG) |
|
1832 |
parser->RemoveFile(parser->getCompErrFile(), iNotRemovedFiles); |
|
1833 |
parser2->RemoveFile(parser2->getCompErrFile(), iNotRemovedFiles); |
|
1834 |
#endif |
|
1835 |
||
1836 |
||
1837 |
//delete parser; |
|
1838 |
//delete parser2; |
|
1839 |
return false; |
|
1840 |
} |
|
1841 |
//delete parser; |
|
1842 |
//delete parser2; |
|
1843 |
return true; |
|
1844 |
} |
|
1845 |
||
1846 |
||
1847 |
// ---------------------------------------------------------------------------- |
|
1848 |
// Analyser::processFileReplaces |
|
1849 |
// Process the file replaces |
|
1850 |
// ---------------------------------------------------------------------------- |
|
1851 |
// |
|
1852 |
pair<string, string> Analyser::processFileReplaces(pair<string, string>& aFile, const stringmap& aReplaceMap, list<pair<string, string> >& aCurrentFiles) |
|
1853 |
{
|
|
1854 |
string searched(aFile.second); |
|
1855 |
pair<string, string> replacement(aFile); |
|
1856 |
// If there are items on replace map, then apply the |
|
1857 |
// replaces when necessary |
|
1858 |
if (aReplaceMap.size() > 0) |
|
1859 |
{
|
|
1860 |
StringMapIterC fileMapIter = aReplaceMap.find(searched); |
|
1861 |
if (fileMapIter != aReplaceMap.end()) |
|
1862 |
{
|
|
1863 |
string file = fileMapIter->second; |
|
1864 |
list<pair<string, string> >::const_iterator filereplace = FindFromList(toLowerCaseWin(file), aCurrentFiles, ERightValue, compareFiles); |
|
1865 |
if (filereplace != aCurrentFiles.end()) |
|
1866 |
{
|
|
1867 |
replacement = *filereplace; |
|
1868 |
} |
|
1869 |
} |
|
1870 |
} |
|
1871 |
||
1872 |
return replacement; |
|
1873 |
} |
|
1874 |
||
1875 |
||
1876 |
// ---------------------------------------------------------------------------- |
|
1877 |
// Analyser::createReplaceMap |
|
1878 |
// |
|
1879 |
// ---------------------------------------------------------------------------- |
|
1880 |
// |
|
1881 |
void Analyser::createReplaceMap(const string& aReplaceList, stringmap& aReplaceMap) |
|
1882 |
{
|
|
1883 |
string originalfilename("");
|
|
1884 |
string replacementfilename("");
|
|
1885 |
string* name = &originalfilename; |
|
1886 |
bool original = true; |
|
1887 |
bool isstr = false; |
|
1888 |
for (size_t i = 0; i < aReplaceList.length(); i++) |
|
1889 |
{
|
|
1890 |
char ch = aReplaceList.at(i); |
|
1891 |
if (ch == ' ' && isstr == false) |
|
1892 |
{
|
|
1893 |
if (original == true) |
|
1894 |
{
|
|
1895 |
original = false; |
|
1896 |
name = &replacementfilename; |
|
1897 |
} |
|
1898 |
else |
|
1899 |
{
|
|
1900 |
// Pair separator found. |
|
1901 |
// Store the pair (original, replacement) |
|
1902 |
stringpair mappair(toLowerCaseWin(originalfilename), toLowerCaseWin(replacementfilename)); |
|
1903 |
aReplaceMap.insert(mappair); |
|
1904 |
replacementfilename.resize(0); |
|
1905 |
originalfilename.resize(0); |
|
1906 |
||
1907 |
original = true; |
|
1908 |
name = &originalfilename; |
|
1909 |
} |
|
1910 |
} else if (ch == '"') |
|
1911 |
{
|
|
1912 |
if (isstr == true) |
|
1913 |
{
|
|
1914 |
isstr = false; |
|
1915 |
} else |
|
1916 |
{
|
|
1917 |
isstr = true; |
|
1918 |
} |
|
1919 |
} else |
|
1920 |
{
|
|
1921 |
*name += ch; |
|
1922 |
} |
|
1923 |
} |
|
1924 |
if (original == true) |
|
1925 |
{
|
|
1926 |
throw HAException("Syntax error: There has been given file name to replace but not file name for replace.");
|
|
1927 |
} |
|
1928 |
if (originalfilename.length() > 0 && replacementfilename.length() > 0) |
|
1929 |
{
|
|
1930 |
// Store the last pair in replacement list |
|
1931 |
stringpair mappair(toLowerCaseWin(originalfilename), toLowerCaseWin(replacementfilename)); |
|
1932 |
aReplaceMap.insert(mappair); |
|
1933 |
} |
|
1934 |
} |
|
1935 |
||
1936 |
// ---------------------------------------------------------------------------- |
|
1937 |
// Analyser::fileDiffs |
|
1938 |
// ---------------------------------------------------------------------------- |
|
1939 |
// |
|
1940 |
void Analyser::fileDiffs(vector<pair<string, string> >& aFiles, list<string>& aMismatches) |
|
1941 |
{
|
|
1942 |
vector<pair<string, string> > ret; |
|
1943 |
ret.reserve(aFiles.size()); |
|
1944 |
vector<pair<string, string> >::iterator file = aFiles.begin(); |
|
1945 |
vector<pair<string, string> >::iterator fileend = aFiles.end(); |
|
1946 |
||
1947 |
for(;file != fileend; file++) |
|
1948 |
{
|
|
1949 |
// START -- Support for multiple header directories |
|
1950 |
list<pair<string, string> > basedirs = BBCFileUtils::extractFilenames(iParams.getParameter(BASELINEDIR)); |
|
1951 |
list<pair<string, string> >::iterator basedirbegin = basedirs.begin(); |
|
1952 |
string basedir; |
|
1953 |
string basefile; |
|
1954 |
for(; basedirbegin != basedirs.end(); basedirbegin++) |
|
1955 |
{
|
|
1956 |
// Find the base dir from the list of base dirs |
|
1957 |
basedir = basedirbegin->first; |
|
1958 |
basefile = basedir + DIR_SEPARATOR + file->first; |
|
1959 |
if (BBCFileUtils::FileExists(basefile)) |
|
1960 |
break; |
|
1961 |
} |
|
1962 |
||
1963 |
list<pair<string, string> > curdirs = BBCFileUtils::extractFilenames(iParams.getParameter(CURRENTDIR)); |
|
1964 |
list<pair<string, string> >::iterator curdirbegin = curdirs.begin(); |
|
1965 |
string curdir; |
|
1966 |
string curfile; |
|
1967 |
for(; curdirbegin != curdirs.end(); curdirbegin++) |
|
1968 |
{
|
|
1969 |
// Find the current dir from the list of current dirs |
|
1970 |
curdir = curdirbegin->first; |
|
1971 |
curfile = curdir + DIR_SEPARATOR + file->second; |
|
1972 |
if (BBCFileUtils::FileExists(curfile)) |
|
1973 |
break; |
|
1974 |
} |
|
1975 |
// END -- Support for multiple header directories |
|
1976 |
||
1977 |
if (file->second == "") |
|
1978 |
{
|
|
1979 |
// We hadn't find matching file from current list so we add it to removed list |
|
1980 |
aMismatches.push_back(basefile); |
|
1981 |
} else |
|
1982 |
{
|
|
1983 |
pair<string, string> tempvar(basefile, curfile); |
|
1984 |
ret.push_back(tempvar); |
|
1985 |
} |
|
1986 |
} |
|
1987 |
aFiles = ret; |
|
1988 |
} |
|
1989 |
||
1990 |
// ---------------------------------------------------------------------------- |
|
1991 |
// Analyser::getFilenameWithoutDir |
|
1992 |
// Return the file part of the filename, eg. retuns the rightmost part of |
|
1993 |
// the given string, up to a "\" // or "/" separator. |
|
1994 |
// ---------------------------------------------------------------------------- |
|
1995 |
// |
|
1996 |
string Analyser::getFilenameWithoutDir(const string& aFilename) |
|
1997 |
{
|
|
1998 |
string ret = aFilename; |
|
1999 |
string::size_type idx = rightmostDirSeparatorIndex(aFilename); |
|
2000 |
if (idx != string::npos) |
|
2001 |
{
|
|
2002 |
ret = aFilename.substr(idx+1, aFilename.length() - idx); |
|
2003 |
} |
|
2004 |
return ret; |
|
2005 |
} |
|
2006 |
||
2007 |
// ---------------------------------------------------------------------------- |
|
2008 |
// Analyser::testFileAvailability |
|
2009 |
// ---------------------------------------------------------------------------- |
|
2010 |
// |
|
2011 |
#if 0 |
|
2012 |
void Analyser::testFileAvailability(stringmap map) |
|
2013 |
{
|
|
2014 |
stringmap::iterator begin = map.begin(); |
|
2015 |
stringmap::iterator end = map.end(); |
|
2016 |
||
2017 |
for(; begin!= end; begin++) |
|
2018 |
{
|
|
2019 |
string file = (*begin).first; |
|
2020 |
||
2021 |
int isValid = ACCESS(file.c_str(), 0); |
|
2022 |
if (isValid == -1) |
|
2023 |
{
|
|
2024 |
throw HAException("File: \"" + file + "\" not found");
|
|
2025 |
} |
|
2026 |
||
2027 |
file = (*begin).second; |
|
2028 |
||
2029 |
isValid = ACCESS(file.c_str(), 0); |
|
2030 |
if (isValid == -1) |
|
2031 |
{
|
|
2032 |
throw HAException("File: \"" + file + "\" not found");
|
|
2033 |
} |
|
2034 |
} |
|
2035 |
} |
|
2036 |
||
2037 |
#endif |
|
2038 |
||
2039 |
// ---------------------------------------------------------------------------- |
|
2040 |
// Analyser::MergeFiles |
|
2041 |
// ---------------------------------------------------------------------------- |
|
2042 |
// |
|
2043 |
void Analyser::MergeFiles(const list<pair<string, string> >& aBasefiles, list<pair<string, string> >& aCurrentfiles, |
|
2044 |
const string& aReplaceList, vector<pair<string, string> >& aMatches) |
|
2045 |
{
|
|
2046 |
size_t asdf = aBasefiles.size(); |
|
2047 |
list<pair<string, string> >::const_iterator baseiter = aBasefiles.begin(); |
|
2048 |
list<pair<string, string> >::const_iterator baseend = aBasefiles.end(); |
|
2049 |
list<pair<string, string> > removedcurrentfiles; |
|
2050 |
list<pair<string, string> > mismatches; |
|
2051 |
if (!iParams.givenParameter(BASELINE)) |
|
2052 |
{
|
|
2053 |
stringmap replaceMap; |
|
2054 |
if (aReplaceList.length() > 0) |
|
2055 |
{
|
|
2056 |
createReplaceMap(aReplaceList, replaceMap); |
|
2057 |
stringmap::iterator begin = replaceMap.begin(); |
|
2058 |
stringmap::iterator end = replaceMap.end(); |
|
2059 |
} |
|
2060 |
for(; baseiter != baseend; baseiter++) |
|
2061 |
{
|
|
2062 |
pair<string, string> file = *baseiter; |
|
2063 |
file = processFileReplaces(file, replaceMap, aCurrentfiles); |
|
2064 |
pair<string,string> tempvar; |
|
2065 |
//compareWholeString will be set to true, |
|
2066 |
//only if the file name with whole path of current file need to compare with base file. |
|
2067 |
//else by default will always be set to false. |
|
2068 |
list<pair<string, string> >::iterator current = FindFromList(file.second, aCurrentfiles, ERightValue, compareFiles, false,true); |
|
2069 |
if (current != aCurrentfiles.end()) |
|
2070 |
{
|
|
2071 |
tempvar.first = baseiter->first.substr(1); |
|
2072 |
tempvar.second = current->first.substr(1); |
|
2073 |
aMatches.push_back(tempvar); |
|
2074 |
removedcurrentfiles.push_back(*current); |
|
2075 |
aCurrentfiles.erase(current); |
|
2076 |
} else |
|
2077 |
{
|
|
2078 |
current = FindFromList(file.second, removedcurrentfiles, ERightValue, compareFiles, false); |
|
2079 |
if (current != removedcurrentfiles.end()) |
|
2080 |
{
|
|
2081 |
tempvar.first = baseiter->first.substr(1); |
|
2082 |
tempvar.second = current->first.substr(1); |
|
2083 |
aMatches.push_back(tempvar); |
|
2084 |
} else |
|
2085 |
{
|
|
2086 |
mismatches.push_back(file); |
|
2087 |
} |
|
2088 |
} |
|
2089 |
} |
|
2090 |
baseiter = mismatches.begin(); |
|
2091 |
baseend = mismatches.end(); |
|
2092 |
for(; baseiter != baseend; baseiter++) |
|
2093 |
{
|
|
2094 |
string filename = BBCFileUtils::StripPath(baseiter->second); |
|
2095 |
pair<string, string> file(filename, filename); // We don't need to put filename to lowercase as it's already in lowercase |
|
2096 |
file = processFileReplaces(file, replaceMap, aCurrentfiles); |
|
2097 |
string empty("");
|
|
2098 |
pair<string,string> tempvar; |
|
2099 |
tempvar.first = baseiter->first.substr(1); |
|
2100 |
list<pair<string, string> >::iterator current = FindFromList(file.second, aCurrentfiles, ERightValue, compareFiles); |
|
2101 |
if (current != aCurrentfiles.end()) |
|
2102 |
{
|
|
2103 |
tempvar.second = current->first.substr(1); |
|
2104 |
} else |
|
2105 |
{
|
|
2106 |
tempvar.second = empty; |
|
2107 |
} |
|
2108 |
aMatches.push_back(tempvar); |
|
2109 |
} |
|
2110 |
} else |
|
2111 |
{
|
|
2112 |
// START -- Support for multiple header directories |
|
2113 |
list<pair<string, string> > basedirs = BBCFileUtils::extractFilenames(iParams.getParameter(BASELINEDIR)); |
|
2114 |
list<pair<string, string> >::iterator basedirbegin = basedirs.begin(); |
|
2115 |
bool basefilefound = false; |
|
2116 |
string basefile; |
|
2117 |
for(; basedirbegin != basedirs.end(); basedirbegin++) |
|
2118 |
{
|
|
2119 |
string basedir = basedirbegin->first; |
|
2120 |
basefile = basedir + DIR_SEPARATOR + aBasefiles.front().first; |
|
2121 |
||
2122 |
if (ACCESS(basefile.c_str(), 0) != -1) |
|
2123 |
{
|
|
2124 |
basefilefound = true; |
|
2125 |
break; |
|
2126 |
} |
|
2127 |
} |
|
2128 |
list<pair<string, string> > curdirs = BBCFileUtils::extractFilenames(iParams.getParameter(CURRENTDIR)); |
|
2129 |
list<pair<string, string> >::iterator curdirbegin = curdirs.begin(); |
|
2130 |
bool curfilefound = false; |
|
2131 |
string curfile; |
|
2132 |
||
2133 |
for(; curdirbegin != curdirs.end(); curdirbegin++) |
|
2134 |
{
|
|
2135 |
string curdir = curdirbegin->first; |
|
2136 |
curfile = curdir + DIR_SEPARATOR + aBasefiles.front().first; |
|
2137 |
if (ACCESS(curfile.c_str(), 0) != -1) |
|
2138 |
{
|
|
2139 |
curfilefound = true; |
|
2140 |
break; |
|
2141 |
} |
|
2142 |
} |
|
2143 |
if (!basefilefound ) |
|
2144 |
{
|
|
2145 |
throw HAException("File \"" + basefile + "\" not found");
|
|
2146 |
} |
|
2147 |
if (!curfilefound) |
|
2148 |
{
|
|
2149 |
throw HAException("File \"" + curfile + "\" not found");
|
|
2150 |
} |
|
2151 |
pair<string,string> tempvar(aBasefiles.front().first, aCurrentfiles.front().first); |
|
2152 |
aMatches.push_back(tempvar); |
|
2153 |
// END -- Support for multiple header directories |
|
2154 |
} |
|
2155 |
} |
|
2156 |
||
2157 |
// ---------------------------------------------------------------------------- |
|
2158 |
// AnalyserParams::diffs |
|
2159 |
// |
|
2160 |
// ---------------------------------------------------------------------------- |
|
2161 |
// |
|
2162 |
void Analyser::diffs( const list<pair<string, string> >& allfiles, |
|
2163 |
const list<pair<string, string> >& sets, |
|
2164 |
list<pair<string, string> >& result) |
|
2165 |
{
|
|
2166 |
result = sets; |
|
2167 |
list<stringpair >::iterator setiter = result.begin(); |
|
2168 |
while(setiter != result.end()) |
|
2169 |
{
|
|
2170 |
if( setiter->first.find_first_of("*?") != string::npos )
|
|
2171 |
setiter = result.erase(setiter); |
|
2172 |
else |
|
2173 |
++setiter; |
|
2174 |
} |
|
2175 |
||
2176 |
list<pair<string, string> >::const_iterator file = allfiles.begin(); |
|
2177 |
list<pair<string, string> >::const_iterator fileend = allfiles.end(); |
|
2178 |
for(; file != fileend; file++) |
|
2179 |
{
|
|
2180 |
list<pair<string, string> >::iterator set = |
|
2181 |
FindFromList(file->second, result, ERightValue); |
|
2182 |
if (set == result.end()) |
|
2183 |
{
|
|
2184 |
set = FindFromList(file->second, result, ERightValue, compareFiles); |
|
2185 |
} |
|
2186 |
||
2187 |
if (set != result.end()) |
|
2188 |
{
|
|
2189 |
result.erase(set); |
|
2190 |
} |
|
2191 |
} |
|
2192 |
||
2193 |
} |
|
2194 |
||
2195 |
// ---------------------------------------------------------------------------- |
|
2196 |
// AnalyserParams::canonicalizeFilename |
|
2197 |
// Get the actual name of a file. |
|
2198 |
// ---------------------------------------------------------------------------- |
|
2199 |
// |
|
2200 |
list<pair<string, string> > Analyser::canonicalizeFilename(list<pair<string, string> >& sets) |
|
2201 |
{
|
|
2202 |
list<pair<string, string> > ret; |
|
2203 |
list<pair<string, string> >::iterator begin = sets.begin(); |
|
2204 |
list<pair<string, string> >::iterator end = sets.end(); |
|
2205 |
for(; begin != end; begin++) |
|
2206 |
{
|
|
2207 |
if (begin->first.at(0) != DIR_SEPARATOR && begin->first.find(DIR_SEPARATOR) != string::npos) |
|
2208 |
{
|
|
2209 |
string left = ""; |
|
2210 |
left += DIR_SEPARATOR; |
|
2211 |
left += begin->first; |
|
2212 |
string right = ""; |
|
2213 |
right += DIR_SEPARATOR; |
|
2214 |
right += begin->second; |
|
2215 |
ret.push_back(pair<string, string>(left, right)); |
|
2216 |
} else |
|
2217 |
{
|
|
2218 |
ret.push_back(*begin); |
|
2219 |
} |
|
2220 |
} |
|
2221 |
||
2222 |
return ret; |
|
2223 |
} |
|
2224 |
||
2225 |
||
2226 |
// ---------------------------------------------------------------------------- |
|
2227 |
// Analyser::Wrapper |
|
2228 |
// Wrapper function to analyse all files in a component in separate thread. |
|
2229 |
// |
|
2230 |
// ---------------------------------------------------------------------------- |
|
2231 |
// |
|
2232 |
void Analyser::Wrapper( ReportGenerator& report, |
|
2233 |
int& issues, |
|
2234 |
CPPParser baseParser, |
|
2235 |
CPPParser currParser, |
|
2236 |
PlatformHeaders& pfHeaders, |
|
2237 |
PlatformHeaders& unsuccessfulHdrs |
|
2238 |
) |
|
2239 |
{
|
|
2240 |
stringvector tiBaseFilenames; // This contains also additional headers needed to compile baseline |
|
2241 |
stringvector tiCurrFilenames; // This contains also additional headers needed to compile product |
|
2242 |
PlatformHeaders tiInvalidFiles; // holds a list of files without include guards need to be compiled individually |
|
2243 |
stringvector tiBaseIncludes; // This contains also additional headers needed to compile baseline |
|
2244 |
stringvector tiCurrIncludes; // This contains also additional headers needed to compile product |
|
2245 |
||
2246 |
stringvector baseSysIncludes; // This contains headers needed to compile baseline for 3rd time analyzation of a single header. |
|
2247 |
stringvector curSysIncludes; // This contains headers needed to compile product for 3rd time analyzation of a single header. |
|
2248 |
||
2249 |
tiBaseFilenames.assign(iBaseFilenames.begin(),iBaseFilenames.end()); |
|
2250 |
tiCurrFilenames.assign(iCurrFilenames.begin(),iCurrFilenames.end()); |
|
2251 |
tiInvalidFiles.assign(iInvalidFiles.begin(),iInvalidFiles.end()); |
|
2252 |
tiBaseIncludes.assign(iBaseIncludes.begin(),iBaseIncludes.end()); |
|
2253 |
tiCurrIncludes.assign(iCurrIncludes.begin(),iCurrIncludes.end()); |
|
2254 |
||
2255 |
if (iOnlySystemIncludeRequired == true) |
|
2256 |
{
|
|
2257 |
//tiBaseIncludes and tiCurrIncludes are required for 3rd time analyzation. |
|
2258 |
//This time parse each unsuccessful header with both system includes and paths. |
|
2259 |
baseSysIncludes.assign(tiBaseIncludes.begin(),tiBaseIncludes.end()); |
|
2260 |
curSysIncludes.assign(tiCurrIncludes.begin(),tiCurrIncludes.end()); |
|
2261 |
||
2262 |
// Clear these includes as for 2nd time parsing of each unsuccessful headres, |
|
2263 |
//as only system include paths arerequuired. |
|
2264 |
tiBaseIncludes.clear(); |
|
2265 |
tiCurrIncludes.clear(); |
|
2266 |
} |
|
2267 |
||
2268 |
||
2269 |
if( (tiBaseIncludes.size()>0 && tiCurrIncludes.size()>0)|| (tiBaseFilenames.size()>0 && tiCurrFilenames.size()>0) ) |
|
2270 |
{
|
|
2271 |
if( AnalyseBundle(tiBaseFilenames, tiCurrFilenames, report, issues, &baseParser, &currParser, &tiBaseIncludes, &tiCurrIncludes)) |
|
2272 |
{
|
|
2273 |
tiBaseFilenames.clear(); |
|
2274 |
tiCurrFilenames.clear(); |
|
2275 |
} |
|
2276 |
} |
|
2277 |
||
2278 |
if (iNotRemovedFiles.size() != 0) |
|
2279 |
{
|
|
2280 |
list<string> tempvar; |
|
2281 |
list<string>::iterator removefile = iNotRemovedFiles.begin(); |
|
2282 |
list<string>::iterator fileend = iNotRemovedFiles.end(); |
|
2283 |
for(; removefile != fileend; removefile++) |
|
2284 |
{
|
|
2285 |
CPPParser::RemoveFile(*removefile, tempvar); |
|
2286 |
} |
|
2287 |
if (tempvar.size() != 0) |
|
2288 |
{
|
|
2289 |
iNotRemovedFiles = tempvar; |
|
2290 |
} |
|
2291 |
else |
|
2292 |
{
|
|
2293 |
iNotRemovedFiles.clear(); |
|
2294 |
} |
|
2295 |
} |
|
2296 |
||
2297 |
if(tiInvalidFiles.size() > 0) |
|
2298 |
{
|
|
2299 |
// also add to this list, the set of headers |
|
2300 |
// without include guards |
|
2301 |
PlatformHeaders::iterator add = tiInvalidFiles.begin(); |
|
2302 |
for(; add != tiInvalidFiles.end(); ++add ) |
|
2303 |
{
|
|
2304 |
tiBaseFilenames.push_back( add->first->ID() ); |
|
2305 |
tiCurrFilenames.push_back( add->second->ID() ); |
|
2306 |
} |
|
2307 |
} |
|
2308 |
||
2309 |
// if thread flag is set and there are gretaer number of files, create threads for analysing every PLATFORM_BUNDLESIZE number of files |
|
2310 |
if( iUseThread && tiBaseFilenames.size() >= PLATFORM_BUNDLESIZE ) |
|
2311 |
{
|
|
2312 |
stringvector tmp; |
|
2313 |
int pcount = 0; |
|
2314 |
stringvector::iterator i = tiBaseFilenames.begin(); |
|
2315 |
for(; i != tiBaseFilenames.end(); ++i ) |
|
2316 |
{
|
|
2317 |
pcount++; |
|
2318 |
PlatformHeaders::iterator h = FindHeaderPair(*i, pfHeaders); |
|
2319 |
if( h != pfHeaders.end() ) |
|
2320 |
{
|
|
2321 |
tmp.push_back(*i); |
|
2322 |
} |
|
2323 |
if ((pcount % PLATFORM_BUNDLESIZE == 0 || pcount == tiBaseFilenames.size()) && tmp.size()>0) |
|
2324 |
{
|
|
2325 |
while (lock.locked()) |
|
2326 |
{
|
|
2327 |
#ifdef __WIN__ |
|
2328 |
Sleep(4000); |
|
2329 |
#else |
|
2330 |
usleep(4000*1000); |
|
2331 |
#endif |
|
2332 |
} |
|
2333 |
lock.lock(); |
|
2334 |
||
2335 |
if(gComponentThreads.size() >= MAX_THREAD_COUNT2) |
|
2336 |
{
|
|
2337 |
gComponentThreads.join_all(); |
|
2338 |
int size = gComponentThreads.size(); |
|
2339 |
for (int i=0;i<size;i++) |
|
2340 |
{
|
|
2341 |
gComponentThreads.remove_thread(gpHeaderThreads[i]); |
|
2342 |
gpHeaderThreads[i]->~thread(); |
|
2343 |
} |
|
2344 |
} |
|
2345 |
||
2346 |
//2nd time analyzation of each header in a different thread |
|
2347 |
Analyser* obj = new Analyser(); |
|
2348 |
*obj = *this; |
|
2349 |
int size = gComponentThreads.size(); |
|
2350 |
gpHeaderThreads[size]=gComponentThreads.create_thread(boost::bind(&Analyser::Wrapper2,obj,tmp, |
|
2351 |
boost::ref(pfHeaders), boost::ref(unsuccessfulHdrs), boost::ref(report), boost::ref(issues))); |
|
2352 |
lock.unlock(); |
|
2353 |
tmp.clear(); |
|
2354 |
||
2355 |
} |
|
2356 |
} |
|
2357 |
} |
|
2358 |
else // do not create different thread. analyse in the same thread. |
|
2359 |
{
|
|
2360 |
stringvector::iterator i = tiBaseFilenames.begin(); |
|
2361 |
for(; i != tiBaseFilenames.end(); ++i ) |
|
2362 |
{
|
|
2363 |
PlatformHeaders::iterator h = FindHeaderPair(*i, pfHeaders); |
|
2364 |
if( h != pfHeaders.end() ) |
|
2365 |
{
|
|
2366 |
if(( pfHeaders.size() > 1 ) ) |
|
2367 |
{
|
|
2368 |
PlatformHeaders tempHeaders; |
|
2369 |
tempHeaders.push_back(*h); |
|
2370 |
h->first->SetStatus(Header::HDR_STATUS_TO_BE_ANALYZED); |
|
2371 |
iOnlySystemIncludeRequired = true; |
|
2372 |
//2nd time analyzation of each header in same thread |
|
2373 |
AnalyzePlatforms( tempHeaders, unsuccessfulHdrs, report, issues, false ); |
|
2374 |
iOnlySystemIncludeRequired = false; |
|
2375 |
} |
|
2376 |
else |
|
2377 |
{
|
|
2378 |
//The 3rd time parsing is required to check again each unsuccessful headers |
|
2379 |
//with system includes and paths from platform data |
|
2380 |
if(!AnalyseBundle(tiBaseFilenames, tiCurrFilenames, report, issues, &baseParser, &currParser, &baseSysIncludes, &curSysIncludes)) |
|
2381 |
{
|
|
2382 |
if( FindHeaderPair(h->first->ID(), unsuccessfulHdrs ) == unsuccessfulHdrs.end() ) |
|
2383 |
{
|
|
2384 |
unsuccessfulHdrs.push_back(*h); |
|
2385 |
} |
|
2386 |
} |
|
2387 |
if (iNotRemovedFiles.size() != 0) |
|
2388 |
{
|
|
2389 |
list<string> tempvar; |
|
2390 |
list<string>::iterator removefile = iNotRemovedFiles.begin(); |
|
2391 |
list<string>::iterator fileend = iNotRemovedFiles.end(); |
|
2392 |
for(; removefile != fileend; removefile++) |
|
2393 |
{
|
|
2394 |
CPPParser::RemoveFile(*removefile, tempvar); |
|
2395 |
} |
|
2396 |
if (tempvar.size() != 0) |
|
2397 |
{
|
|
2398 |
iNotRemovedFiles = tempvar; |
|
2399 |
} |
|
2400 |
else |
|
2401 |
{
|
|
2402 |
iNotRemovedFiles.clear(); |
|
2403 |
} |
|
2404 |
} |
|
2405 |
} |
|
2406 |
} |
|
2407 |
} |
|
2408 |
} |
|
2409 |
} |
|
2410 |
||
2411 |
// ---------------------------------------------------------------------------- |
|
2412 |
// Analyser::Wrapper2 |
|
2413 |
// Wrapper function to analyse group of files in a component individually in different thread. |
|
2414 |
// |
|
2415 |
// ---------------------------------------------------------------------------- |
|
2416 |
// |
|
2417 |
void Analyser::Wrapper2(stringvector filenames, PlatformHeaders& pfHeaders, PlatformHeaders& unsuccessfulHdrs, ReportGenerator& report, int& issues) |
|
2418 |
{
|
|
2419 |
PlatformHeaders tempHeaders; |
|
2420 |
stringvector::iterator i = filenames.begin(); |
|
2421 |
for(; i != filenames.end(); ++i ) |
|
2422 |
{
|
|
2423 |
PlatformHeaders::iterator h = FindHeaderPair(*i, pfHeaders); |
|
2424 |
if( h != pfHeaders.end() ) |
|
2425 |
{
|
|
2426 |
tempHeaders.push_back(*h); |
|
2427 |
h->first->SetStatus(Header::HDR_STATUS_TO_BE_ANALYZED); |
|
2428 |
iOnlySystemIncludeRequired = true; |
|
2429 |
AnalyzePlatforms( tempHeaders, unsuccessfulHdrs, report, issues, false ); |
|
2430 |
iOnlySystemIncludeRequired = false; |
|
2431 |
} |
|
2432 |
} |
|
2433 |
||
2434 |
if (iNotRemovedFiles.size() != 0) |
|
2435 |
{
|
|
2436 |
list<string> tempvar; |
|
2437 |
list<string>::iterator removefile = iNotRemovedFiles.begin(); |
|
2438 |
list<string>::iterator fileend = iNotRemovedFiles.end(); |
|
2439 |
for(; removefile != fileend; removefile++) |
|
2440 |
{
|
|
2441 |
CPPParser::RemoveFile(*removefile, tempvar); |
|
2442 |
} |
|
2443 |
if (tempvar.size() != 0) |
|
2444 |
{
|
|
2445 |
iNotRemovedFiles = tempvar; |
|
2446 |
} |
|
2447 |
else |
|
2448 |
{
|
|
2449 |
iNotRemovedFiles.clear(); |
|
2450 |
} |
|
2451 |
} |
|
2452 |
} |
|
2453 |
||
2454 |
||
2455 |
||
2456 |
void Analyser::ParseAndCompareResourceFiles(vector<pair< string, string> >& resourcevector, ReportGenerator& report) |
|
2457 |
{
|
|
2458 |
ResourceContent baseResource; |
|
2459 |
ResourceContent curResource; |
|
2460 |
||
2461 |
list<pair<string, string> > iBaseSystemheaders = BBCFileUtils::extractFilenames(iParams.getParameter(BASELINEPLAT)); |
|
2462 |
list<pair<string, string> > iCurSystemheaders = BBCFileUtils::extractFilenames(iParams.getParameter(CURRENTPLAT)); |
|
2463 |
||
2464 |
for(int outer = 0; outer< (int)resourcevector.size(); outer++) |
|
2465 |
{
|
|
2466 |
list<pair<string, string> > baseSystemheaders; |
|
2467 |
list<pair<string, string> > curSystemheaders; |
|
2468 |
||
2469 |
baseSystemheaders = iBaseSystemheaders; |
|
2470 |
curSystemheaders = iCurSystemheaders; |
|
2471 |
pair <string, string> files = resourcevector.at(outer); |
|
2472 |
vector <string> bIncludes; |
|
2473 |
vector <string> cIncludes; |
|
2474 |
||
2475 |
||
2476 |
baseResource.RHFileName = ""; |
|
2477 |
curResource.RHFileName = ""; |
|
2478 |
||
2479 |
baseResource.RHFileName = BBCFileUtils::TrimAll(files.first); |
|
2480 |
curResource.RHFileName = BBCFileUtils::TrimAll(files.second); |
|
2481 |
||
2482 |
pair <string, string> fileAnalyzed; |
|
2483 |
fileAnalyzed.first = baseResource.RHFileName; |
|
2484 |
fileAnalyzed.second = curResource.RHFileName; |
|
2485 |
bool pairFound = false; |
|
2486 |
// check if the file is already analyzed or not. |
|
2487 |
for(int i = 0; i < (int)iRHFile_Analyzed.size(); i++ ) |
|
2488 |
{
|
|
2489 |
pair<string,string> filePair = iRHFile_Analyzed.at(i); |
|
2490 |
if(fileAnalyzed.first == filePair.first ) |
|
2491 |
{
|
|
2492 |
pairFound = true; |
|
2493 |
break; |
|
2494 |
} |
|
2495 |
} |
|
2496 |
// File is not analyzed yet, so analyze it. |
|
2497 |
if(pairFound == false ) |
|
2498 |
{
|
|
2499 |
iRHFile_Analyzed.push_back(fileAnalyzed); |
|
2500 |
||
2501 |
ifstream file(files.first.c_str()); |
|
2502 |
if(!file.is_open()) |
|
2503 |
{
|
|
2504 |
cerr << "ERROR: Cannot open " << files.first << " for reading!" << endl; |
|
2505 |
exit(17); |
|
2506 |
} |
|
2507 |
||
2508 |
// baseline resource file parsing |
|
2509 |
getElementListFromRHFile(file,baseResource,bIncludes ); |
|
2510 |
file.close(); |
|
2511 |
||
2512 |
// handle #include .RH headers, get proper path from system includes |
|
2513 |
int basePos = (int)baseResource.RHFileName.find_last_of(DIR_SEPARATOR); |
|
2514 |
string basePath = baseResource.RHFileName.substr(0,basePos); |
|
2515 |
vector<pair<string,string> > includes; |
|
2516 |
bool isPresent = false; |
|
2517 |
pair<string,string> bPath; |
|
2518 |
list<pair<string,string> >::iterator bHdr = baseSystemheaders.begin(); |
|
2519 |
for(;bHdr!= baseSystemheaders.end(); bHdr++) |
|
2520 |
{
|
|
2521 |
bPath = *bHdr; |
|
2522 |
if(bPath.first == basePath) |
|
2523 |
{
|
|
2524 |
isPresent = true; |
|
2525 |
break; |
|
2526 |
} |
|
2527 |
} |
|
2528 |
if(isPresent == false) |
|
2529 |
{
|
|
2530 |
pair<string,string> bPair; |
|
2531 |
bPair.first =basePath; |
|
2532 |
bPair.second =basePath; |
|
2533 |
baseSystemheaders.push_back(bPair); |
|
2534 |
} |
|
2535 |
||
2536 |
bHdr= baseSystemheaders.begin(); |
|
2537 |
for(int i = 0; i < (int)bIncludes.size(); i++) |
|
2538 |
{
|
|
2539 |
for(;bHdr != baseSystemheaders.end(); bHdr++) |
|
2540 |
{
|
|
2541 |
pair<string,string> baseHeader = *bHdr; |
|
2542 |
pair<string,string>basePair; |
|
2543 |
if(BBCFileUtils::FileExists(baseHeader.first + DIR_SEPARATOR + bIncludes.at(i)) ) |
|
2544 |
{
|
|
2545 |
basePair.first = baseHeader.first + DIR_SEPARATOR + bIncludes.at(i); |
|
2546 |
includes.push_back(basePair); |
|
2547 |
break; |
|
2548 |
} |
|
2549 |
} |
|
2550 |
} |
|
2551 |
||
2552 |
ifstream file2(files.second.c_str()); |
|
2553 |
if(!file2.is_open()) |
|
2554 |
{
|
|
2555 |
cerr << "ERROR: Cannot open " << files.second << " for reading!" << endl; |
|
2556 |
exit(17); |
|
2557 |
} |
|
2558 |
// current resource file parsing |
|
2559 |
getElementListFromRHFile(file2,curResource, cIncludes ); |
|
2560 |
file2.close(); |
|
2561 |
||
2562 |
_current_files++; |
|
2563 |
cout << "\nAnalysing files (" << _current_files << "/" << _total_files << "): " << files.first <<" => "<< files.second << endl;
|
|
2564 |
||
2565 |
// get current resource file's path and add to system include paths |
|
2566 |
// to get proper path for #include rh headers in current file |
|
2567 |
int cPos = (int)curResource.RHFileName.find_last_of(DIR_SEPARATOR); |
|
2568 |
string curPath = curResource.RHFileName.substr(0,cPos); |
|
2569 |
isPresent = false; |
|
2570 |
list<pair<string,string> >::iterator chdr= curSystemheaders.begin(); |
|
2571 |
pair<string,string> cPath; |
|
2572 |
for(;chdr != curSystemheaders.end(); chdr++) |
|
2573 |
{
|
|
2574 |
cPath = *chdr; |
|
2575 |
if(cPath.first == curPath) |
|
2576 |
{
|
|
2577 |
isPresent = true; |
|
2578 |
break; |
|
2579 |
} |
|
2580 |
} |
|
2581 |
if(isPresent == false) |
|
2582 |
{
|
|
2583 |
pair<string,string> cPair; |
|
2584 |
cPair.first = curPath; |
|
2585 |
cPair.second = curPath; |
|
2586 |
curSystemheaders.push_back(cPair); |
|
2587 |
} |
|
2588 |
||
2589 |
||
2590 |
for(int out = 0; out < (int)includes.size(); out++) |
|
2591 |
{
|
|
2592 |
int bLoc = (int)includes.at(out).first.find_last_of(DIR_SEPARATOR); |
|
2593 |
string bString = includes.at(out).first.substr(bLoc+1,string::npos); |
|
2594 |
bool includedHeaderPresent = false; |
|
2595 |
||
2596 |
for(int j = 0; j < (int)cIncludes.size(); j++) |
|
2597 |
{
|
|
2598 |
bool fileMatched = false; |
|
2599 |
chdr= curSystemheaders.begin(); |
|
2600 |
for(;chdr != curSystemheaders.end(); chdr++) |
|
2601 |
{
|
|
2602 |
pair<string,string> curHeader = *chdr; |
|
2603 |
string curFile = curHeader.first + DIR_SEPARATOR + cIncludes.at(j); |
|
2604 |
int loc = (int)curFile.find_last_of(DIR_SEPARATOR); |
|
2605 |
string curTemp = curFile.substr(loc+1 ,string::npos); |
|
2606 |
if(bString == curTemp) |
|
2607 |
{
|
|
2608 |
includedHeaderPresent = true; |
|
2609 |
if(BBCFileUtils::FileExists(curFile) ) |
|
2610 |
{
|
|
2611 |
fileMatched = true; // current file found in curr dir |
|
2612 |
includes.at(out).second = curFile; |
|
2613 |
break; |
|
2614 |
} |
|
2615 |
} |
|
2616 |
} |
|
2617 |
||
2618 |
if ( fileMatched = false ) |
|
2619 |
{
|
|
2620 |
// file does not exists in curdir |
|
2621 |
report.addIssue(baseResource.RHFileName, includes.at(out).first, EIssueIdentityFile, |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2622 |
EIssueTypeRemoval,ESeverityBBCBreak,ESeveritySCNULL, "", 0, "",curResource.RHFileName,""); |
| 0 | 2623 |
break; |
2624 |
} |
|
2625 |
} |
|
2626 |
if(includedHeaderPresent == false) |
|
2627 |
{
|
|
2628 |
// add issue, as field is removed in current file. |
|
2629 |
report.addIssue(baseResource.RHFileName, bString, EIssueIdentityField, |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2630 |
EIssueTypeRemoval,ESeverityNULL,ESeveritySCBreak, "", 0, "",curResource.RHFileName,""); |
| 0 | 2631 |
} |
2632 |
} |
|
2633 |
||
2634 |
for(int l = 0; l < (int)includes.size(); l++ ) |
|
2635 |
{
|
|
2636 |
pair<string,string> pair = includes.at(l); |
|
2637 |
if(pair.first.size() > 0 && pair.second.size()>0) |
|
2638 |
{
|
|
2639 |
resourcevector.push_back(pair); |
|
2640 |
} |
|
2641 |
} |
|
2642 |
||
2643 |
compareResources( baseResource, curResource, report); |
|
2644 |
} |
|
2645 |
||
2646 |
||
2647 |
baseResource.structList.clear(); |
|
2648 |
baseResource.enumList.clear(); |
|
2649 |
baseResource.macroList.clear(); |
|
2650 |
||
2651 |
curResource.structList.clear(); |
|
2652 |
curResource.enumList.clear(); |
|
2653 |
curResource.macroList.clear(); |
|
2654 |
||
2655 |
||
2656 |
}// end of one resource |
|
2657 |
cout<<"\n\n"<<endl; |
|
2658 |
} |
|
2659 |
||
2660 |
||
2661 |
void Analyser::getElementListFromRHFile(std::ifstream& RHFile,ResourceContent& resource, vector< string >& includes ) |
|
2662 |
{
|
|
2663 |
string line; |
|
2664 |
EnumElement lEnum; |
|
2665 |
string tempData; |
|
2666 |
string elementVal; |
|
2667 |
||
2668 |
StructElement lStruct; |
|
2669 |
string structName; |
|
2670 |
||
2671 |
bool structInuse = false; |
|
2672 |
bool enumInuse = false; |
|
2673 |
bool macroInuse = false; |
|
2674 |
bool keyFound = false; |
|
2675 |
bool elementfound = false; |
|
2676 |
bool valueFound = false; |
|
2677 |
||
2678 |
bool comment = false; |
|
2679 |
bool ignoreLine = false; |
|
2680 |
||
2681 |
bool newLinecharFound = false; // for macros, newline character can be present |
|
2682 |
||
2683 |
long currentEnumVal = -1; |
|
2684 |
||
2685 |
char keywords [23][15] = {"short","long", "word", "len", "byte", "struct", "ltext","enum", "ltext8", "ltext16", "ltext32", "llink", "srlink","double",
|
|
2686 |
"buf<1>","buf<2>","buf<4>","buf<8>","buf<16>","buf<32>","buf<64>","buf<128>","buf<256>"}; |
|
2687 |
||
2688 |
MacroElement macro; |
|
2689 |
int lineNo = 0; |
|
2690 |
||
2691 |
while(getline(RHFile,line)) |
|
2692 |
{
|
|
2693 |
lineNo++; |
|
2694 |
pair<string,int> enummember; |
|
2695 |
StructMember elementMember; |
|
2696 |
line = toLowerCase(trimWhiteSpace(line)); |
|
2697 |
||
2698 |
// Ignore all comment lines. e.g /*xxxxxxxxxx*/ Struct ABCD , start reading characterwise from struct |
|
2699 |
if(enumInuse == false && macroInuse == false && structInuse == false ) |
|
2700 |
{
|
|
2701 |
if(line.find("/*") != -1 )
|
|
2702 |
{
|
|
2703 |
if( line.find("*/") == -1)
|
|
2704 |
{
|
|
2705 |
comment = true; |
|
2706 |
continue; |
|
2707 |
} |
|
2708 |
else |
|
2709 |
{
|
|
2710 |
int com = (int)line.find_last_of("*");
|
|
2711 |
line= line.substr(com +2, string::npos); |
|
2712 |
} |
|
2713 |
} |
|
2714 |
if(line.find("*/") != -1 )
|
|
2715 |
{
|
|
2716 |
comment = false; |
|
2717 |
if(ignoreLine == true) |
|
2718 |
ignoreLine = false; |
|
2719 |
continue; |
|
2720 |
} |
|
2721 |
if(comment == true) |
|
2722 |
{
|
|
2723 |
continue; |
|
2724 |
} |
|
2725 |
if(line.find("//") != -1 )
|
|
2726 |
{
|
|
2727 |
int com = (int)line.find_first_of("//");
|
|
2728 |
bool wordFound = false; |
|
2729 |
line = line.substr(0,com); |
|
2730 |
for (int i = 0; i< (int)line.size(); i++ ) |
|
2731 |
{
|
|
2732 |
// check '//' commentline starts after some key value e.g struct ABCD // xyz |
|
2733 |
if ( (int)line.at(i ) != 32 && (int)line.at(i) != 9 ) // 32 and 9 are for space and invalid character |
|
2734 |
{
|
|
2735 |
wordFound = true; |
|
2736 |
break; |
|
2737 |
} |
|
2738 |
} |
|
2739 |
if(wordFound == false) |
|
2740 |
continue; |
|
2741 |
} |
|
2742 |
||
2743 |
} |
|
2744 |
||
2745 |
// Find any other header file is included in current file |
|
2746 |
// Then add it to file and check whether this is already analyzed or not. |
|
2747 |
// If not, then analyze it. |
|
2748 |
if(line.find ("#") != -1 && line.find("include") != -1 )
|
|
2749 |
{
|
|
2750 |
int start = (int)line.find_first_of ("<");
|
|
2751 |
||
2752 |
int end; |
|
2753 |
if(start == -1) |
|
2754 |
{
|
|
2755 |
start =(int) line.find_first_of("\"");
|
|
2756 |
end = (int)line.find_last_of("\"");
|
|
2757 |
} |
|
2758 |
else |
|
2759 |
{
|
|
2760 |
end = (int)line.find(">");
|
|
2761 |
} |
|
2762 |
||
2763 |
if (start > 0 && end > 0 ) |
|
2764 |
{
|
|
2765 |
line = line.substr(start + 1,(end - start) - 1); |
|
2766 |
line = BBCFileUtils::TrimAll(line); |
|
2767 |
int loc = (int)line.find(RH_EXTENSION); |
|
2768 |
// Include only .rh files |
|
2769 |
if(loc != -1) |
|
2770 |
includes.push_back(line); |
|
2771 |
} |
|
2772 |
} |
|
2773 |
||
2774 |
// Now check lines for key structure (struct, enum, #inlude and start reading characterwise unless the key structure end. |
|
2775 |
if (keyFound == false ) |
|
2776 |
{
|
|
2777 |
tempData.clear(); |
|
2778 |
int enumloc = (int)line.find(KEY_ENUM); |
|
2779 |
// to get enum key word properly. After "enum" keyword, there might be no name present. |
|
2780 |
// For this case, following checks are needed. |
|
2781 |
if( enumloc!= -1) |
|
2782 |
{
|
|
2783 |
enumInuse = true; |
|
2784 |
string prestring = line.substr(0,enumloc); |
|
2785 |
for(int i = 0; i< (int)prestring.size(); i++ ) |
|
2786 |
{
|
|
2787 |
if( (int)prestring.at(i)!= 32 && (int)prestring.at(i) != 9 ) |
|
2788 |
{
|
|
2789 |
enumInuse =false; |
|
2790 |
break; |
|
2791 |
} |
|
2792 |
} |
|
2793 |
if(enumInuse == true) |
|
2794 |
{
|
|
2795 |
string postline = line.substr(enumloc+strlen(KEY_ENUM) ,string::npos); |
|
2796 |
if( postline.size() > 0 && (int)postline.at(0)!= 32 && (int)postline.at(0) != 9 ) |
|
2797 |
{
|
|
2798 |
enumInuse =false; |
|
2799 |
break; |
|
2800 |
} |
|
2801 |
else |
|
2802 |
{
|
|
2803 |
line = postline; |
|
2804 |
macroInuse = false; |
|
2805 |
structInuse = false; |
|
2806 |
lEnum.enumName = ""; |
|
2807 |
lEnum.enums.clear(); |
|
2808 |
} |
|
2809 |
} |
|
2810 |
} |
|
2811 |
if(line.find(KEY_MACRO) != -1) |
|
2812 |
{
|
|
2813 |
macroInuse = true; |
|
2814 |
enumInuse = false; |
|
2815 |
structInuse = false; |
|
2816 |
macro.macroName = ""; |
|
2817 |
macro.macroVal = ""; |
|
2818 |
line = line.substr(strlen(KEY_MACRO),string::npos); |
|
2819 |
} |
|
2820 |
||
2821 |
if(line.find(KEY_STRUCT) != -1) |
|
2822 |
{
|
|
2823 |
structInuse = true; |
|
2824 |
enumInuse = false; |
|
2825 |
macroInuse = false; |
|
2826 |
lStruct.structName = ""; |
|
2827 |
lStruct.members.clear(); |
|
2828 |
line = line.substr(strlen(KEY_STRUCT),string::npos); |
|
2829 |
} |
|
2830 |
} |
|
2831 |
||
2832 |
// If any of the key found, then following lines will be checked character wise. |
|
2833 |
if ( enumInuse == true || macroInuse == true || structInuse == true ) |
|
2834 |
{
|
|
2835 |
keyFound = true; |
|
2836 |
||
2837 |
EnumMember enummember; |
|
2838 |
||
2839 |
string elementName; |
|
2840 |
string elementType; |
|
2841 |
string structElementVal; |
|
2842 |
||
2843 |
bool lineend = false; |
|
2844 |
int length = int(line.size()); |
|
2845 |
||
2846 |
for (int j = 0; j < length ; j++) |
|
2847 |
{
|
|
2848 |
int temp = line.at(j); |
|
2849 |
//int templie = line.at(j); |
|
2850 |
switch (temp) |
|
2851 |
{
|
|
2852 |
case 32: // For ' ' |
|
2853 |
case 9: //for Invalid space |
|
2854 |
{
|
|
2855 |
if (structInuse == true && tempData.size() > 0) |
|
2856 |
{
|
|
2857 |
if ( elementfound == true ) |
|
2858 |
{
|
|
2859 |
for (int k = 0 ; k < 23 ; k++ ) |
|
2860 |
{
|
|
2861 |
// got the type, will check with all possible data types.Else it will be member name. |
|
2862 |
int loc = int(line.find_first_of(keywords[k])); |
|
2863 |
string key(keywords[k]); |
|
2864 |
if (tempData == key ) |
|
2865 |
{
|
|
2866 |
elementType.append(keywords[k]); |
|
2867 |
tempData.clear(); |
|
2868 |
break; |
|
2869 |
} |
|
2870 |
} |
|
2871 |
} |
|
2872 |
} |
|
2873 |
if (macroInuse == true && macro.macroName.size() <=0 && tempData.size() > 0) // can be macro name |
|
2874 |
{
|
|
2875 |
macro.macroName = tempData; |
|
2876 |
macro.lineNo = lineNo; |
|
2877 |
tempData.clear(); |
|
2878 |
} |
|
2879 |
} |
|
2880 |
break; |
|
2881 |
case 59://For ';' |
|
2882 |
{
|
|
2883 |
if ( structInuse == true && elementfound == true && tempData.size() > 0) |
|
2884 |
{
|
|
2885 |
elementName.append(tempData); |
|
2886 |
elementMember.elementName = elementName; |
|
2887 |
elementMember.elementType = elementType; |
|
2888 |
elementMember.lineNo = lineNo; |
|
2889 |
if (valueFound == true) |
|
2890 |
{
|
|
2891 |
elementMember.elementValue= structElementVal; |
|
2892 |
valueFound = false; |
|
2893 |
} |
|
2894 |
lStruct.members.push_back (elementMember); |
|
2895 |
tempData.clear(); |
|
2896 |
} |
|
2897 |
||
2898 |
if(macroInuse ==false) |
|
2899 |
break; |
|
2900 |
||
2901 |
} |
|
2902 |
||
2903 |
case 44://For ',' |
|
2904 |
{
|
|
2905 |
if(macroInuse ==false) |
|
2906 |
{
|
|
2907 |
if ( enumInuse == true && elementfound == true && tempData.size() > 0) |
|
2908 |
{
|
|
2909 |
if (valueFound == true) |
|
2910 |
{
|
|
2911 |
enummember.enumVal = elementVal.c_str(); |
|
2912 |
char *p; |
|
2913 |
// convert enumVal to long , so that can be incremented if required. |
|
2914 |
currentEnumVal = strtol(enummember.enumVal.c_str(),&p,0); |
|
2915 |
valueFound = false; |
|
2916 |
} |
|
2917 |
else |
|
2918 |
{
|
|
2919 |
currentEnumVal += 1; |
|
2920 |
string p; |
|
2921 |
// convert long to string |
|
2922 |
enummember.enumVal = ltoa(currentEnumVal,p,0); |
|
2923 |
} |
|
2924 |
enummember.enumMemName.append(tempData); |
|
2925 |
enummember.lineNo = lineNo; |
|
2926 |
||
2927 |
lEnum.enums.push_back(enummember); |
|
2928 |
||
2929 |
tempData.clear(); |
|
2930 |
elementVal.clear(); |
|
2931 |
} |
|
2932 |
break; |
|
2933 |
} |
|
2934 |
} |
|
2935 |
||
2936 |
case 61: //For '=' |
|
2937 |
{
|
|
2938 |
if(macroInuse == false) |
|
2939 |
{
|
|
2940 |
valueFound = true; |
|
2941 |
break; |
|
2942 |
} |
|
2943 |
} |
|
2944 |
//break; |
|
2945 |
||
2946 |
case 123: //For '{'
|
|
2947 |
{
|
|
2948 |
if(macroInuse ==false) |
|
2949 |
{
|
|
2950 |
if(tempData.size() > 0 ) |
|
2951 |
{
|
|
2952 |
if(structInuse == true) |
|
2953 |
{
|
|
2954 |
lStruct.structName.assign(tempData); |
|
2955 |
lStruct.lineNo = lineNo; |
|
2956 |
} |
|
2957 |
else |
|
2958 |
{
|
|
2959 |
lEnum.enumName.assign(tempData); |
|
2960 |
lEnum.lineNo = lineNo; |
|
2961 |
} |
|
2962 |
} |
|
2963 |
tempData.clear(); |
|
2964 |
elementfound = true; |
|
2965 |
||
2966 |
break; |
|
2967 |
} |
|
2968 |
} |
|
2969 |
case 125: //For '}' |
|
2970 |
{
|
|
2971 |
if(macroInuse ==false) |
|
2972 |
{
|
|
2973 |
if(structInuse == true) |
|
2974 |
{
|
|
2975 |
structInuse = false; |
|
2976 |
if(tempData.size() > 0) // if some inline macro is present |
|
2977 |
{
|
|
2978 |
elementMember.elementName = tempData ; |
|
2979 |
elementMember.elementType = ""; |
|
2980 |
elementMember.lineNo = lineNo; |
|
2981 |
lStruct.members.push_back(elementMember); |
|
2982 |
} |
|
2983 |
resource.structList.push_back(lStruct); |
|
2984 |
} |
|
2985 |
else if ( enumInuse == true ) |
|
2986 |
{
|
|
2987 |
if (elementfound == true && tempData.size() > 0) |
|
2988 |
{
|
|
2989 |
if (valueFound == true) |
|
2990 |
{
|
|
2991 |
enummember.enumVal = elementVal.c_str(); |
|
2992 |
char *p; |
|
2993 |
// convert enumVal to long , so that can be incremented if required. |
|
2994 |
currentEnumVal = strtol(enummember.enumVal.c_str(),&p,0); |
|
2995 |
valueFound = false; |
|
2996 |
} |
|
2997 |
else |
|
2998 |
{
|
|
2999 |
currentEnumVal += 1; |
|
3000 |
string p; |
|
3001 |
// convert long to string |
|
3002 |
enummember.enumVal = ltoa(currentEnumVal,p,0); |
|
3003 |
} |
|
3004 |
||
3005 |
enummember.lineNo = lineNo; |
|
3006 |
||
3007 |
enummember.enumMemName.append(tempData); |
|
3008 |
||
3009 |
lEnum.enums.push_back(enummember); |
|
3010 |
} |
|
3011 |
currentEnumVal = -1; |
|
3012 |
elementVal.clear(); |
|
3013 |
enumInuse = false; |
|
3014 |
resource.enumList.push_back(lEnum); |
|
3015 |
} |
|
3016 |
keyFound = false; |
|
3017 |
elementfound = false; |
|
3018 |
tempData.clear(); |
|
3019 |
||
3020 |
break; |
|
3021 |
} |
|
3022 |
} |
|
3023 |
default: |
|
3024 |
{
|
|
3025 |
// followings are to ignore any comment line in between. |
|
3026 |
if( j+1 <length) |
|
3027 |
{
|
|
3028 |
if (line.at(j) == '/' ) |
|
3029 |
{
|
|
3030 |
if(line.at(j+1) == '*') |
|
3031 |
ignoreLine = true; |
|
3032 |
||
3033 |
else if ( line.at(j+1) == '/') |
|
3034 |
{
|
|
3035 |
lineend = true; |
|
3036 |
break; |
|
3037 |
} |
|
3038 |
} |
|
3039 |
if(ignoreLine == true) |
|
3040 |
{
|
|
3041 |
if (j+1 <length && line.at(j) == '*' && line.at(j+1) == '/') |
|
3042 |
{
|
|
3043 |
ignoreLine = false; |
|
3044 |
j = j+2; |
|
3045 |
continue; |
|
3046 |
||
3047 |
} |
|
3048 |
} |
|
3049 |
} // comment line checks ended |
|
3050 |
||
3051 |
if(ignoreLine == false && j<length) |
|
3052 |
{
|
|
3053 |
// newline character's int value is 92, for macros, newline char can be present mainly. |
|
3054 |
if ((int) line.at(j)== 92 && macroInuse == true && tempData.size() > 0) // can be macro name |
|
3055 |
{
|
|
3056 |
newLinecharFound = true; // new line character found |
|
3057 |
if ( macro.macroName.size() <=0) |
|
3058 |
{
|
|
3059 |
macro.macroName = tempData; |
|
3060 |
macro.lineNo = lineNo; |
|
3061 |
} |
|
3062 |
else |
|
3063 |
{
|
|
3064 |
macro.macroVal.append(tempData); |
|
3065 |
} |
|
3066 |
tempData.clear(); |
|
3067 |
||
3068 |
} |
|
3069 |
// Check macro definition ended after newlines |
|
3070 |
if( (int) line.at(j)!= 92 && j+1 >= length && macroInuse == true && newLinecharFound == true ) |
|
3071 |
{
|
|
3072 |
newLinecharFound =false; |
|
3073 |
//macroInuse = false; |
|
3074 |
//macro.macroVal.append(tempData); |
|
3075 |
//tempData.clear(); |
|
3076 |
break; |
|
3077 |
} |
|
3078 |
if (enumInuse == true || macroInuse == true || structInuse == true) |
|
3079 |
{
|
|
3080 |
if(valueFound == true) |
|
3081 |
{
|
|
3082 |
if ( structInuse == true ) |
|
3083 |
structElementVal.push_back(line.at(j)); |
|
3084 |
else |
|
3085 |
elementVal.push_back(line.at(j)); |
|
3086 |
} |
|
3087 |
else |
|
3088 |
{
|
|
3089 |
if( (int)line.at(j) != 92)// ignore newline character |
|
3090 |
tempData.push_back(line.at(j)); |
|
3091 |
} |
|
3092 |
} |
|
3093 |
} |
|
3094 |
||
3095 |
||
3096 |
} |
|
3097 |
break; |
|
3098 |
} |
|
3099 |
if (lineend == true) |
|
3100 |
break; |
|
3101 |
}// line end |
|
3102 |
||
3103 |
// Macro structure ended, fill the values. |
|
3104 |
if( macroInuse == true && newLinecharFound == false && tempData.size() > 0 ) |
|
3105 |
{
|
|
3106 |
if(tempData.size()> 0 ) |
|
3107 |
{
|
|
3108 |
macro.macroVal.append(tempData); |
|
3109 |
tempData.clear(); |
|
3110 |
} |
|
3111 |
keyFound = false; |
|
3112 |
macroInuse = false ; |
|
3113 |
resource.macroList.push_back(macro); |
|
3114 |
} |
|
3115 |
} |
|
3116 |
||
3117 |
}// End of all lines in resource file |
|
3118 |
||
3119 |
} |
|
3120 |
||
3121 |
void Analyser::compareResources(ResourceContent &baseResource, ResourceContent &curResource, ReportGenerator& report) |
|
3122 |
{
|
|
3123 |
int base_struct_no = (int)baseResource.structList.size(); |
|
3124 |
int cur_struct_no = (int)curResource.structList.size(); |
|
3125 |
||
3126 |
int base_enum_no = (int)baseResource.enumList.size(); |
|
3127 |
int cur_enum_no = (int)curResource.enumList.size(); |
|
3128 |
||
3129 |
int base_macro_no = (int)baseResource.macroList.size(); |
|
3130 |
int cur_macro_no = (int)curResource.macroList.size(); |
|
3131 |
||
3132 |
StructElement baseStruct; |
|
3133 |
StructElement curStruct; |
|
3134 |
||
3135 |
EnumElement baseEnum; |
|
3136 |
EnumElement curEnum; |
|
3137 |
||
3138 |
MacroElement baseMacro; |
|
3139 |
MacroElement curMacro; |
|
3140 |
||
3141 |
for(int i = 0; i < base_struct_no; i++ ) |
|
3142 |
{
|
|
3143 |
baseStruct = baseResource.structList.at(i); |
|
3144 |
bool structFound = false; |
|
3145 |
for(int j = 0; j < cur_struct_no; j++ ) |
|
3146 |
{
|
|
3147 |
curStruct = curResource.structList.at(j); |
|
3148 |
if(baseStruct.structName == curStruct.structName ) |
|
3149 |
{
|
|
3150 |
int baseMemNo = (int)baseStruct.members.size(); |
|
3151 |
int curMemNo = (int)curStruct.members.size(); |
|
3152 |
||
3153 |
structFound = true; |
|
3154 |
||
3155 |
for( int bInner = 0; bInner < baseMemNo; bInner++ ) |
|
3156 |
{
|
|
3157 |
bool memFound = false; |
|
3158 |
for ( int cInner = 0; cInner < curMemNo; cInner++ ) |
|
3159 |
{
|
|
3160 |
if ( baseStruct.members.at(bInner).elementName == curStruct.members.at(cInner).elementName ) |
|
3161 |
{
|
|
3162 |
memFound = true; |
|
3163 |
if(baseStruct.members.at(bInner).elementType == curStruct.members.at(cInner).elementType) |
|
3164 |
{
|
|
3165 |
if(baseStruct.members.at(bInner).elementValue.size() > 0 |
|
3166 |
&& (baseStruct.members.at(bInner).elementValue != curStruct.members.at(cInner).elementValue) ) |
|
3167 |
{
|
|
3168 |
//add issue member value mismatch |
|
3169 |
string bVal = baseStruct.structName + "::" + baseStruct.members.at(bInner).elementName; |
|
3170 |
string cVal = curStruct.members.at(cInner).elementValue; |
|
3171 |
int lineNo = curStruct.members.at(cInner).lineNo; |
|
3172 |
report.addIssue(baseResource.RHFileName, bVal, EIssueIdentityStructMember, EIssueTypeChangeInInitialisation, |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3173 |
ESeverityNULL, ESeveritySCBreak, cVal, lineNo,"",curResource.RHFileName,""); |
| 0 | 3174 |
} |
3175 |
} |
|
3176 |
else |
|
3177 |
{
|
|
3178 |
// add issue tyechange |
|
3179 |
string bType = baseStruct.structName + "::" + baseStruct.members.at(bInner).elementName; |
|
3180 |
string cType = curStruct.members.at(cInner).elementType; |
|
3181 |
int lineNo = curStruct.members.at(cInner).lineNo; |
|
3182 |
report.addIssue(baseResource.RHFileName, bType, EIssueIdentityStructMember, EIssueTypeChangeInType, |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3183 |
ESeverityNULL, ESeveritySCBreak, cType, lineNo,"",curResource.RHFileName,""); |
| 0 | 3184 |
} |
3185 |
||
3186 |
break; |
|
3187 |
||
3188 |
}// memeber name matched |
|
3189 |
}// loop thru all curr struct member |
|
3190 |
||
3191 |
if( memFound == false) |
|
3192 |
{
|
|
3193 |
// Add Issue Member not found // baseStruct.members.at(bInner) |
|
3194 |
string bMember = baseStruct.structName + "::" + baseStruct.members.at(bInner).elementName; |
|
3195 |
int lineNo = curStruct.lineNo; |
|
3196 |
report.addIssue(baseResource.RHFileName, bMember, EIssueIdentityStructMember, EIssueTypeRemoval, |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3197 |
ESeverityNULL,ESeveritySCBreak, "", lineNo,"",curResource.RHFileName,""); |
| 0 | 3198 |
} |
3199 |
}// loop base struct member |
|
3200 |
||
3201 |
}// struct name match |
|
3202 |
}// loop curr structs |
|
3203 |
||
3204 |
if( structFound == false ) |
|
3205 |
{
|
|
3206 |
//Add issue struct not found |
|
3207 |
report.addIssue(baseResource.RHFileName, baseStruct.structName, EIssueIdentityStruct, EIssueTypeRemoval, |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3208 |
ESeverityNULL, ESeveritySCBreak, "", 0,"",curResource.RHFileName,""); |
| 0 | 3209 |
} |
3210 |
}//loop base structs |
|
3211 |
||
3212 |
// --------------Enum Comparison ------------ |
|
3213 |
vector<EnumMember>baseEnumNameEmptyMemberList; |
|
3214 |
vector<EnumMember>curEnumNameEmptyMemberList; |
|
3215 |
vector<EnumElement> bEnumList; |
|
3216 |
vector<EnumElement> cEnumList; |
|
3217 |
||
3218 |
for( int b = 0; b < base_enum_no; b++) |
|
3219 |
{
|
|
3220 |
baseEnum = baseResource.enumList.at(b); |
|
3221 |
||
3222 |
if(baseEnum.enumName.size()<=0) |
|
3223 |
{
|
|
3224 |
for(int k = 0; k < (int)baseEnum.enums.size(); k++) |
|
3225 |
{
|
|
3226 |
baseEnumNameEmptyMemberList.push_back(baseEnum.enums.at(k)); |
|
3227 |
} |
|
3228 |
} |
|
3229 |
else |
|
3230 |
{
|
|
3231 |
bEnumList.push_back(baseEnum); |
|
3232 |
} |
|
3233 |
} |
|
3234 |
||
3235 |
for( int c = 0; c < cur_enum_no; c++) |
|
3236 |
{
|
|
3237 |
curEnum = curResource.enumList.at(c); |
|
3238 |
||
3239 |
if(curEnum.enumName.size()<=0) |
|
3240 |
{
|
|
3241 |
for(int k = 0; k < (int)curEnum.enums.size(); k++) |
|
3242 |
{
|
|
3243 |
curEnumNameEmptyMemberList.push_back(curEnum.enums.at(k)); |
|
3244 |
} |
|
3245 |
} |
|
3246 |
else |
|
3247 |
{
|
|
3248 |
cEnumList.push_back(curEnum); |
|
3249 |
} |
|
3250 |
} |
|
3251 |
||
3252 |
// Compare and report issue for enum list with name |
|
3253 |
for( int l = 0; l < (int) bEnumList.size(); l++) |
|
3254 |
{
|
|
3255 |
baseEnum = bEnumList.at(l); |
|
3256 |
bool enumFound = false; |
|
3257 |
||
3258 |
for( int m = 0; m < (int)cEnumList.size(); m++ ) |
|
3259 |
{
|
|
3260 |
curEnum = cEnumList.at(m); |
|
3261 |
if ( baseEnum.enumName == curEnum.enumName ) |
|
3262 |
{
|
|
3263 |
int bMemNo = (int)baseEnum.enums.size(); |
|
3264 |
int cMemNo = (int)curEnum.enums.size(); |
|
3265 |
||
3266 |
enumFound = true; |
|
3267 |
||
3268 |
for ( int outer = 0; outer < bMemNo; outer++ ) |
|
3269 |
{
|
|
3270 |
bool enumMemFound = false; |
|
3271 |
for( int inner = 0; inner < cMemNo; inner++ ) |
|
3272 |
{
|
|
3273 |
if(baseEnum.enums.at(outer).enumMemName == curEnum.enums.at(inner).enumMemName ) |
|
3274 |
{
|
|
3275 |
enumMemFound = true; |
|
3276 |
// member name found |
|
3277 |
if(baseEnum.enums.at(outer).enumVal.size() > 0 ) |
|
3278 |
{
|
|
3279 |
if (baseEnum.enums.at(outer).enumVal != curEnum.enums.at(inner).enumVal ) |
|
3280 |
{
|
|
3281 |
//add issue Member value changed |
|
3282 |
string baseEnumVal = baseEnum.enumName +"::" + baseEnum.enums.at(outer).enumMemName; |
|
3283 |
string curEnumVal = curEnum.enums.at(inner).enumVal; |
|
3284 |
int lineNo = curEnum.enums.at(inner).lineNo; |
|
3285 |
||
3286 |
report.addIssue(baseResource.RHFileName, baseEnumVal, EIssueIdentityEnumerationValue, EIssueTypeChangeInInitialisation, |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3287 |
ESeverityNULL, ESeveritySCBreak, curEnumVal, lineNo,"",curResource.RHFileName,""); |
| 0 | 3288 |
} |
3289 |
} |
|
3290 |
break; |
|
3291 |
} |
|
3292 |
} // loop cur mems |
|
3293 |
||
3294 |
if ( enumMemFound == false) |
|
3295 |
{
|
|
3296 |
// Add Enum Member Missing |
|
3297 |
string bMemName = baseEnum.enumName +"::" + baseEnum.enums.at(outer).enumMemName; |
|
3298 |
int lineNo = curEnum.lineNo; |
|
3299 |
report.addIssue(baseResource.RHFileName, bMemName, EIssueIdentityEnumerationValue, EIssueTypeRemoval, |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3300 |
ESeverityNULL, ESeveritySCBreak, "", lineNo,"",curResource.RHFileName,""); |
| 0 | 3301 |
|
3302 |
} |
|
3303 |
}// loop base mems |
|
3304 |
||
3305 |
break; |
|
3306 |
}// enum name matched |
|
3307 |
}// loop cur enums |
|
3308 |
||
3309 |
if (enumFound == false ) |
|
3310 |
{
|
|
3311 |
// Enum List missing |
|
3312 |
string bEnum = baseEnum.enumName; |
|
3313 |
string cEnum = curEnum.enumName; |
|
3314 |
report.addIssue(baseResource.RHFileName, bEnum, EIssueIdentityEnumerationValue, EIssueTypeRemoval, |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3315 |
ESeverityNULL, ESeveritySCBreak, cEnum, 0,"",curResource.RHFileName,""); |
| 0 | 3316 |
} |
3317 |
}//base enums |
|
3318 |
||
3319 |
// Now check for enum list with no enum name, in this case check member name and value |
|
3320 |
if(baseEnumNameEmptyMemberList.size() > 0) |
|
3321 |
{
|
|
3322 |
EnumMember bEnumMem; |
|
3323 |
for(unsigned long i = 0; i < (unsigned long)baseEnumNameEmptyMemberList.size(); i++) |
|
3324 |
{
|
|
3325 |
bEnumMem = baseEnumNameEmptyMemberList.at(i); |
|
3326 |
EnumMember cEnumMem; |
|
3327 |
bool enumMemFound = false; |
|
3328 |
for(unsigned long j = 0; j <(unsigned long) curEnumNameEmptyMemberList.size(); j++ ) |
|
3329 |
{
|
|
3330 |
cEnumMem = curEnumNameEmptyMemberList.at(j); |
|
3331 |
if(bEnumMem.enumMemName == cEnumMem.enumMemName) |
|
3332 |
{
|
|
3333 |
enumMemFound = true; |
|
3334 |
if(bEnumMem.enumVal != cEnumMem.enumVal ) |
|
3335 |
{
|
|
3336 |
//add issue enum value changed |
|
3337 |
string baseEnumVal = "::" + bEnumMem.enumMemName; |
|
3338 |
string curEnumVal = cEnumMem.enumMemName; |
|
3339 |
int lineNo = cEnumMem.lineNo; |
|
3340 |
||
3341 |
report.addIssue(baseResource.RHFileName, baseEnumVal, EIssueIdentityEnumerationValue, EIssueTypeChangeInInitialisation, |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3342 |
ESeverityNULL, ESeveritySCBreak, curEnumVal, lineNo,"",curResource.RHFileName,""); |
| 0 | 3343 |
} |
3344 |
break; |
|
3345 |
} |
|
3346 |
} |
|
3347 |
if(enumMemFound == false) |
|
3348 |
{
|
|
3349 |
// add issue enum mem mising |
|
3350 |
string bMemName = "::" + bEnumMem.enumMemName; |
|
3351 |
report.addIssue(baseResource.RHFileName, bMemName, EIssueIdentityEnumerationValue, EIssueTypeRemoval, |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3352 |
ESeverityNULL, ESeveritySCBreak, "", 0,"",curResource.RHFileName,""); |
| 0 | 3353 |
} |
3354 |
} |
|
3355 |
} |
|
3356 |
||
3357 |
||
3358 |
// --------------------- Macro Comparision -------------- |
|
3359 |
||
3360 |
for (int p = 0; p < base_macro_no; p++ ) |
|
3361 |
{
|
|
3362 |
bool macroFound = false; |
|
3363 |
baseMacro = baseResource.macroList.at(p); |
|
3364 |
for (int q = 0; q < cur_macro_no; q++ ) |
|
3365 |
{
|
|
3366 |
curMacro = curResource.macroList.at(q); |
|
3367 |
if(baseMacro.macroName == curMacro.macroName ) |
|
3368 |
{ // check Macro value
|
|
3369 |
macroFound = true; |
|
3370 |
if(baseMacro.macroVal != curMacro.macroVal ) |
|
3371 |
{
|
|
3372 |
//add issue macro value mismatch |
|
3373 |
report.addIssue(baseResource.RHFileName, baseMacro.macroName, EIssueIdentityMacro, EIssueTypeChange, |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3374 |
ESeverityNULL, ESeveritySCBreak, curMacro.macroVal, curMacro.lineNo,"",curResource.RHFileName,""); |
| 0 | 3375 |
} |
3376 |
break; // macro name matched |
|
3377 |
} |
|
3378 |
||
3379 |
} |
|
3380 |
||
3381 |
if (macroFound == false ) |
|
3382 |
{
|
|
3383 |
// add issue macro not found |
|
3384 |
report.addIssue(baseResource.RHFileName, baseMacro.macroName, EIssueIdentityMacro, EIssueTypeRemoval, |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3385 |
ESeverityNULL, ESeveritySCBreak, "", 0,"",curResource.RHFileName,""); |
| 0 | 3386 |
} |
3387 |
} |
|
3388 |
||
3389 |
||
3390 |
||
3391 |
} |
|
3392 |