| author | shrivatsa |
| Mon, 27 Sep 2010 14:51:17 +0530 | |
| changeset 12 | a0eee409ff14 |
| parent 3 | ebe3f8f03b59 |
| 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 |
||
24 |
#include <assert.h> |
|
25 |
#include <map> |
|
26 |
#include <list> |
|
27 |
#include <string> |
|
28 |
#include <time.h> |
|
29 |
#include <xercesc/dom/DOM.hpp> |
|
30 |
||
31 |
#include "BBCAnalyser.h" |
|
32 |
#include "BBCPreAnalysis.h" |
|
33 |
#include "Issues.h" |
|
34 |
#include "ReportGenerator.h" |
|
35 |
#include "ReportIssue.h" |
|
36 |
#include "XMLUtils.h" |
|
37 |
#include "XMLStringConst.h" |
|
38 |
#include "VariableNodeAnalysis.h" |
|
39 |
#include "EnumNodeAnalysis.h" |
|
40 |
#include "FunctionNodeAnalysis.h" |
|
41 |
#include "TypedefNodeAnalysis.h" |
|
42 |
#include "OperatorFunctionNodeAnalysis.h" |
|
43 |
#include "UnionNodeAnalysis.h" |
|
44 |
#include "ClassNodeAnalysis.h" |
|
45 |
#include "StructNodeAnalysis.h" |
|
46 |
#include "NodeTypeComparator.h" |
|
47 |
#include "Utils.h" |
|
48 |
||
49 |
using namespace std; |
|
50 |
||
51 |
XERCES_CPP_NAMESPACE_USE |
|
52 |
||
53 |
||
54 |
||
55 |
struct ConstructorElement |
|
56 |
{
|
|
57 |
const XMLCHAR* iEntityName; |
|
58 |
NodeAnalysis::Constructor iConstructor; |
|
59 |
}; |
|
60 |
||
61 |
// Table of different node analysis constructor functions |
|
62 |
const ConstructorElement KConstructorTable[KEntityComparisonTableCount]= |
|
63 |
{
|
|
64 |
{KXMLBaseString,UnderConstructionNodeAnalysis::Construct},
|
|
65 |
{KXMLFundamentalTypeString,UnderConstructionNodeAnalysis::Construct},
|
|
66 |
{KXMLTypedefString,TypedefNodeAnalysis::Construct},//
|
|
67 |
{KXMLNamespaceString,UnderConstructionNodeAnalysis::Construct},
|
|
68 |
{KXMLCvQualifiedTypeString,UnderConstructionNodeAnalysis::Construct},
|
|
69 |
{KXMLVariableString,VariableNodeAnalysis::Construct},//
|
|
70 |
{KXMLFundamentalTypeString,UnderConstructionNodeAnalysis::Construct},
|
|
71 |
{KXMLTypedefString,UnderConstructionNodeAnalysis::Construct},
|
|
72 |
{KXMLNamespaceString,UnderConstructionNodeAnalysis::Construct},
|
|
73 |
{KXMLFunctionString,FunctionNodeAnalysis::Construct},//
|
|
74 |
{KXMLEnumerationString,EnumNodeAnalysis::Construct},//
|
|
75 |
{KXMLFieldString,UnderConstructionNodeAnalysis::Construct},
|
|
76 |
{KXMLArgumentString,UnderConstructionNodeAnalysis::Construct},
|
|
77 |
{KXMLEllipsisString,UnderConstructionNodeAnalysis::Construct},
|
|
78 |
{KXMLArrayTypeString,UnderConstructionNodeAnalysis::Construct},
|
|
79 |
{KXMLClassString,ClassNodeAnalysis::Construct},//
|
|
80 |
{KXMLConstructorString,UnderConstructionNodeAnalysis::Construct},
|
|
81 |
{KXMLConverterString,UnderConstructionNodeAnalysis::Construct},
|
|
82 |
{KXMLDestructorString,UnderConstructionNodeAnalysis::Construct},
|
|
83 |
{KXMLEnumValueString,UnderConstructionNodeAnalysis::Construct},
|
|
84 |
{KXMLFileString,UnderConstructionNodeAnalysis::Construct},
|
|
85 |
{KXMLFunctionTypeString,UnderConstructionNodeAnalysis::Construct},
|
|
86 |
{KXMLMethodString,UnderConstructionNodeAnalysis::Construct},
|
|
87 |
{KXMLMethodTypeString,UnderConstructionNodeAnalysis::Construct},
|
|
88 |
{KXMLNamespaceAliasString,UnderConstructionNodeAnalysis::Construct},
|
|
89 |
{KXMLOffsetTypeString,UnderConstructionNodeAnalysis::Construct},
|
|
90 |
{KXMLOperatorFunctionString,OperatorFunctionNodeAnalysis::Construct},
|
|
91 |
{KXMLOperatorMethodString,UnderConstructionNodeAnalysis::Construct},
|
|
92 |
{KXMLPointerTypeString,UnderConstructionNodeAnalysis::Construct},
|
|
93 |
{KXMLReferenceTypeString,UnderConstructionNodeAnalysis::Construct},
|
|
94 |
{KXMLStructString,StructNodeAnalysis::Construct},
|
|
95 |
{KXMLUnimplementedString,UnderConstructionNodeAnalysis::Construct},
|
|
96 |
{KXMLUnionString,UnionNodeAnalysis::Construct}
|
|
97 |
}; |
|
98 |
||
99 |
// ---------------------------------------------------------------------------- |
|
100 |
// NodeAnalysis::FindNodeAnalysisConstructor |
|
101 |
// ---------------------------------------------------------------------------- |
|
102 |
// |
|
103 |
NodeAnalysis::Constructor FindNodeAnalysisConstructor(const XMLCh* nodeName) |
|
104 |
{
|
|
105 |
int i = 0; |
|
106 |
||
107 |
for (i = 0;i < KEntityComparisonTableCount; ++i) |
|
108 |
{
|
|
109 |
if ( Equals(KConstructorTable[i].iEntityName,nodeName) ) |
|
110 |
{
|
|
111 |
return KConstructorTable[i].iConstructor; |
|
112 |
} |
|
113 |
} |
|
114 |
return NULL; |
|
115 |
} |
|
116 |
||
117 |
// ---------------------------------------------------------------------------- |
|
118 |
// BBCPreAnalysis::preAnalyseClassForVirtuality |
|
119 |
// |
|
120 |
// Analyse for virtuality |
|
121 |
// ---------------------------------------------------------------------------- |
|
122 |
// |
|
123 |
bool BBCPreAnalysis::preAnalyseClassForVirtuality(HANodeIterator classNode) |
|
124 |
{
|
|
125 |
bool isvirtual = false; |
|
126 |
bool hasvirtualbases = false; |
|
127 |
||
128 |
//Check to see if we have already inspected this class |
|
129 |
if ( classNode.GetAttribute(KXMLBBCVirtualString) ) |
|
130 |
{
|
|
131 |
return classNode.CheckForBooleanAttribute(KXMLBBCVirtualString); |
|
132 |
} |
|
133 |
||
134 |
if ( classNode->hasChildNodes() ) |
|
135 |
{
|
|
136 |
//Check for virtual bases first as it is quicker |
|
137 |
DOMNodeList * childs = classNode->getChildNodes(); |
|
138 |
||
139 |
XMLSize_t childcount = childs->getLength(); |
|
140 |
||
141 |
for (unsigned int i = 0; i < childcount; ++i) |
|
142 |
{
|
|
143 |
DOMNode* child = childs->item(i); |
|
144 |
||
145 |
//Skip any other than Base node |
|
146 |
if ( !Equals(child->getNodeName(),KXMLBaseString) ) |
|
147 |
{
|
|
148 |
continue; |
|
149 |
} |
|
150 |
||
151 |
HANodeIterator childclass(classNode); |
|
152 |
childclass.current = child; |
|
153 |
||
154 |
if ( childclass.CheckForBooleanAttribute(KXMLVirtualString) ) |
|
155 |
{
|
|
156 |
classNode.SetAttribute(KXMLBBCVirtualInheritanceString,KXML1String); |
|
157 |
hasvirtualbases = true; |
|
158 |
} |
|
159 |
||
160 |
const XMLCh * classid = childclass.GetAttribute(KXMLTypeString); |
|
161 |
||
162 |
assert(classid != NULL); |
|
163 |
||
164 |
bool ret = childclass.FindNodeById(classid); |
|
165 |
||
166 |
assert(ret == true); |
|
167 |
||
168 |
if ( preAnalyseClassForVirtuality( childclass ) ) |
|
169 |
{
|
|
170 |
//The class is virtual, mark it to the xml document and return |
|
171 |
classNode.SetAttribute(KXMLBBCVirtualString, KXML1String); |
|
172 |
isvirtual = true; |
|
173 |
} |
|
174 |
||
175 |
if ( childclass.CheckForBooleanAttribute(KXMLBBCVirtualInheritanceString) ) |
|
176 |
{
|
|
177 |
classNode.SetAttribute(KXMLBBCVirtualInheritanceString,KXML1String); |
|
178 |
hasvirtualbases = true; |
|
179 |
} |
|
180 |
} |
|
181 |
||
182 |
} |
|
183 |
||
184 |
//We have already detected that this is virtual class |
|
185 |
if ( isvirtual ) |
|
186 |
{
|
|
187 |
ClassGenerateVirtualTable(classNode); |
|
188 |
return true; |
|
189 |
} |
|
190 |
||
191 |
//Go through the methods of the class and check them for virtuality |
|
192 |
const XMLCh* attributeValue = classNode.GetAttribute(KXMLMembersString); |
|
193 |
||
194 |
if (attributeValue) |
|
195 |
{
|
|
196 |
BaseRefVectorOf< XMLCh > * memberids_ptr = XMLString::tokenizeString(attributeValue); |
|
197 |
auto_ptr<BaseRefVectorOf< XMLCh > > memberids(memberids_ptr); |
|
198 |
||
199 |
for (unsigned int i = 0; i < memberids->size(); ++i) |
|
200 |
{
|
|
201 |
const XMLCh * memberid = memberids->elementAt(i); |
|
202 |
||
203 |
HANodeIterator member(classNode); |
|
204 |
bool memberfound = member.FindNodeById(memberid); |
|
205 |
||
206 |
if ( memberfound ) |
|
207 |
{
|
|
208 |
if ( member.CheckForBooleanAttribute(KXMLVirtualString) || |
|
209 |
member.CheckForBooleanAttribute(KXMLPureVirtualString)) |
|
210 |
{
|
|
211 |
//Generate primary virtual table for the class |
|
212 |
ClassGenerateVirtualTable(classNode); |
|
213 |
//The class is virtual, mark it to the xml document and return |
|
214 |
classNode.SetAttribute(KXMLBBCVirtualString, KXML1String); |
|
215 |
return true; |
|
216 |
} |
|
217 |
} |
|
218 |
else |
|
219 |
{
|
|
220 |
//The tree is broken |
|
221 |
assert(false); |
|
222 |
} |
|
223 |
} |
|
224 |
//memberids->cleanup(); |
|
225 |
//delete memberids; |
|
226 |
} |
|
227 |
||
228 |
classNode.SetAttribute(KXMLBBCVirtualString, KXML0String); |
|
229 |
return false; |
|
230 |
} |
|
231 |
||
232 |
// ---------------------------------------------------------------------------- |
|
233 |
// BBCAnalyser::preAnalyseClassForDerivability |
|
234 |
// |
|
235 |
// Check for derivability. The class is derivable iff: |
|
236 |
// 1. Has a public or protected explicitely declared exported constructor |
|
237 |
// 2. Has a public or protected inline constructor |
|
238 |
// In GCCXML: |
|
239 |
// |
|
240 |
// Check methods of type "Constructor" |
|
241 |
// |
|
242 |
// Constructor type / attribute:| artificial | explicit | inline | exported |
|
243 |
//-------------------------------------------------------------------------- |
|
244 |
// implicite inline constructor | x | x | x | |
|
245 |
// inline constructor | | (x) | x | |
|
246 |
// exported constructor | | (x) | | x |
|
247 |
// ---------------------------------------------------------------------------- |
|
248 |
// |
|
249 |
void BBCPreAnalysis::preAnalyseClassForDerivability(HANodeIterator classNode) |
|
250 |
{
|
|
251 |
//Go through the methods of the class and check them for constructor |
|
252 |
const XMLCh* attributeValue = classNode.GetAttribute(KXMLMembersString); |
|
253 |
||
254 |
//Default to public desctructor as it is same as no desctructor at all |
|
255 |
classNode.SetAttribute(KXMLBBCDestructorAccessString,KXMLBBCAccessPublicString); |
|
256 |
||
257 |
if (attributeValue) |
|
258 |
{
|
|
259 |
BaseRefVectorOf< XMLCh > * memberids_ptr = XMLString::tokenizeString (attributeValue); |
|
260 |
auto_ptr<BaseRefVectorOf< XMLCh > > memberids(memberids_ptr); |
|
261 |
||
262 |
for (unsigned int i = 0; i < memberids->size(); ++i) |
|
263 |
{
|
|
264 |
const XMLCh * memberid = memberids->elementAt(i); |
|
265 |
||
266 |
HANodeIterator member(classNode); |
|
267 |
||
268 |
if ( member.FindNodeById(memberid) ) |
|
269 |
{
|
|
270 |
//The member is constructor |
|
271 |
if ( Equals(member->getNodeName(),KXMLConstructorString) ) |
|
272 |
{
|
|
273 |
//Check if the constructor is protected or public |
|
274 |
const XMLCh* accessAttribute = member.GetAttribute(KXMLAccessString); |
|
275 |
||
276 |
if ( Equals(accessAttribute,KXMLProtectedString) || Equals(accessAttribute,KXMLPublicString) ) |
|
277 |
{
|
|
278 |
//If the constructor is artificial (compiler generated) we need to check for the explicit attribute |
|
279 |
// to recognize the proper constructor and not the helper constructor generated by the compiler |
|
280 |
bool artificial = member.CheckForBooleanAttribute(KXMLArtificialString); |
|
281 |
||
282 |
bool explicit_val = member.CheckForBooleanAttribute(KXMLExplicitString); |
|
283 |
||
284 |
bool inline_val = member.CheckForBooleanAttribute(KXMLInlineString); |
|
285 |
||
286 |
const XMLCh* attributeAttribute = member.GetAttribute(KXMLAttributeString); |
|
287 |
//Check for export or inline |
|
288 |
if ( ( inline_val && explicit_val && artificial ) || //the constructor is compiler generated inline function |
|
289 |
( inline_val && !artificial ) || //the constructor is explicitely declared inline function |
|
290 |
(attributeAttribute && Equals(attributeAttribute,KXMLExportedString)) //the constructor is explicitely declared exported function |
|
291 |
) |
|
292 |
{
|
|
293 |
if ( Equals(accessAttribute,KXMLProtectedString) ) |
|
294 |
{
|
|
295 |
//Is derivable class. Mark the node as one. |
|
296 |
classNode.SetAttribute(KXMLBBCProtectedConstructorString,KXML1String); |
|
297 |
} |
|
298 |
||
299 |
if ( Equals(accessAttribute,KXMLPublicString) ) |
|
300 |
{
|
|
301 |
classNode.SetAttribute(KXMLBBCPublicConstructorString,KXML1String); |
|
302 |
//Class is instantiable,too!!! |
|
303 |
} |
|
304 |
} |
|
305 |
} |
|
306 |
} else if ( Equals(member->getNodeName(),KXMLDestructorString) ) |
|
307 |
{
|
|
308 |
//Check if the destructor is private, protected or public and accessibility |
|
309 |
// if the desctructor is not accessible it is marked as private |
|
310 |
const XMLCh* accessAttribute = member.GetAttribute(KXMLAccessString); |
|
311 |
||
312 |
bool inline_val = member.CheckForBooleanAttribute(KXMLInlineString); |
|
313 |
bool virtual_val = member.CheckForBooleanAttribute(KXMLVirtualString) || |
|
314 |
member.CheckForBooleanAttribute(KXMLPureVirtualString); |
|
315 |
bool exported_val = false; |
|
316 |
const XMLCh* attributeAttribute = member.GetAttribute(KXMLAttributeString); |
|
317 |
||
318 |
if (attributeAttribute && Equals(attributeAttribute,KXMLExportedString) ) |
|
319 |
{
|
|
320 |
exported_val = true; |
|
321 |
} |
|
322 |
||
323 |
if ( !Equals(accessAttribute,KXMLPrivateString) && (inline_val || virtual_val || exported_val) ) |
|
324 |
{
|
|
325 |
||
326 |
if ( Equals(accessAttribute,KXMLPublicString) ) |
|
327 |
{
|
|
328 |
classNode.SetAttribute(KXMLBBCDestructorAccessString,KXMLBBCAccessPublicString); |
|
329 |
||
330 |
} else if ( Equals(accessAttribute,KXMLProtectedString) ) |
|
331 |
{
|
|
332 |
classNode.SetAttribute(KXMLBBCDestructorAccessString,KXMLBBCAccessProtectedString); |
|
333 |
} |
|
334 |
} |
|
335 |
else |
|
336 |
{
|
|
337 |
classNode.SetAttribute(KXMLBBCDestructorAccessString,KXMLBBCAccessPrivateString); |
|
338 |
} |
|
339 |
} |
|
340 |
||
341 |
} |
|
342 |
else |
|
343 |
{
|
|
344 |
//The tree is broken |
|
345 |
assert(false); |
|
346 |
} |
|
347 |
} |
|
348 |
//delete memberids; |
|
349 |
} |
|
350 |
} |
|
351 |
||
352 |
||
353 |
// ---------------------------------------------------------------------------- |
|
354 |
// BBCAnalyser::preAnalyseClassForInlineFunctions |
|
355 |
// |
|
356 |
// ---------------------------------------------------------------------------- |
|
357 |
// |
|
358 |
void BBCPreAnalysis::preAnalyseClassForInlineFunctions(HANodeIterator classNode) |
|
359 |
{
|
|
360 |
//Go through the methods of the class and check them for virtuality |
|
361 |
const XMLCh* attributeValue = classNode.GetAttribute(KXMLMembersString); |
|
362 |
||
363 |
if (attributeValue) |
|
364 |
{
|
|
365 |
BaseRefVectorOf< XMLCh > * memberids_ptr = XMLString::tokenizeString (attributeValue); |
|
366 |
auto_ptr<BaseRefVectorOf< XMLCh > > memberids(memberids_ptr); |
|
367 |
bool hasPublicInline = false; |
|
368 |
bool hasProtectedInline = false; |
|
369 |
||
370 |
for (unsigned int i = 0; i < memberids->size(); ++i) |
|
371 |
{
|
|
372 |
const XMLCh * memberid = memberids->elementAt(i); |
|
373 |
||
374 |
HANodeIterator member(classNode); |
|
375 |
||
376 |
if ( member.FindNodeById(memberid) ) |
|
377 |
{
|
|
378 |
//Check every inline function but do not take artificial (compiler generated) functions into account |
|
379 |
if ( member.CheckForBooleanAttribute(KXMLInlineString) && !member.CheckForBooleanAttribute(KXMLArtificialString) ) |
|
380 |
{
|
|
381 |
||
382 |
//Check if the constructor is protected or public |
|
383 |
const XMLCh* attributeValue = member.GetAttribute(KXMLAccessString); |
|
384 |
||
385 |
if ( Equals(attributeValue,KXMLProtectedString) ) |
|
386 |
{
|
|
387 |
//The class has protected inline function |
|
388 |
hasProtectedInline = true; |
|
389 |
classNode.SetAttribute(KXMLBBCProtectedInlineString,KXML1String); |
|
390 |
} |
|
391 |
||
392 |
if ( Equals(attributeValue,KXMLPublicString) ) |
|
393 |
{
|
|
394 |
//The class has public inline function |
|
395 |
hasPublicInline = true; |
|
396 |
classNode.SetAttribute(KXMLBBCPublicInlineString,KXML1String); |
|
397 |
} |
|
398 |
||
399 |
//It is enough if we have public inline, the class is fully exposed |
|
400 |
if ( hasPublicInline ) |
|
401 |
{
|
|
402 |
return; |
|
403 |
} |
|
404 |
} |
|
405 |
} |
|
406 |
else |
|
407 |
{
|
|
408 |
//The tree is broken |
|
409 |
assert(false); |
|
410 |
} |
|
411 |
} |
|
412 |
//memberids->cleanup(); |
|
413 |
//delete memberids; |
|
414 |
} |
|
415 |
||
416 |
} |
|
417 |
||
418 |
||
419 |
// ---------------------------------------------------------------------------- |
|
420 |
// BBCAnalyser::preAnalyseClass |
|
421 |
// |
|
422 |
// ---------------------------------------------------------------------------- |
|
423 |
// |
|
424 |
void BBCPreAnalysis::preAnalyseClass(HANodeIterator classNode) |
|
425 |
{
|
|
426 |
preAnalyseClassForVirtuality(classNode); |
|
427 |
preAnalyseClassForDerivability(classNode); |
|
428 |
preAnalyseClassForInlineFunctions(classNode); |
|
429 |
} |
|
430 |
||
431 |
||
432 |
// ---------------------------------------------------------------------------- |
|
433 |
// printNode |
|
434 |
// DEBUG method |
|
435 |
// |
|
436 |
// ---------------------------------------------------------------------------- |
|
437 |
// |
|
438 |
void printNode(HANodeIterator node) |
|
439 |
{
|
|
440 |
DEBUG_STUFF(const XMLCh * name = node->getNodeName();) |
|
441 |
const XMLCh * value = node->getNodeValue(); |
|
442 |
||
443 |
DEBUG_PRINT_XMLCh(name) |
|
444 |
||
445 |
if ( value ) |
|
446 |
{
|
|
447 |
DEBUG_PRINT(":")
|
|
448 |
DEBUG_PRINT_XMLCh(value) |
|
449 |
} |
|
450 |
||
451 |
DOMNamedNodeMap * atts = node->getAttributes(); |
|
452 |
if (atts) |
|
453 |
{
|
|
454 |
DEBUG_PRINT(" attributes: ")
|
|
455 |
XMLSize_t size = atts->getLength(); |
|
456 |
for (unsigned int i = 0; i < size; ++i ) |
|
457 |
{
|
|
458 |
DOMNode * att = atts->item(i); |
|
459 |
HANodeIterator cit(node); |
|
460 |
cit.current = att; |
|
461 |
printNode(cit); |
|
462 |
} |
|
463 |
} |
|
464 |
DEBUG_PRINT("\n")
|
|
465 |
} |
|
466 |
||
467 |
||
468 |
// ---------------------------------------------------------------------------- |
|
469 |
// BBCAnalyser::preAnalyseGenerateMaps |
|
470 |
// |
|
471 |
// ---------------------------------------------------------------------------- |
|
472 |
// |
|
473 |
void BBCPreAnalysis::preAnalyseGenerateMaps(HANodeIterator rootnode, bool baseline) |
|
474 |
{
|
|
475 |
//First generate the file maps |
|
476 |
short nodetype = rootnode->getNodeType(); |
|
477 |
assert(nodetype == DOMNode::ELEMENT_NODE); |
|
478 |
||
479 |
#ifndef NO_DBG |
|
480 |
DEBUG_PRINT("****************preAnalyse: Generating index*********************\n")
|
|
481 |
DEBUG_STUFF(time_t starttime = time(NULL);) |
|
482 |
#endif |
|
483 |
||
484 |
DOMDocument * doc = rootnode->getOwnerDocument(); |
|
485 |
DOMNodeIterator * domit = doc->createNodeIterator (rootnode.current,DOMNodeFilter::SHOW_ELEMENT, NULL, true); |
|
486 |
DOMNode * it = NULL; |
|
487 |
while ( NULL != (it = domit->nextNode()) ) |
|
488 |
{
|
|
489 |
HANodeIterator childit(rootnode); |
|
490 |
childit.current = it; |
|
491 |
||
492 |
#ifdef _DEBUG |
|
493 |
//printNode(childit); |
|
494 |
// Keep commented, too much stuff to print |
|
495 |
#endif |
|
496 |
if (DOMNode::ELEMENT_NODE == childit->getNodeType()) |
|
497 |
{
|
|
498 |
childit.IndexNode(); |
|
499 |
} |
|
500 |
} |
|
501 |
#ifndef NO_DBG |
|
502 |
DEBUG_PRINT("****************preAnalyse: Generating index END*********************\n")
|
|
503 |
DEBUG_STUFF(time_t endtime = time(NULL);) |
|
504 |
DEBUG_STUFF(time_t runningtime = endtime - starttime;) |
|
505 |
DEBUG_PRINT("ELAPSED TIME: ")
|
|
506 |
DEBUG_PRINT((long)runningtime) |
|
507 |
DEBUG_PRINT("\n")
|
|
508 |
||
509 |
DEBUG_PRINT("****************preAnalyse: Generating name map*********************\n")
|
|
510 |
DEBUG_STUFF(time_t starttime2 = time(NULL);) |
|
511 |
#endif |
|
512 |
||
513 |
doc = rootnode->getOwnerDocument(); |
|
514 |
domit = doc->createNodeIterator (rootnode.current,DOMNodeFilter::SHOW_ELEMENT, NULL, true); |
|
515 |
it = NULL; |
|
516 |
while ( NULL != (it = domit->nextNode()) ) |
|
517 |
{
|
|
518 |
HANodeIterator childit(rootnode); |
|
519 |
childit.current = it; |
|
520 |
||
521 |
// Add node to name map if following conditions are true: |
|
522 |
// 1. Node is proper i.e. it is in proper context and it is not artificial (compiler generated). |
|
523 |
// 2. Node is named (class, enum, function.. etc.) |
|
524 |
// 3. It is declared in the analysed header OR it is not a baseline node. |
|
525 |
// Without this rule, classes that are moved to another, not to be analysed header, |
|
526 |
// would not be properly analysed. |
|
527 |
if (IsProperNode(childit) && IsNamedNode(childit) && (childit.toBeAnalysed() || !baseline)) |
|
528 |
{
|
|
529 |
const XMLCh* nodetype = childit->getNodeName(); |
|
530 |
||
531 |
if ( Equals(nodetype,KXMLEnumerationString) ) |
|
532 |
{
|
|
533 |
//Check to see if the enumeration is anonymous |
|
534 |
if ( IsAnonymous(childit) ) |
|
535 |
{
|
|
536 |
DOMNodeList* enumchilds = childit.GetElementsByTagName(KXMLEnumValueString); |
|
537 |
XMLSize_t enumchildcount = enumchilds->getLength(); |
|
538 |
unsigned int i = 0; |
|
539 |
for (i = 0; i < enumchildcount; ++i) |
|
540 |
{
|
|
541 |
HANodeIterator enumchildit(childit); |
|
542 |
enumchildit.current = enumchilds->item(i); |
|
543 |
||
544 |
enumchildit.NameNode(!baseline); |
|
545 |
||
546 |
} |
|
547 |
||
548 |
continue;//Skip the enum naming |
|
549 |
} |
|
550 |
} |
|
551 |
||
552 |
childit.NameNode(!baseline); |
|
553 |
} |
|
554 |
} |
|
555 |
||
556 |
#ifndef NO_DBG |
|
557 |
DEBUG_PRINT("****************preAnalyse: Generating name map END*********************\n")
|
|
558 |
DEBUG_STUFF(time_t endtime2 = time(NULL);) |
|
559 |
DEBUG_STUFF(time_t runningtime2 = endtime2 - starttime2;) |
|
560 |
DEBUG_PRINT("ELAPSED TIME: ")
|
|
561 |
DEBUG_PRINT((long)runningtime2) |
|
562 |
DEBUG_PRINT("\n")
|
|
563 |
#endif |
|
564 |
} |
|
565 |
||
566 |
||
567 |
// ---------------------------------------------------------------------------- |
|
568 |
// BBCAnalyser::checkForEmptyFiles |
|
569 |
// ---------------------------------------------------------------------------- |
|
570 |
// |
|
571 |
vector<bool> BBCAnalyser::checkForEmptyFiles(HANodeIterator rootnode, const list<string>& filesToAnalyse, const list<string>& aMacroFiles) |
|
572 |
{
|
|
573 |
DOMNodeList* childs = rootnode.GetElementsByTagName(KXMLFileString); |
|
574 |
XMLSize_t childcount = childs->getLength(); |
|
575 |
||
576 |
vector<bool> filefound(filesToAnalyse.size(),false); |
|
577 |
||
578 |
for (unsigned int i = 0; i < childcount; ++i) |
|
579 |
{
|
|
580 |
DOMNode* child = childs->item(i); |
|
581 |
HANodeIterator childit(rootnode); |
|
582 |
childit.current = child; |
|
583 |
const XMLCh* filename = childit.GetAttribute(KXMLNameString); |
|
584 |
list<string>::const_iterator it = filesToAnalyse.begin(); |
|
585 |
int j = 0; |
|
586 |
for (;it != filesToAnalyse.end(); ++it) |
|
587 |
{
|
|
588 |
if ( CompareFileNames((*it),toString(filename)) ) |
|
589 |
{
|
|
590 |
filefound[j] = true; |
|
591 |
break; |
|
592 |
} |
|
593 |
++j; |
|
594 |
} |
|
595 |
} |
|
596 |
||
597 |
//validate that file is not empty |
|
598 |
//in case file only contained macros |
|
599 |
if(!aMacroFiles.empty()) |
|
600 |
{
|
|
601 |
list<string>::const_iterator start = filesToAnalyse.begin(); |
|
602 |
for(unsigned int i=0; i < filesToAnalyse.size(); i++, start++) |
|
603 |
{
|
|
604 |
if(!filefound[i]) |
|
605 |
{
|
|
606 |
list<string>::const_iterator mFiles = aMacroFiles.begin(); |
|
607 |
for(;mFiles != aMacroFiles.end();mFiles++) |
|
608 |
if( toLowerCaseWin(*start) == *mFiles ) |
|
609 |
{
|
|
610 |
filefound[i] = true; |
|
611 |
break; |
|
612 |
} |
|
613 |
} |
|
614 |
} |
|
615 |
} |
|
616 |
return filefound; |
|
617 |
} |
|
618 |
||
619 |
||
620 |
// ---------------------------------------------------------------------------- |
|
621 |
// BBCAnalyser::preAnalyse |
|
622 |
// |
|
623 |
// ---------------------------------------------------------------------------- |
|
624 |
// |
|
625 |
void BBCPreAnalysis::preAnalyse(HANodeIterator rootnode,const list<string> & filesToAnalyse, bool baseline) |
|
626 |
{
|
|
627 |
short nodetype = rootnode->getNodeType(); |
|
628 |
assert(nodetype == DOMNode::ELEMENT_NODE); |
|
629 |
||
630 |
//First generate the file maps |
|
631 |
#ifndef NO_DBG |
|
632 |
DEBUG_PRINT("****************preAnalyse: Generating file maps*********************\n")
|
|
633 |
DEBUG_STUFF(time_t starttime = time(NULL);) |
|
634 |
#endif |
|
635 |
||
636 |
DOMNodeList* childs = rootnode.GetElementsByTagName(KXMLFileString); |
|
637 |
XMLSize_t childcount = childs->getLength(); |
|
638 |
#ifndef NO_DBG |
|
639 |
DEBUG_PRINT("preAnalyseGenerateMaps: Files to analyse: ")
|
|
640 |
DEBUG_PRINT(childcount) |
|
641 |
DEBUG_PRINT("\n")
|
|
642 |
#endif |
|
643 |
||
644 |
unsigned int i = 0; |
|
645 |
for (i = 0; i < childcount; ++i) |
|
646 |
{
|
|
647 |
DOMNode* child = childs->item(i); |
|
648 |
HANodeIterator childit(rootnode); |
|
649 |
childit.current = child; |
|
650 |
bool filetoanalyse = false; |
|
651 |
const XMLCh* filename = childit.GetAttribute(KXMLNameString); |
|
652 |
list<string>::const_iterator it = filesToAnalyse.begin(); |
|
653 |
int i = 0; |
|
654 |
for (;it != filesToAnalyse.end(); ++it) |
|
655 |
{
|
|
656 |
if ( CompareFileNames((*it),toString(filename)) ) |
|
657 |
{
|
|
658 |
filetoanalyse = true; |
|
659 |
break; |
|
660 |
} |
|
661 |
++i; |
|
662 |
} |
|
663 |
childit.IndexFileNode(filetoanalyse); |
|
664 |
} |
|
665 |
#ifndef NO_DBG |
|
666 |
DEBUG_PRINT("****************preAnalyse: Generating file maps END*********************\n")
|
|
667 |
DEBUG_STUFF(time_t endtime = time(NULL);) |
|
668 |
DEBUG_STUFF(time_t runningtime = endtime - starttime;) |
|
669 |
DEBUG_PRINT("ELAPSED TIME: ")
|
|
670 |
DEBUG_PRINT((long)runningtime) |
|
671 |
DEBUG_PRINT("\n")
|
|
672 |
#endif |
|
673 |
||
674 |
preAnalyseGenerateMaps(rootnode,baseline); |
|
675 |
||
676 |
//rootnode.iNodeIndex.DumpTables(); |
|
677 |
||
678 |
#ifndef NO_DBG |
|
679 |
DEBUG_PRINT("****************preAnalyse: Preanalysing classes*********************\n")
|
|
680 |
DEBUG_STUFF(time_t starttime2 = time(NULL);) |
|
681 |
DEBUG_PRINT("preAnalyse: Nodes to analyse: ")
|
|
682 |
DEBUG_PRINT(childcount) |
|
683 |
DEBUG_PRINT("\n")
|
|
684 |
#endif |
|
685 |
||
686 |
DOMDocument * doc = rootnode->getOwnerDocument(); |
|
687 |
DOMNodeIterator * domit = doc->createNodeIterator (rootnode.current,DOMNodeFilter::SHOW_ELEMENT, NULL, true); |
|
688 |
DOMNode * it = NULL; |
|
689 |
while ( NULL != (it = domit->nextNode()) ) |
|
690 |
{
|
|
691 |
HANodeIterator childit(rootnode); |
|
692 |
childit.current = it; |
|
693 |
#ifdef _DEBUG |
|
694 |
// printNode(childit); |
|
695 |
// Keep commented, too much stuff to print |
|
696 |
#endif |
|
697 |
const XMLCh * nodename = childit->getNodeName(); |
|
698 |
if ( DOMNode::ELEMENT_NODE == childit->getNodeType() && childit.toBeAnalysed() && |
|
699 |
( Equals(nodename,KXMLClassString) || Equals(nodename,KXMLStructString) |
|
700 |
|| Equals(nodename,KXMLUnionString)) |
|
701 |
) |
|
702 |
{
|
|
703 |
preAnalyseClass(childit); |
|
704 |
} |
|
705 |
} |
|
706 |
||
707 |
#ifndef NO_DBG |
|
708 |
DEBUG_PRINT("****************preAnalyse: Preanalysing classes END*********************\n")
|
|
709 |
DEBUG_STUFF(time_t endtime2 = time(NULL);) |
|
710 |
DEBUG_STUFF(time_t runningtime2 = endtime2 - starttime2;) |
|
711 |
DEBUG_PRINT("ELAPSED TIME: ")
|
|
712 |
DEBUG_PRINT((long)runningtime2) |
|
713 |
DEBUG_PRINT("\n")
|
|
714 |
#endif |
|
715 |
} |
|
716 |
||
717 |
// ---------------------------------------------------------------------------- |
|
718 |
// BBCAnalyser::nodeAnalyseTrees |
|
719 |
// ---------------------------------------------------------------------------- |
|
720 |
// |
|
721 |
int BBCAnalyser::nodeAnalyseTrees(HANodeIterator baseline, HANodeIterator current,const list< pair<string,string> >& filesToAnalyse) |
|
722 |
{
|
|
723 |
//Find out the files to be processed |
|
724 |
short nodetype = baseline->getNodeType(); |
|
725 |
assert(nodetype == DOMNode::ELEMENT_NODE); |
|
726 |
nodetype = current->getNodeType(); |
|
727 |
assert(nodetype == DOMNode::ELEMENT_NODE); |
|
728 |
||
729 |
int ret = 0; |
|
730 |
||
731 |
DOMDocument * doc = baseline->getOwnerDocument(); |
|
732 |
DOMNodeIterator * domit = doc->createNodeIterator (baseline.current,DOMNodeFilter::SHOW_ELEMENT, NULL, true); |
|
733 |
DOMNode * it = NULL; |
|
734 |
||
735 |
while ( NULL != (it = domit->nextNode()) ) |
|
736 |
{
|
|
737 |
HANodeIterator childit(baseline); |
|
738 |
childit.current = it; |
|
739 |
||
740 |
if (IsNamedNode(childit) && IsProperNode(childit) && childit.toBeAnalysed()) |
|
741 |
{
|
|
742 |
if ( !CheckAccessibility(childit) ) |
|
743 |
{
|
|
744 |
//The node is not visible, so no need to analyse |
|
745 |
continue; |
|
746 |
} |
|
747 |
HANodeIterator currentit(current); |
|
748 |
||
749 |
const XMLCh* name = childit.GetAttribute(KXMLNameString); |
|
750 |
if ( StartsWith(name,KXMLInternalNamePrefix) ) |
|
751 |
{
|
|
752 |
//Skip compiler generated pseudo elements |
|
753 |
continue; |
|
754 |
} |
|
755 |
||
756 |
const XMLCh* id = childit.GetAttribute(KXMLIdString); |
|
757 |
DEBUG_PRINT("Analysing:")
|
|
758 |
if ( name ) |
|
759 |
{
|
|
760 |
DEBUG_PRINT_XMLCh(name) |
|
761 |
} |
|
762 |
if ( id ) |
|
763 |
{
|
|
764 |
DEBUG_PRINT(":")
|
|
765 |
DEBUG_PRINT_XMLCh(id) |
|
766 |
} |
|
767 |
DEBUG_PRINT("\n")
|
|
768 |
||
769 |
||
770 |
NodeAnalysis::Constructor constructorfunction = FindNodeAnalysisConstructor(childit->getNodeName()); |
|
771 |
NodeAnalysis * analyser = constructorfunction(); |
|
772 |
||
773 |
ret += analyser->FindNodeAndAnalyse(childit,currentit); |
|
774 |
delete analyser; |
|
775 |
} |
|
776 |
} |
|
777 |
||
778 |
return ret; |
|
779 |
} |
|
780 |
||
781 |
// ---------------------------------------------------------------------------- |
|
782 |
// BBCAnalyser::analyseTrees |
|
783 |
// ---------------------------------------------------------------------------- |
|
784 |
// |
|
785 |
int BBCAnalyser::analyseTrees(DOMNode* baseline, DOMNode* current,const list< pair<string,string> >& filesToAnalyse, const list<string>& aMacroFiles) |
|
786 |
{
|
|
787 |
#ifndef NO_DBG |
|
788 |
DEBUG_PRINT("****************Analyse: ANALYSE starts*********************\n")
|
|
789 |
DEBUG_STUFF(time_t starttime = time(NULL);) |
|
790 |
#endif |
|
791 |
||
792 |
iBaselineIndex.clear(); |
|
793 |
iCurrentIndex.clear(); |
|
794 |
||
795 |
HANodeIterator baselineit(baseline,iBaselineIndex,iReport, filesToAnalyse, true ); |
|
796 |
HANodeIterator currentit(current,iCurrentIndex,iReport, filesToAnalyse, false); |
|
797 |
||
798 |
list<string> basefiles, currentfiles; |
|
799 |
list< pair<string,string> >::const_iterator it = filesToAnalyse.begin(); |
|
800 |
||
801 |
for (; it != filesToAnalyse.end(); ++it) |
|
802 |
{
|
|
803 |
basefiles.push_back((*it).first); |
|
804 |
currentfiles.push_back((*it).second); |
|
805 |
} |
|
806 |
||
807 |
preAnalysis.preAnalyse(baselineit,basefiles,true); |
|
808 |
preAnalysis.preAnalyse(currentit,currentfiles,false); |
|
809 |
||
810 |
vector<bool> bfilefound; |
|
811 |
bfilefound = checkForEmptyFiles(baselineit,basefiles,aMacroFiles); |
|
812 |
||
813 |
vector<bool> cfilefound; |
|
814 |
cfilefound = checkForEmptyFiles(currentit,currentfiles,aMacroFiles); |
|
815 |
||
816 |
list<pair<string,string> >::const_iterator fileit = filesToAnalyse.begin(); |
|
817 |
size_t i = 0; |
|
818 |
||
819 |
for (i=0;i < bfilefound.size(); ++i,++fileit) |
|
820 |
{
|
|
821 |
if ( !cfilefound[i] && !bfilefound[i] ) |
|
822 |
{
|
|
823 |
// Serious problem, the analysed file is not in the GCCXML output |
|
824 |
iReport.addIssue(fileit->first,"", EIssueIdentityFile, EIssueTypeEmpty, |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
825 |
BCseverityAccessible<EIssueIdentityFile,EIssueTypeEmpty>(true), SCseverityAccessible<EIssueIdentityFile,EIssueTypeEmpty>(true), "", 0, "",fileit->second, ""); |
| 0 | 826 |
} |
827 |
else if ( !bfilefound[i] ) |
|
828 |
{
|
|
829 |
// Serious problem, the analysed file is not in the GCCXML output |
|
830 |
iReport.addIssue(fileit->first,"", EIssueIdentityFile, EIssueTypeEmpty, |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
831 |
BCseverityAccessible<EIssueIdentityFile,EIssueTypeEmpty>(true), SCseverityAccessible<EIssueIdentityFile,EIssueTypeEmpty>(true), "", 0, "",fileit->second, ""); |
| 0 | 832 |
} |
833 |
else if ( !cfilefound[i]) |
|
834 |
{
|
|
835 |
// Serious problem, the analysed file is not in the GCCXML output |
|
836 |
iReport.addIssue(fileit->first,"", EIssueIdentityFile, EIssueTypeEmpty, |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
837 |
BCseverityAccessible<EIssueIdentityFile,EIssueTypeEmpty>(true), SCseverityAccessible<EIssueIdentityFile,EIssueTypeEmpty>(true), "", 0, "",fileit->second, ""); |
| 0 | 838 |
} |
839 |
} |
|
840 |
||
841 |
//baselineit.iNodeIndex.DumpTables(); |
|
842 |
//currentit.iNodeIndex.DumpTables(); |
|
843 |
||
844 |
#ifndef NO_DBG |
|
845 |
DEBUG_PRINT("****************nodeAnalyse: Analysing*********************\n")
|
|
846 |
DEBUG_STUFF(time_t starttime2 = time(NULL);) |
|
847 |
#endif |
|
848 |
||
849 |
int ret = nodeAnalyseTrees(baselineit, currentit, filesToAnalyse); |
|
850 |
#ifndef NO_DBG |
|
851 |
DEBUG_STUFF(time_t endtime2 = time(NULL);) |
|
852 |
DEBUG_STUFF(time_t runningtime2 = endtime2- starttime2;) |
|
853 |
DEBUG_PRINT("****************nodeAnalyse: Analysing END*********************\n")
|
|
854 |
DEBUG_PRINT("ELAPSED TIME: ")
|
|
855 |
DEBUG_PRINT((long)runningtime2) |
|
856 |
DEBUG_PRINT("\n")
|
|
857 |
||
858 |
DEBUG_PRINT("****************Analyse: ANALYSE END*********************\n")
|
|
859 |
DEBUG_STUFF(time_t endtime = time(NULL);) |
|
860 |
DEBUG_STUFF(time_t runningtime = endtime - starttime;) |
|
861 |
DEBUG_PRINT("ELAPSED TIME: ")
|
|
862 |
DEBUG_PRINT((long)runningtime) |
|
863 |
DEBUG_PRINT("\n")
|
|
864 |
#endif |
|
865 |
||
866 |
return ret; |
|
867 |
} |
|
868 |
||
869 |
||
870 |
// ---------------------------------------------------------------------------- |
|
871 |
// BBCAnalyser::BBCAnalyser |
|
872 |
// ---------------------------------------------------------------------------- |
|
873 |
// |
|
874 |
BBCAnalyser::BBCAnalyser(ReportGenerator & report): |
|
875 |
iReport(report) |
|
876 |
{
|
|
877 |
} |
|
878 |
||
879 |
||
880 |
// ---------------------------------------------------------------------------- |
|
881 |
// NodeAnalysis::findNode |
|
882 |
// |
|
883 |
// ---------------------------------------------------------------------------- |
|
884 |
// |
|
885 |
DOMNode* NodeAnalysis::findNode(HANodeIterator nodetofind, HANodeIterator findfrom ) |
|
886 |
{
|
|
887 |
DOMNode * ret = NULL; |
|
888 |
||
889 |
pair<const XMLCh*,const XMLCh*> fqname = nodetofind.GetFullyQualifiedName(); |
|
890 |
#ifndef NO_DBG |
|
891 |
DEBUG_PRINT("Finding node from current three with fqname: ")
|
|
892 |
DEBUG_PRINT_XMLCh(fqname.first) |
|
893 |
DEBUG_PRINT(" ... ")
|
|
894 |
#endif |
|
895 |
||
896 |
if ( findfrom.FindNodeByName(fqname) ) |
|
897 |
{
|
|
898 |
ret = findfrom.current; |
|
899 |
} |
|
900 |
return ret; |
|
901 |
} |
|
902 |
||
903 |
///////////////////////////////UnderConstructionNodeAnalysis//////////////////////////// |
|
904 |
||
905 |
// ---------------------------------------------------------------------------- |
|
906 |
// UnderConstructionNodeAnalysis::Construct |
|
907 |
// |
|
908 |
// ---------------------------------------------------------------------------- |
|
909 |
// |
|
910 |
NodeAnalysis* UnderConstructionNodeAnalysis::Construct() |
|
911 |
{
|
|
912 |
return new UnderConstructionNodeAnalysis(); |
|
913 |
} |
|
914 |
||
915 |
||
916 |
// ---------------------------------------------------------------------------- |
|
917 |
// UnderConstructionNodeAnalysis::Analyse |
|
918 |
// |
|
919 |
// ---------------------------------------------------------------------------- |
|
920 |
// |
|
921 |
int UnderConstructionNodeAnalysis::Analyse(HANodeIterator baseline,HANodeIterator current, bool report) |
|
922 |
{
|
|
923 |
assert( |
|
924 |
Equals(baseline->getNodeName(), current->getNodeName()) |
|
925 |
); |
|
926 |
||
927 |
if (report) |
|
928 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
929 |
AddIssue<EIssueIdentityFile, EIssueTypeUnderConstruction>(&baseline, baseline,0,""); |
| 0 | 930 |
} |
931 |
return 1; |
|
932 |
} |
|
933 |
||
934 |
||
935 |
// ---------------------------------------------------------------------------- |
|
936 |
// UnderConstructionNodeAnalysis::FindNodeAndAnalyse |
|
937 |
// |
|
938 |
// ---------------------------------------------------------------------------- |
|
939 |
// |
|
940 |
int UnderConstructionNodeAnalysis::FindNodeAndAnalyse(HANodeIterator baseline,HANodeIterator current) |
|
941 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
942 |
AddIssue<EIssueIdentityFile,EIssueTypeUnderConstruction>(&baseline,baseline,0,""); |
| 0 | 943 |
return 1; |
944 |
} |
|
945 |
//////////////////////////////////////////////////////////////////////////////////////// |
|
946 |
///////////////////////////////VariableNodeAnalysis///////////////////////////////////// |
|
947 |
||
948 |
||
949 |
// ---------------------------------------------------------------------------- |
|
950 |
// VariableNodeAnalysis::Construct |
|
951 |
// ---------------------------------------------------------------------------- |
|
952 |
// |
|
953 |
NodeAnalysis* VariableNodeAnalysis::Construct() |
|
954 |
{
|
|
955 |
return new VariableNodeAnalysis(); |
|
956 |
} |
|
957 |
||
958 |
// ---------------------------------------------------------------------------- |
|
959 |
// VariableNodeAnalysis::FindNodeAndAnalyse |
|
960 |
// ---------------------------------------------------------------------------- |
|
961 |
// |
|
962 |
int VariableNodeAnalysis::FindNodeAndAnalyse(HANodeIterator baseline,HANodeIterator current) |
|
963 |
{
|
|
964 |
DOMNode* node = NodeAnalysis::findNode(baseline,current); |
|
965 |
if ( !node ) |
|
966 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
967 |
AddIssue<EIssueIdentityVariable, EIssueTypeRemoval>(&baseline, baseline,0,""); |
| 0 | 968 |
return 1; |
969 |
} |
|
970 |
current.current = node; |
|
971 |
||
972 |
return this->Analyse(baseline,current); |
|
973 |
} |
|
974 |
||
975 |
||
976 |
// ---------------------------------------------------------------------------- |
|
977 |
// VariableNodeAnalysis::Analyse |
|
978 |
// ---------------------------------------------------------------------------- |
|
979 |
// |
|
980 |
int VariableNodeAnalysis::Analyse(HANodeIterator baseline,HANodeIterator current, bool report) |
|
981 |
{
|
|
982 |
assert( Equals(KXMLVariableString, baseline->getNodeName()) && |
|
983 |
Equals(KXMLVariableString, current->getNodeName()) && |
|
984 |
Equals(baseline->getNodeName(), current->getNodeName()) |
|
985 |
); |
|
986 |
||
987 |
int ret = 0; |
|
988 |
||
989 |
int lineNo = 0; |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
990 |
string issueLoc; |
| 0 | 991 |
const XMLCh* lineNumber = current.GetAttribute(KXMLLineString); |
992 |
lineNo = atoi(toString(lineNumber).c_str()); |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
993 |
const XMLCh* fnameNode= current.GetAttribute(KXMLFileIdString); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
994 |
if( fnameNode!= NULL) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
995 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
996 |
HANodeIterator fileNode(current); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
997 |
bool ret1 = fileNode.FindNodeById(fnameNode); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
998 |
issueLoc = toString(fileNode.GetAttribute(KXMLNameString)); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
999 |
} |
| 0 | 1000 |
|
1001 |
if ( IsAnonymousType(baseline) ) |
|
1002 |
{
|
|
1003 |
//We need to to comparison between the baseline type and current type anonymously |
|
1004 |
||
1005 |
HANodeIterator baselinetypeit(baseline); |
|
1006 |
HANodeIterator currenttypeit(current); |
|
1007 |
||
1008 |
const XMLCh* baselinetypeid = baseline.GetAttribute(KXMLTypeString); |
|
1009 |
const XMLCh* currenttypeid = current.GetAttribute(KXMLTypeString); |
|
1010 |
||
1011 |
assert( baselinetypeid && currenttypeid); |
|
1012 |
||
1013 |
bool ret1 = baselinetypeit.FindNodeById(baselinetypeid); |
|
1014 |
bool ret2 = currenttypeit.FindNodeById(currenttypeid); |
|
1015 |
||
1016 |
assert(ret1 && ret2); |
|
1017 |
||
1018 |
HANodeIterator baselinetypeanonit(baselinetypeit); |
|
1019 |
HANodeIterator currenttypeanonit(currenttypeit); |
|
1020 |
ret1 = FindAnonymousType(baselinetypeit,baselinetypeanonit); |
|
1021 |
ret2 = FindAnonymousType(currenttypeit,currenttypeanonit); |
|
1022 |
||
1023 |
assert(ret1); |
|
1024 |
||
1025 |
if ( !ret2 || !baselinetypeanonit.IsSameNodeType(currenttypeanonit) ) |
|
1026 |
{
|
|
1027 |
if (report) |
|
1028 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1029 |
AddIssue<EIssueIdentityVariable, EIssueTypeChangeInType>(&baseline, current,lineNo,issueLoc); |
| 0 | 1030 |
} |
1031 |
++ret; |
|
1032 |
} |
|
1033 |
else |
|
1034 |
{
|
|
1035 |
||
1036 |
NodeAnalysis::Constructor constructorfunction = FindNodeAnalysisConstructor(baselinetypeanonit->getNodeName()); |
|
1037 |
NodeAnalysis * analyser = constructorfunction(); |
|
1038 |
int ret = analyser->Analyse(baselinetypeanonit,currenttypeanonit,false); |
|
1039 |
if ( ret > 0 ) |
|
1040 |
{
|
|
1041 |
if (report) |
|
1042 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1043 |
AddIssue<EIssueIdentityVariable, EIssueTypeChangeInType>(&baseline, current,lineNo,issueLoc); |
| 0 | 1044 |
} |
1045 |
++ret; |
|
1046 |
} |
|
1047 |
delete analyser; |
|
1048 |
} |
|
1049 |
} |
|
1050 |
else |
|
1051 |
{
|
|
1052 |
//{KXMLTypeString,EIdAttribute}
|
|
1053 |
if ( !CompareAttributes(baseline,current,KXMLTypeString,ETypeAttribute) ) |
|
1054 |
{
|
|
1055 |
if (report) |
|
1056 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1057 |
AddIssue<EIssueIdentityVariable, EIssueTypeChangeInType>(&baseline, current,lineNo,issueLoc); |
| 0 | 1058 |
} |
1059 |
++ret; |
|
1060 |
} |
|
1061 |
} |
|
1062 |
||
1063 |
//{KXMLInitString,EOptionalSimpleAttribute}
|
|
1064 |
if ( !CompareAttributes(baseline,current,KXMLInitString,EOptionalSimpleAttribute) ) |
|
1065 |
{
|
|
1066 |
if (report) |
|
1067 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1068 |
AddIssue<EIssueIdentityVariable, EIssueTypeChangeInInitialisation>(&baseline, current,lineNo,issueLoc); |
| 0 | 1069 |
} |
1070 |
++ret; |
|
1071 |
} |
|
1072 |
||
1073 |
if (!CheckAccessModifier(baseline,current)) |
|
1074 |
{
|
|
1075 |
if (report) |
|
1076 |
{
|
|
1077 |
//AddIssue<iIdentity,EIssueTypeAccess>(&baseline, current); |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1078 |
AddIssue<EIssueIdentityVariable,EIssueTypeAccess>(&baseline, current,lineNo,issueLoc); |
| 0 | 1079 |
} |
1080 |
ret += 1; |
|
1081 |
} |
|
1082 |
||
1083 |
return ret; |
|
1084 |
} |
|
1085 |
||
1086 |
//////////////////////////////////////////////////////////////////////////////////////// |
|
1087 |
///////////////////////////////EnumNodeAnalysis///////////////////////////////////////// |
|
1088 |
||
1089 |
// ---------------------------------------------------------------------------- |
|
1090 |
// EnumNodeAnalysis::Construct |
|
1091 |
// |
|
1092 |
// ---------------------------------------------------------------------------- |
|
1093 |
// |
|
1094 |
NodeAnalysis* EnumNodeAnalysis::Construct() |
|
1095 |
{
|
|
1096 |
return new EnumNodeAnalysis; |
|
1097 |
} |
|
1098 |
||
1099 |
// ---------------------------------------------------------------------------- |
|
1100 |
// EnumNodeAnalysis::FindNodeAndAnalyse |
|
1101 |
// |
|
1102 |
// ---------------------------------------------------------------------------- |
|
1103 |
// |
|
1104 |
int EnumNodeAnalysis::FindNodeAndAnalyse(HANodeIterator baseline,HANodeIterator current) |
|
1105 |
{
|
|
1106 |
int ret = 0; |
|
1107 |
if ( IsAnonymous(baseline) ) |
|
1108 |
{
|
|
1109 |
DOMNodeList* enumchilds = baseline.GetElementsByTagName(KXMLEnumValueString); |
|
1110 |
XMLSize_t enumchildcount = enumchilds->getLength(); |
|
1111 |
unsigned int i = 0; |
|
1112 |
for (i = 0; i < enumchildcount; ++i) |
|
1113 |
{
|
|
1114 |
int lineNo = 0; |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1115 |
string issueLoc; |
| 0 | 1116 |
HANodeIterator enumchildit(baseline); |
1117 |
enumchildit.current = enumchilds->item(i); |
|
1118 |
||
1119 |
DOMNode* node = NodeAnalysis::findNode(enumchildit,current); |
|
1120 |
if ( !node ) |
|
1121 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1122 |
AddIssue<EIssueIdentityEnumerationValue,EIssueTypeRemoval>(&enumchildit, enumchildit, 0, "", baseline.GetAttribute(KXMLFileIdString)); |
| 0 | 1123 |
++ret; |
1124 |
continue; |
|
1125 |
} |
|
1126 |
current.current = node; |
|
1127 |
DOMNode* parentnode = node->getParentNode(); |
|
1128 |
const XMLCh* lineNumber = GetAttribute(parentnode,KXMLLineString); |
|
1129 |
lineNo = atoi(toString(lineNumber).c_str()); |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1130 |
const XMLCh* fnameNode= current.GetAttribute(KXMLFileIdString); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1131 |
if( fnameNode!= NULL) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1132 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1133 |
HANodeIterator fileNode(current); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1134 |
bool ret1 = fileNode.FindNodeById(fnameNode); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1135 |
issueLoc = toString(fileNode.GetAttribute(KXMLNameString)); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1136 |
} |
| 0 | 1137 |
|
1138 |
if ( !CheckEnumValue(enumchildit,current) ) |
|
1139 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1140 |
AddIssue<EIssueIdentityEnumerationValue,EIssueTypeChangeInInitialisation>(&enumchildit, current, lineNo, issueLoc,baseline.GetAttribute(KXMLFileIdString)); |
| 0 | 1141 |
++ret; |
1142 |
} |
|
1143 |
HANodeIterator currentparent(current); |
|
1144 |
if ( FindParentContext(current, currentparent)) |
|
1145 |
{
|
|
1146 |
if ( !CheckAccessModifier(baseline,currentparent) ) |
|
1147 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1148 |
AddIssue<EIssueIdentityEnumerationValue,EIssueTypeAccess>(&enumchildit, current, lineNo, issueLoc, baseline.GetAttribute(KXMLFileIdString)); |
| 0 | 1149 |
++ret; |
1150 |
} |
|
1151 |
} |
|
1152 |
} |
|
1153 |
} |
|
1154 |
else |
|
1155 |
{
|
|
1156 |
||
1157 |
DOMNode* node = NodeAnalysis::findNode(baseline,current); |
|
1158 |
if ( !node ) |
|
1159 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1160 |
AddIssue<EIssueIdentityEnumeration,EIssueTypeRemoval>(&baseline, baseline,0,""); |
| 0 | 1161 |
return 1; |
1162 |
} |
|
1163 |
current.current = node; |
|
1164 |
||
1165 |
ret += this->Analyse(baseline,current); |
|
1166 |
} |
|
1167 |
return ret; |
|
1168 |
} |
|
1169 |
||
1170 |
||
1171 |
// ---------------------------------------------------------------------------- |
|
1172 |
// EnumNodeAnalysis::CheckEnumValue |
|
1173 |
// |
|
1174 |
// ---------------------------------------------------------------------------- |
|
1175 |
// |
|
1176 |
bool EnumNodeAnalysis::CheckEnumValue(HANodeIterator baseline,HANodeIterator current) |
|
1177 |
{
|
|
1178 |
||
1179 |
return CompareNodes(baseline,current); |
|
1180 |
} |
|
1181 |
||
1182 |
// ---------------------------------------------------------------------------- |
|
1183 |
// EnumNodeAnalysis::Analyse |
|
1184 |
// |
|
1185 |
// ---------------------------------------------------------------------------- |
|
1186 |
// |
|
1187 |
int EnumNodeAnalysis::Analyse(HANodeIterator baseline,HANodeIterator current, bool report) |
|
1188 |
{
|
|
1189 |
assert( Equals(KXMLEnumerationString, baseline->getNodeName()) && |
|
1190 |
Equals(KXMLEnumerationString, current->getNodeName()) && |
|
1191 |
Equals(baseline->getNodeName(), current->getNodeName()) |
|
1192 |
); |
|
1193 |
||
1194 |
||
1195 |
int ret = 0; |
|
1196 |
int lineNo = 0; |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1197 |
string issueLoc; |
| 0 | 1198 |
const XMLCh* lineNumber = current.GetAttribute(KXMLLineString); |
1199 |
lineNo = atoi(toString(lineNumber).c_str()); |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1200 |
const XMLCh* fnameNode = current.GetAttribute(KXMLFileIdString); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1201 |
if( fnameNode!= NULL) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1202 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1203 |
HANodeIterator fileNode(current); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1204 |
bool ret1 = fileNode.FindNodeById(fnameNode); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1205 |
issueLoc = toString(fileNode.GetAttribute(KXMLNameString)); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1206 |
} |
| 0 | 1207 |
|
1208 |
//{KXMLAlignString,ESimpleAttribute}
|
|
1209 |
if ( !CompareAttributes(baseline,current,KXMLAlignString,ESimpleAttribute) ) |
|
1210 |
{
|
|
1211 |
if (report) |
|
1212 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1213 |
AddIssue<EIssueIdentityEnumeration,EIssueTypeAlign>(&baseline, current,lineNo,issueLoc); |
| 0 | 1214 |
} |
1215 |
++ret; |
|
1216 |
} |
|
1217 |
||
1218 |
//{KXMLSizeString,ESimpleAttribute}
|
|
1219 |
if ( !CompareAttributes(baseline,current,KXMLSizeString,ESimpleAttribute) ) |
|
1220 |
{
|
|
1221 |
if (report) |
|
1222 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1223 |
AddIssue<EIssueIdentityEnumeration,EIssueTypeSize>(&baseline, current,lineNo,issueLoc); |
| 0 | 1224 |
} |
1225 |
++ret; |
|
1226 |
} |
|
1227 |
||
1228 |
if (!CheckAccessModifier(baseline,current)) |
|
1229 |
{
|
|
1230 |
if (report) |
|
1231 |
{
|
|
1232 |
//AddIssue<iIdentity,EIssueTypeAccess>(&baseline, current); |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1233 |
AddIssue<EIssueIdentityEnumeration, EIssueTypeAccess>(&baseline, current,lineNo,issueLoc); |
| 0 | 1234 |
} |
1235 |
++ret; |
|
1236 |
} |
|
1237 |
||
1238 |
//Check the enum values |
|
1239 |
DOMNodeList* baselinechilds = baseline.GetElementsByTagName(KXMLEnumValueString); |
|
1240 |
DOMNodeList* currentchilds = current.GetElementsByTagName(KXMLEnumValueString); |
|
1241 |
||
1242 |
XMLSize_t baselinechildcount = baselinechilds->getLength(); |
|
1243 |
XMLSize_t currentchildcount = currentchilds->getLength(); |
|
1244 |
||
1245 |
unsigned int i = 0; |
|
1246 |
for (i = 0; i < baselinechildcount; ++i) |
|
1247 |
{
|
|
1248 |
HANodeIterator baselineit(baseline); |
|
1249 |
baselineit.current = baselinechilds->item(i); |
|
1250 |
unsigned int ii = 0; |
|
1251 |
for (ii = 0; ii < currentchildcount; ++ii) |
|
1252 |
{
|
|
1253 |
HANodeIterator currentit(current); |
|
1254 |
currentit.current = currentchilds->item(ii); |
|
1255 |
||
1256 |
if ( CompareAttributes(baselineit,currentit,KXMLNameString,ESimpleAttribute) ) |
|
1257 |
{
|
|
1258 |
if ( !CompareAttributes(baselineit,currentit,KXMLInitString,ESimpleAttribute) ) |
|
1259 |
{
|
|
1260 |
if (report) |
|
1261 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1262 |
AddIssue<EIssueIdentityEnumeration,EIssueTypeChange>(&baseline, current,lineNo,issueLoc); |
| 0 | 1263 |
} |
1264 |
++ret; |
|
1265 |
return ret; |
|
1266 |
} |
|
1267 |
break; |
|
1268 |
} |
|
1269 |
||
1270 |
} |
|
1271 |
||
1272 |
if ( currentchildcount == ii ) |
|
1273 |
{
|
|
1274 |
||
1275 |
if (report) |
|
1276 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1277 |
AddIssue<EIssueIdentityEnumerationValue,EIssueTypeRemoval>(&baseline, current,lineNo,issueLoc); |
| 0 | 1278 |
} |
1279 |
++ret; |
|
1280 |
return ret; |
|
1281 |
} |
|
1282 |
} |
|
1283 |
||
1284 |
return ret; |
|
1285 |
} |
|
1286 |
||
1287 |
//////////////////////////////////////////////////////////////////////////////////////// |
|
1288 |
///////////////////////////////FunctionNodeAnalysis///////////////////////////////////// |
|
1289 |
||
1290 |
||
1291 |
// ---------------------------------------------------------------------------- |
|
1292 |
// FunctionNodeAnalysis::FunctionNodeAnalysis |
|
1293 |
// |
|
1294 |
// ---------------------------------------------------------------------------- |
|
1295 |
// |
|
1296 |
FunctionNodeAnalysis::FunctionNodeAnalysis(): |
|
1297 |
iFuncType(EIssueIdentityExportedFunction) |
|
1298 |
{
|
|
1299 |
} |
|
1300 |
||
1301 |
// ---------------------------------------------------------------------------- |
|
1302 |
// FunctionNodeAnalysis::Construct |
|
1303 |
// |
|
1304 |
// ---------------------------------------------------------------------------- |
|
1305 |
// |
|
1306 |
NodeAnalysis* FunctionNodeAnalysis::Construct() |
|
1307 |
{
|
|
1308 |
return new FunctionNodeAnalysis; |
|
1309 |
} |
|
1310 |
||
1311 |
// ---------------------------------------------------------------------------- |
|
1312 |
// FunctionNodeAnalysis::FindNodeAndAnalyse |
|
1313 |
// |
|
1314 |
// ---------------------------------------------------------------------------- |
|
1315 |
// |
|
1316 |
int FunctionNodeAnalysis::FindNodeAndAnalyse(HANodeIterator baseline,HANodeIterator current) |
|
1317 |
{
|
|
1318 |
if ( baseline.CheckForBooleanAttribute(KXMLInlineString) ) |
|
1319 |
{
|
|
1320 |
iFuncType = EIssueIdentityInlineFunction; |
|
1321 |
} |
|
1322 |
||
1323 |
//Check first if the function is exported |
|
1324 |
const XMLCh* attributeValue = baseline.GetAttribute(KXMLAttributeString); |
|
1325 |
||
1326 |
if ( (iFuncType == EIssueIdentityInlineFunction) || (attributeValue && Equals(attributeValue,KXMLExportedString)) ) |
|
1327 |
{
|
|
1328 |
DOMNode* node = NodeAnalysis::findNode(baseline,current); |
|
1329 |
if ( !node ) |
|
1330 |
{
|
|
1331 |
//AddIssue<iFuncType,EIssueTypeRemoval>(&baseline, baseline); |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1332 |
AddIssueFunction<EIssueTypeRemoval>(&baseline,iFuncType,baseline,0,""); |
| 0 | 1333 |
return 1; |
1334 |
} |
|
1335 |
current.current = node; |
|
1336 |
||
1337 |
return this->Analyse(baseline,current); |
|
1338 |
} |
|
1339 |
||
1340 |
return 0; |
|
1341 |
} |
|
1342 |
||
1343 |
// ---------------------------------------------------------------------------- |
|
1344 |
// FunctionNodeAnalysis::Analyse |
|
1345 |
// |
|
1346 |
// ---------------------------------------------------------------------------- |
|
1347 |
// |
|
1348 |
int FunctionNodeAnalysis::Analyse(HANodeIterator baseline,HANodeIterator current, bool report) |
|
1349 |
{
|
|
1350 |
assert( |
|
1351 |
Equals(baseline->getNodeName(), current->getNodeName()) |
|
1352 |
); |
|
1353 |
||
1354 |
int ret = 0; |
|
1355 |
//<!ELEMENT FunctionType (Argument | Ellipsis)*> |
|
1356 |
//<!ATTLIST FunctionType attributes CDATA #IMPLIED> |
|
1357 |
//<!ATTLIST FunctionType id ID #REQUIRED> |
|
1358 |
//<!ATTLIST FunctionType returns IDREF #REQUIRED> |
|
1359 |
||
1360 |
int lineNo = 0; |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1361 |
string issueLoc; |
| 0 | 1362 |
const XMLCh* lineNumber = current.GetAttribute(KXMLLineString); |
1363 |
lineNo = atoi(toString(lineNumber).c_str()); |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1364 |
const XMLCh* fnameNode = current.GetAttribute(KXMLFileIdString); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1365 |
if( fnameNode!= NULL) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1366 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1367 |
HANodeIterator fileNode(current); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1368 |
bool ret1 = fileNode.FindNodeById(fnameNode); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1369 |
issueLoc = toString(fileNode.GetAttribute(KXMLNameString)); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1370 |
} |
| 0 | 1371 |
|
1372 |
const XMLCh* attributeValue = current.GetAttribute(KXMLAttributeString); |
|
1373 |
if ( |
|
1374 |
( |
|
1375 |
(iFuncType == EIssueIdentityInlineFunction) && !current.CheckForBooleanAttribute(KXMLInlineString) |
|
1376 |
) || |
|
1377 |
( |
|
1378 |
(iFuncType == EIssueIdentityExportedFunction) && (!attributeValue || !Equals(attributeValue,KXMLExportedString) ) |
|
1379 |
&& |
|
1380 |
(!current.CheckForBooleanAttribute(KXMLVirtualString)) |
|
1381 |
) |
|
1382 |
) |
|
1383 |
{
|
|
1384 |
if (report) |
|
1385 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1386 |
AddIssueFunction<EIssueTypeRemoval>(&baseline,iFuncType,baseline,0,""); |
| 0 | 1387 |
|
1388 |
} |
|
1389 |
++ret; |
|
1390 |
return ret; |
|
1391 |
} |
|
1392 |
||
1393 |
string basefuncsig = GenerateFunctionSignature(baseline); |
|
1394 |
string currentfuncsig = GenerateFunctionSignature(current); |
|
1395 |
||
1396 |
if ( basefuncsig != currentfuncsig ) |
|
1397 |
{
|
|
1398 |
++ret; |
|
1399 |
if (report) |
|
1400 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1401 |
AddIssueFunction<EIssueTypeParam>(&baseline,iFuncType,current,lineNo,issueLoc); |
| 0 | 1402 |
} |
1403 |
} |
|
1404 |
else |
|
1405 |
{
|
|
1406 |
//Check also the default parameter values |
|
1407 |
DOMElement * baselineelement = static_cast<DOMElement*>(baseline.current); |
|
1408 |
DOMNodeList* baselinechilds = baselineelement->getChildNodes(); |
|
1409 |
DOMElement * currentelement = static_cast<DOMElement*>(current.current); |
|
1410 |
DOMNodeList* currentchilds = currentelement->getChildNodes(); |
|
1411 |
||
1412 |
XMLSize_t childcount = baselinechilds->getLength(); |
|
1413 |
||
1414 |
unsigned int i = 0; |
|
1415 |
for (i = 0; i < childcount; ++i) |
|
1416 |
{
|
|
1417 |
DOMNode* baselinechild = baselinechilds->item(i); |
|
1418 |
HANodeIterator baselinechildit(baseline); |
|
1419 |
baselinechildit.current = baselinechild; |
|
1420 |
||
1421 |
DOMNode* currentchild = currentchilds->item(i); |
|
1422 |
HANodeIterator currentchildit(current); |
|
1423 |
currentchildit.current = currentchild; |
|
1424 |
||
1425 |
short nodetype = baselinechildit->getNodeType(); |
|
1426 |
if (nodetype == DOMNode::ELEMENT_NODE) |
|
1427 |
{
|
|
1428 |
const XMLCh * baselinesize = FindAttributeValueForType(baselinechildit,KXMLSizeString); |
|
1429 |
const XMLCh * currentsize = FindAttributeValueForType(currentchildit,KXMLSizeString); |
|
1430 |
||
1431 |
const XMLCh * baselinealign = FindAttributeValueForType(baselinechildit,KXMLAlignString); |
|
1432 |
const XMLCh * currentalign = FindAttributeValueForType(currentchildit,KXMLAlignString); |
|
1433 |
||
1434 |
if ( !baselinesize ) |
|
1435 |
{
|
|
1436 |
baselinesize = baselinealign; |
|
1437 |
} |
|
1438 |
||
1439 |
if ( !currentsize ) |
|
1440 |
{
|
|
1441 |
currentsize = currentalign; |
|
1442 |
} |
|
1443 |
||
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1444 |
if ( !Equals(baselinesize,currentsize) || !Equals(baselinealign, currentalign) ) |
| 0 | 1445 |
{
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1446 |
++ret; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1447 |
if (report) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1448 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1449 |
//AddIssue<iFuncType,EIssueTypeParam>(&baseline, current); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1450 |
AddIssueFunction<EIssueTypeParam>(&baseline,iFuncType,current,lineNo,issueLoc); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1451 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1452 |
break; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1453 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1454 |
// if default value is changed then it should be reported as informative |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1455 |
if(!CompareAttributes(baselinechildit,currentchildit,KXMLDefaultString,EOptionalSimpleAttribute)) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1456 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1457 |
++ret; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1458 |
if (report) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1459 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1460 |
AddIssueFunction<EIssueTypeDefaultParam>(&baseline,iFuncType,current,lineNo,issueLoc); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1461 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1462 |
break; |
| 0 | 1463 |
} |
1464 |
} |
|
1465 |
||
1466 |
} |
|
1467 |
||
1468 |
} |
|
1469 |
||
1470 |
if ( !CompareAttributes(baseline,current,KXMLReturnsString,EOptionalTypeAttribute) ) |
|
1471 |
{
|
|
1472 |
++ret; |
|
1473 |
if (report) |
|
1474 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1475 |
AddIssueFunction<EIssueTypeReturn>(&baseline,iFuncType,current,lineNo,issueLoc); |
| 0 | 1476 |
} |
1477 |
} |
|
1478 |
||
1479 |
return ret; |
|
1480 |
} |
|
1481 |
||
1482 |
||
1483 |
//////////////////////////////////////////////////////////////////////////////////////// |
|
1484 |
///////////////////////////////TypedefNodeAnalysis///////////////////////////////////// |
|
1485 |
||
1486 |
||
1487 |
// ---------------------------------------------------------------------------- |
|
1488 |
// TypedefNodeAnalysis::Construct |
|
1489 |
// ---------------------------------------------------------------------------- |
|
1490 |
// |
|
1491 |
NodeAnalysis* TypedefNodeAnalysis::Construct() |
|
1492 |
{
|
|
1493 |
return new TypedefNodeAnalysis; |
|
1494 |
} |
|
1495 |
||
1496 |
// ---------------------------------------------------------------------------- |
|
1497 |
// TypedefNodeAnalysis::FindNodeAndAnalyse |
|
1498 |
// ---------------------------------------------------------------------------- |
|
1499 |
// |
|
1500 |
int TypedefNodeAnalysis::FindNodeAndAnalyse(HANodeIterator baseline,HANodeIterator current) |
|
1501 |
{
|
|
1502 |
DOMNode* node = NodeAnalysis::findNode(baseline,current); |
|
1503 |
if ( !node ) |
|
1504 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1505 |
AddIssue<EIssueIdentityTypedef,EIssueTypeRemoval>(&baseline, baseline,0,""); |
| 0 | 1506 |
return 1; |
1507 |
} |
|
1508 |
current.current = node; |
|
1509 |
||
1510 |
return this->Analyse(baseline,current); |
|
1511 |
} |
|
1512 |
||
1513 |
// ---------------------------------------------------------------------------- |
|
1514 |
// TypedefNodeAnalysis::Analyse |
|
1515 |
// ---------------------------------------------------------------------------- |
|
1516 |
// |
|
1517 |
int TypedefNodeAnalysis::Analyse(HANodeIterator baseline,HANodeIterator current, bool report) |
|
1518 |
{
|
|
1519 |
assert( Equals(KXMLTypedefString, baseline->getNodeName()) && |
|
1520 |
Equals(KXMLTypedefString, current->getNodeName()) && |
|
1521 |
Equals(baseline->getNodeName(), current->getNodeName()) |
|
1522 |
); |
|
1523 |
||
1524 |
//<Typedef id="_9" name="TOmaInt" type="_8" context="_1" location="f0:108" file="f0" line="108"/> |
|
1525 |
||
1526 |
int lineNo = 0; |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1527 |
string issueLoc; |
| 0 | 1528 |
const XMLCh* lineNumber = current.GetAttribute(KXMLLineString); |
1529 |
lineNo = atoi(toString(lineNumber).c_str()); |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1530 |
const XMLCh* fnameNode = current.GetAttribute(KXMLFileIdString); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1531 |
if( fnameNode != NULL) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1532 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1533 |
HANodeIterator fileNode(current); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1534 |
bool retval= fileNode.FindNodeById(fnameNode); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1535 |
issueLoc = toString(fileNode.GetAttribute(KXMLNameString)); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1536 |
} |
| 0 | 1537 |
|
1538 |
int ret = 0; |
|
1539 |
||
1540 |
if ( !CompareAttributes(baseline,current,KXMLNameString,ESimpleAttribute) ) |
|
1541 |
{
|
|
1542 |
if (report) |
|
1543 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1544 |
AddIssue<EIssueIdentityTypedef,EIssueTypeChange>(&baseline, current,lineNo,issueLoc); |
| 0 | 1545 |
} |
1546 |
++ret; |
|
1547 |
} |
|
1548 |
||
1549 |
if ( !CompareAttributes(baseline,current,KXMLTypeString,ETypeAttribute) ) |
|
1550 |
{
|
|
1551 |
if (report) |
|
1552 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1553 |
AddIssue<EIssueIdentityTypedef,EIssueTypeChange>(&baseline, current,lineNo,issueLoc); |
| 0 | 1554 |
} |
1555 |
++ret; |
|
1556 |
} |
|
1557 |
||
1558 |
HANodeIterator baselinetypeit(baseline); |
|
1559 |
HANodeIterator currenttypeit(current); |
|
1560 |
||
1561 |
const XMLCh* baselinetypeid = baseline.GetAttribute(KXMLTypeString); |
|
1562 |
const XMLCh* currenttypeid = current.GetAttribute(KXMLTypeString); |
|
1563 |
||
1564 |
assert( baselinetypeid && currenttypeid); |
|
1565 |
||
1566 |
bool ret1 = baselinetypeit.FindNodeById(baselinetypeid); |
|
1567 |
bool ret2 = currenttypeit.FindNodeById(currenttypeid); |
|
1568 |
||
1569 |
assert(ret1 && ret2); |
|
1570 |
||
1571 |
if ( IsFunction(baselinetypeit) ) |
|
1572 |
{
|
|
1573 |
if ( !CompareAttributes(baselinetypeit,currenttypeit,KXMLReturnsString,EOptionalTypeAttribute) ) |
|
1574 |
{
|
|
1575 |
if (report) |
|
1576 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1577 |
AddIssue<EIssueIdentityTypedef,EIssueTypeChange>(&baseline, current,lineNo,issueLoc); |
| 0 | 1578 |
} |
1579 |
++ret; |
|
1580 |
} |
|
1581 |
} |
|
1582 |
||
1583 |
if (!CheckAccessModifier(baseline,current)) |
|
1584 |
{
|
|
1585 |
if (report) |
|
1586 |
{
|
|
1587 |
//AddIssue<iIdentity,EIssueTypeAccess>(&baseline, current); |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1588 |
AddIssue<EIssueIdentityTypedef,EIssueTypeAccess>(&baseline, current,lineNo,issueLoc); |
| 0 | 1589 |
} |
1590 |
ret += 1; |
|
1591 |
} |
|
1592 |
||
1593 |
return ret; |
|
1594 |
} |
|
1595 |
||
1596 |
||
1597 |
//////////////////////////////////////////////////////////////////////////////////////// |
|
1598 |
///////////////////////////////OperatorFunctionNodeAnalysis///////////////////////////// |
|
1599 |
||
1600 |
// ---------------------------------------------------------------------------- |
|
1601 |
// OperatorFunctionNodeAnalysis::Construct |
|
1602 |
// ---------------------------------------------------------------------------- |
|
1603 |
// |
|
1604 |
NodeAnalysis* OperatorFunctionNodeAnalysis::Construct() |
|
1605 |
{
|
|
1606 |
return new OperatorFunctionNodeAnalysis; |
|
1607 |
} |
|
1608 |
||
1609 |
//////////////////////////////////////////////////////////////////////////////////////// |
|
1610 |
///////////////////////////////UnionNodeAnalysis//////////////////////////////////////// |
|
1611 |
||
1612 |
// ---------------------------------------------------------------------------- |
|
1613 |
// UnionNodeAnalysis::Construct |
|
1614 |
// ---------------------------------------------------------------------------- |
|
1615 |
// |
|
1616 |
NodeAnalysis* UnionNodeAnalysis::Construct() |
|
1617 |
{
|
|
1618 |
return new UnionNodeAnalysis; |
|
1619 |
} |
|
1620 |
||
1621 |
// ---------------------------------------------------------------------------- |
|
1622 |
// UnionNodeAnalysis::UnionNodeAnalysis |
|
1623 |
// |
|
1624 |
// ---------------------------------------------------------------------------- |
|
1625 |
// |
|
1626 |
UnionNodeAnalysis::UnionNodeAnalysis() |
|
1627 |
{
|
|
1628 |
iIdentity = EIssueIdentityUnion; |
|
1629 |
} |
|
1630 |
||
1631 |
// ---------------------------------------------------------------------------- |
|
1632 |
// UnionNodeAnalysis::compareBaseSizes |
|
1633 |
// ---------------------------------------------------------------------------- |
|
1634 |
// |
|
1635 |
int UnionNodeAnalysis::compareBaseSizes(HANodeIterator baseline, HANodeIterator current, const NodeIndex::dtable_t& bfields, const NodeIndex::dtable_t& cfields, bool report) |
|
1636 |
{
|
|
1637 |
//Not meaningful in union as it can not be derived |
|
1638 |
return 0; |
|
1639 |
} |
|
1640 |
||
1641 |
// ---------------------------------------------------------------------------- |
|
1642 |
// UnionNodeAnalysis::FindNodeAndAnalyse |
|
1643 |
// ---------------------------------------------------------------------------- |
|
1644 |
// |
|
1645 |
int UnionNodeAnalysis::FindNodeAndAnalyse(HANodeIterator baseline,HANodeIterator current) |
|
1646 |
{
|
|
1647 |
//First check to see if this is an anonymous Union |
|
1648 |
const XMLCh* name = baseline.GetAttribute(KXMLNameString); |
|
1649 |
if ( !name ) |
|
1650 |
{
|
|
1651 |
//This is anonymous union and does not need to be analysed |
|
1652 |
return 0; |
|
1653 |
} |
|
1654 |
||
1655 |
if ( Equals(name,KXMLEmptyString) ) |
|
1656 |
{
|
|
1657 |
return 0; |
|
1658 |
} |
|
1659 |
||
1660 |
DOMNode* node = NodeAnalysis::findNode(baseline,current); |
|
1661 |
||
1662 |
if ( !node ) |
|
1663 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1664 |
AddIssue<EIssueIdentityUnion,EIssueTypeRemoval>(&baseline, baseline,0,""); |
| 0 | 1665 |
return 1; |
1666 |
} |
|
1667 |
current.current = node; |
|
1668 |
||
1669 |
return this->Analyse(baseline,current); |
|
1670 |
} |
|
1671 |
||
1672 |
// ---------------------------------------------------------------------------- |
|
1673 |
// UnionNodeAnalysis::compareVirtualFunctions |
|
1674 |
// The union can not have virtual functions |
|
1675 |
// ---------------------------------------------------------------------------- |
|
1676 |
// |
|
1677 |
int UnionNodeAnalysis::compareVirtualFunctions(HANodeIterator baseline,HANodeIterator current, |
|
1678 |
const vector<DOMNode*>& bvirtualMethods, |
|
1679 |
const vector<DOMNode*>& cvirtualMethods, |
|
1680 |
bool report) |
|
1681 |
{
|
|
1682 |
return 0; |
|
1683 |
} |
|
1684 |
||
1685 |
//////////////////////////////////////////////////////////////////////////////////////// |
|
1686 |
///////////////////////////////ClassNodeAnalysis//////////////////////////////////////// |
|
1687 |
||
1688 |
// ---------------------------------------------------------------------------- |
|
1689 |
// printMember |
|
1690 |
// Debug stuff |
|
1691 |
// ---------------------------------------------------------------------------- |
|
1692 |
// |
|
1693 |
void printMember(HANodeIterator member) |
|
1694 |
{
|
|
1695 |
DEBUG_PRINT_XMLCh(member->getNodeName()); |
|
1696 |
DEBUG_PRINT(":");
|
|
1697 |
const XMLCh * memname = member.GetAttribute(KXMLNameString); |
|
1698 |
if (memname) |
|
1699 |
{
|
|
1700 |
DEBUG_PRINT_XMLCh(memname); |
|
1701 |
} |
|
1702 |
} |
|
1703 |
||
1704 |
// ---------------------------------------------------------------------------- |
|
1705 |
// ClassNodeAnalysis::compareMethodsSignature |
|
1706 |
// Compare baseline and current methods and return false if they do not match. |
|
1707 |
// Uses additional comparator object if available. |
|
1708 |
// ---------------------------------------------------------------------------- |
|
1709 |
// |
|
1710 |
bool ClassNodeAnalysis::compareMethodsSignature(HANodeIterator basemethod,HANodeIterator currentmethod, const NodeTypeComparator& comparator) |
|
1711 |
{
|
|
1712 |
short basenodetype = basemethod->getNodeType(); |
|
1713 |
short currnodetype = currentmethod->getNodeType(); |
|
1714 |
assert(basenodetype == DOMNode::ELEMENT_NODE && currnodetype == DOMNode::ELEMENT_NODE); |
|
1715 |
assert(IsFunction(basemethod) && IsFunction(currentmethod)); |
|
1716 |
||
1717 |
#ifdef _DEBUG |
|
1718 |
string basefuncsig = GenerateFunctionSignature(basemethod); |
|
1719 |
string currentfuncsig = GenerateFunctionSignature(currentmethod); |
|
1720 |
cout << " basefuncsig=" << basefuncsig << endl; |
|
1721 |
cout << "currentfuncsig=" << currentfuncsig << endl; |
|
1722 |
#endif |
|
1723 |
||
1724 |
if( !Equals(basemethod->getNodeName(), currentmethod->getNodeName() )) |
|
1725 |
{
|
|
1726 |
return false; |
|
1727 |
} |
|
1728 |
||
1729 |
const XMLCh* basenameatt = basemethod.GetAttribute(KXMLNameString); |
|
1730 |
const XMLCh* currnameatt = currentmethod.GetAttribute(KXMLNameString); |
|
1731 |
||
1732 |
if( !Equals(basenameatt, currnameatt )) |
|
1733 |
{
|
|
1734 |
return false; |
|
1735 |
} |
|
1736 |
||
1737 |
DOMElement * basenodeelement = static_cast<DOMElement*>(basemethod.current); |
|
1738 |
DOMElement * currnodeelement = static_cast<DOMElement*>(currentmethod.current); |
|
1739 |
std::vector<DOMNode*> baseElementNodes; |
|
1740 |
std::vector<DOMNode*> currElementNodes; |
|
1741 |
GetElementNodes(basemethod, basenodeelement->getChildNodes(), baseElementNodes); |
|
1742 |
GetElementNodes(currentmethod, currnodeelement->getChildNodes(), currElementNodes); |
|
1743 |
||
1744 |
if( baseElementNodes.size() != currElementNodes.size() ) |
|
1745 |
{
|
|
1746 |
return false; |
|
1747 |
} |
|
1748 |
||
1749 |
for(size_t i = 0; i < baseElementNodes.size(); ++i) |
|
1750 |
{
|
|
1751 |
DOMNode* basechild = baseElementNodes[i]; |
|
1752 |
DOMNode* currchild = currElementNodes[i]; |
|
1753 |
HANodeIterator basechildit(basemethod); |
|
1754 |
HANodeIterator currchildit(currentmethod); |
|
1755 |
basechildit.current = basechild; |
|
1756 |
currchildit.current = currchild; |
|
1757 |
||
1758 |
short basetype = basechildit->getNodeType(); |
|
1759 |
short currtype = currchildit->getNodeType(); |
|
1760 |
if( !comparator.CompareParameter(basechildit, currchildit) ) |
|
1761 |
{
|
|
1762 |
return false; |
|
1763 |
} |
|
1764 |
} |
|
1765 |
||
1766 |
if( !comparator.CompareConstness(basemethod, currentmethod) ) |
|
1767 |
{
|
|
1768 |
return false; |
|
1769 |
} |
|
1770 |
||
1771 |
return true; |
|
1772 |
} |
|
1773 |
// ---------------------------------------------------------------------------- |
|
1774 |
// ClassNodeAnalysis::compareMethodsReturn |
|
1775 |
// ---------------------------------------------------------------------------- |
|
1776 |
// |
|
1777 |
bool ClassNodeAnalysis::compareMethodsReturn(HANodeIterator basemethod,HANodeIterator currentmethod, NodeTypeComparator& cmp) |
|
1778 |
{
|
|
1779 |
return cmp.CompareReturnValue(basemethod, currentmethod); |
|
1780 |
} |
|
1781 |
||
1782 |
// ---------------------------------------------------------------------------- |
|
1783 |
// ClassNodeAnalysis::compareField |
|
1784 |
// ---------------------------------------------------------------------------- |
|
1785 |
// |
|
1786 |
int ClassNodeAnalysis::compareField(HANodeIterator baseline, HANodeIterator current, const DataMember& basemember,const DataMember& currentmember, bool report) |
|
1787 |
{
|
|
1788 |
//<!ATTLIST Field mutable (0 | 1) "0"> |
|
1789 |
//<!ATTLIST Field name CDATA #REQUIRED> |
|
1790 |
//<!ATTLIST Field offset CDATA #IMPLIED> |
|
1791 |
//<!ATTLIST Field type CDATA #REQUIRED> |
|
1792 |
int ret = 0; |
|
1793 |
||
1794 |
HANodeIterator basefield(baseline); |
|
1795 |
basefield.current = basemember.iNode; |
|
1796 |
HANodeIterator currentfield(current); |
|
1797 |
currentfield.current = currentmember.iNode; |
|
1798 |
||
1799 |
int baseoffset = basemember.iOffset; |
|
1800 |
int currentoffset = currentmember.iOffset; |
|
1801 |
||
1802 |
TIssueIdentity identity = EIssueIdentityField; |
|
1803 |
bool accessthroughinline = false; |
|
1804 |
||
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1805 |
string issueLoc; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1806 |
const XMLCh* fnameNode = current.GetAttribute(KXMLFileIdString); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1807 |
if( fnameNode!= NULL) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1808 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1809 |
HANodeIterator fileNode(current); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1810 |
bool ret1 = fileNode.FindNodeById(fnameNode); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1811 |
issueLoc = toString(fileNode.GetAttribute(KXMLNameString)); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1812 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1813 |
|
| 0 | 1814 |
if ( !CheckAccessibility(baseline,accessthroughinline,basemember.iAccess) ) |
1815 |
{
|
|
1816 |
identity = EIssueIdentityFieldInaccessible; |
|
1817 |
} else |
|
1818 |
{
|
|
1819 |
||
1820 |
if ( baseoffset != currentoffset ) |
|
1821 |
{
|
|
1822 |
ret++; |
|
1823 |
if ( report ) |
|
1824 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1825 |
AddIssueField<EIssueTypeOffset>(&baseline,identity, currentfield,currentmember.iLineNo, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1826 |
issueLoc,NULL,basemember); |
| 0 | 1827 |
} |
1828 |
else |
|
1829 |
{
|
|
1830 |
return ret; |
|
1831 |
} |
|
1832 |
||
1833 |
} |
|
1834 |
} |
|
1835 |
||
1836 |
if ( IsAnonymousType(basefield) ) |
|
1837 |
{
|
|
1838 |
//We need to do comparison between the baseline type and current type anonymously |
|
1839 |
||
1840 |
HANodeIterator baselinetypeit(basefield); |
|
1841 |
HANodeIterator currenttypeit(currentfield); |
|
1842 |
||
1843 |
const XMLCh* baselinetypeid = basefield.GetAttribute(KXMLTypeString); |
|
1844 |
const XMLCh* currenttypeid = currentfield.GetAttribute(KXMLTypeString); |
|
1845 |
||
1846 |
assert( baselinetypeid && currenttypeid); |
|
1847 |
||
1848 |
bool ret1 = baselinetypeit.FindNodeById(baselinetypeid); |
|
1849 |
bool ret2 = currenttypeit.FindNodeById(currenttypeid); |
|
1850 |
||
1851 |
assert(ret1 && ret2); |
|
1852 |
||
1853 |
HANodeIterator baselinetypeanonit(baselinetypeit); |
|
1854 |
HANodeIterator currenttypeanonit(currenttypeit); |
|
1855 |
ret1 = FindAnonymousType(baselinetypeit,baselinetypeanonit); |
|
1856 |
ret2 = FindAnonymousType(currenttypeit,currenttypeanonit); |
|
1857 |
||
1858 |
assert(ret1); |
|
1859 |
||
1860 |
if ( !ret2 || !baselinetypeanonit.IsSameNodeType(currenttypeanonit) ) |
|
1861 |
{
|
|
1862 |
if (report) |
|
1863 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1864 |
AddIssueField<EIssueTypeChangeInType>(&baseline,identity, currentfield,currentmember.iLineNo, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1865 |
issueLoc, NULL,basemember); |
| 0 | 1866 |
} |
1867 |
ret++; |
|
1868 |
} |
|
1869 |
else |
|
1870 |
{
|
|
1871 |
bool report2 = false; |
|
1872 |
||
1873 |
if ( Equals(KXMLUnionString, baselinetypeit->getNodeName()) && Equals(KXMLEmptyString, basefield.GetAttribute(KXMLNameString)) ) |
|
1874 |
{
|
|
1875 |
report2 = report; |
|
1876 |
} |
|
1877 |
||
1878 |
NodeAnalysis::Constructor constructorfunction = FindNodeAnalysisConstructor(baselinetypeanonit->getNodeName()); |
|
1879 |
NodeAnalysis * analyser = constructorfunction(); |
|
1880 |
int retval2 = analyser->Analyse(baselinetypeanonit,currenttypeanonit,report2); |
|
1881 |
if ( retval2 > 0 && !report2) |
|
1882 |
{
|
|
1883 |
if (report) |
|
1884 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1885 |
AddIssueField<EIssueTypeChangeInType>(&baseline,identity, currentfield,currentmember.iLineNo, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1886 |
issueLoc,NULL,basemember); |
| 0 | 1887 |
} |
1888 |
++ret; |
|
1889 |
} |
|
1890 |
delete analyser; |
|
1891 |
} |
|
1892 |
} |
|
1893 |
else |
|
1894 |
{
|
|
1895 |
//{KXMLTypeString,EIdAttribute}
|
|
1896 |
if ( !CompareAttributes(basefield,currentfield,KXMLTypeString,ETypeAttribute) ) |
|
1897 |
{
|
|
1898 |
ret++; |
|
1899 |
if ( report ) |
|
1900 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1901 |
AddIssueField<EIssueTypeChangeInType>(&baseline,identity, currentfield,currentmember.iLineNo, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1902 |
issueLoc,NULL,basemember); |
| 0 | 1903 |
} |
1904 |
else |
|
1905 |
{
|
|
1906 |
return ret; |
|
1907 |
} |
|
1908 |
}else //Check if the size has changed although the the type has remained same |
|
1909 |
{
|
|
1910 |
const XMLCh* basefieldsize = GetSize(basefield); |
|
1911 |
const XMLCh* currentfieldsize = GetSize(currentfield); |
|
1912 |
||
1913 |
if ( !Equals(basefieldsize,currentfieldsize) ) |
|
1914 |
{
|
|
1915 |
ret++; |
|
1916 |
if ( report ) |
|
1917 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1918 |
AddIssueField<EIssueTypeSize>(&baseline,identity, currentfield,currentmember.iLineNo, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1919 |
issueLoc,NULL,basemember); |
| 0 | 1920 |
} |
1921 |
else |
|
1922 |
{
|
|
1923 |
return ret; |
|
1924 |
} |
|
1925 |
} |
|
1926 |
||
1927 |
} |
|
1928 |
} |
|
1929 |
return ret; |
|
1930 |
} |
|
1931 |
||
1932 |
// ---------------------------------------------------------------------------- |
|
1933 |
// dumpNodeVectordumpNodeVector |
|
1934 |
// ---------------------------------------------------------------------------- |
|
1935 |
// |
|
1936 |
void dumpNodeVector(HANodeIterator node,const vector<DOMNode*> & nodes) |
|
1937 |
{
|
|
1938 |
DEBUG_PRINT("Dumping node vector:\n")
|
|
1939 |
vector<DOMNode*>::const_iterator it = nodes.begin(); |
|
1940 |
for (;it != nodes.end(); ++it) |
|
1941 |
{
|
|
1942 |
node.current = (*it); |
|
1943 |
||
1944 |
DEBUG_PRINT_XMLCh(node->getNodeName()) |
|
1945 |
const XMLCh * name = node.GetAttribute(KXMLNameString); |
|
1946 |
if (name) |
|
1947 |
{
|
|
1948 |
DEBUG_PRINT(":")
|
|
1949 |
DEBUG_PRINT_XMLCh(name) |
|
1950 |
} |
|
1951 |
const XMLCh * id = node.GetAttribute(KXMLIdString); |
|
1952 |
if (id) |
|
1953 |
{
|
|
1954 |
DEBUG_PRINT(" with id ")
|
|
1955 |
DEBUG_PRINT_XMLCh(id) |
|
1956 |
} |
|
1957 |
DEBUG_PRINT("\n")
|
|
1958 |
} |
|
1959 |
} |
|
1960 |
||
1961 |
// ---------------------------------------------------------------------------- |
|
1962 |
// ClassNodeAnalysis::compareNonvirtualFunctions |
|
1963 |
// ---------------------------------------------------------------------------- |
|
1964 |
// |
|
1965 |
int ClassNodeAnalysis::compareNonvirtualFunctions( HANodeIterator baseline, |
|
1966 |
HANodeIterator current, |
|
1967 |
const vector<DOMNode*>& bexportedMethods, |
|
1968 |
const vector<DOMNode*>& cexportedMethods, |
|
1969 |
TIssueIdentity identity, |
|
1970 |
bool report ) |
|
1971 |
{
|
|
1972 |
int ret = 0; |
|
1973 |
int parentLineNo = 0; |
|
1974 |
||
1975 |
// Get default comparator: |
|
1976 |
const ComparatorVector& cmps = ComparatorFactory::Instance().GetComparators(); |
|
1977 |
ComparatorVector::const_iterator comparator = cmps.begin(); |
|
1978 |
const XMLCh* parenLinenumber = current.GetAttribute( KXMLLineString); |
|
1979 |
parentLineNo = atoi(toString(parenLinenumber).c_str()); |
|
1980 |
||
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1981 |
string parentIssueLoc; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1982 |
const XMLCh* fnameNode = current.GetAttribute(KXMLFileIdString); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1983 |
if(fnameNode != NULL) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1984 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1985 |
HANodeIterator fileNode(current); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1986 |
bool ret1 = fileNode.FindNodeById(fnameNode); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1987 |
parentIssueLoc = toString(fileNode.GetAttribute(KXMLNameString)); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1988 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
1989 |
|
| 0 | 1990 |
// Build method maps for baseline and current platform's classes: |
1991 |
MethodMatchMap baseMap; |
|
1992 |
vector<DOMNode*>::const_iterator i = bexportedMethods.begin(); |
|
1993 |
for( ; i != bexportedMethods.end(); ++i ) |
|
1994 |
{
|
|
1995 |
baseMap.insert( make_pair(*i, MethodMatchFlags(false, false))); |
|
1996 |
} |
|
1997 |
||
1998 |
vector<DOMNode*>::const_iterator j = cexportedMethods.begin(); |
|
1999 |
MethodMatchMap currMap; |
|
2000 |
for( ; j != cexportedMethods.end(); ++j ) |
|
2001 |
{
|
|
2002 |
currMap.insert( make_pair(*j, MethodMatchFlags(false, false))); |
|
2003 |
} |
|
2004 |
||
2005 |
if( comparator != cmps.end() ) |
|
2006 |
{
|
|
2007 |
int comparatorRound = 1; |
|
2008 |
// Call compare function and give the default comparator as a parameter |
|
2009 |
ret = this->compareNonvirtualFunctions(baseline, current, bexportedMethods, cexportedMethods, identity, report, comparator, baseMap, currMap, comparatorRound); |
|
2010 |
} |
|
2011 |
||
2012 |
if( report ) |
|
2013 |
{
|
|
2014 |
MethodMatchMap::iterator baseFunc = baseMap.begin(); |
|
2015 |
for(; baseFunc != baseMap.end(); ++baseFunc ) |
|
2016 |
{
|
|
2017 |
int lineNo = 0; |
|
2018 |
string baseMethodName = toString(GetAttribute(baseFunc->first,KXMLNameString)); |
|
2019 |
MethodMatchMap::iterator curFunc = currMap.begin(); |
|
2020 |
for(; curFunc != currMap.end(); ++curFunc ) |
|
2021 |
{
|
|
2022 |
string curMethodName = toString(GetAttribute(curFunc->first,KXMLNameString)); |
|
2023 |
if (baseMethodName == curMethodName) |
|
2024 |
{
|
|
2025 |
const XMLCh* linenumber = GetAttribute(curFunc->first, KXMLLineString); |
|
2026 |
lineNo = atoi(toString(linenumber).c_str()); |
|
2027 |
break; |
|
2028 |
||
2029 |
} |
|
2030 |
} |
|
2031 |
if( baseFunc->second.signatureMatch == false ) |
|
2032 |
{
|
|
2033 |
// Function signatures do not match |
|
2034 |
HANodeIterator removedMethod(baseline); |
|
2035 |
removedMethod.current = baseFunc->first; |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2036 |
AddIssueFunction<EIssueTypeRemoval>(&removedMethod, identity, removedMethod,parentLineNo,parentIssueLoc); |
| 0 | 2037 |
++ret; |
2038 |
} |
|
2039 |
else if( baseFunc->second.returnValueMatch == false ) |
|
2040 |
{
|
|
2041 |
// Function return values do not match |
|
2042 |
HANodeIterator removedMethod(baseline); |
|
2043 |
removedMethod.current = baseFunc->first; |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2044 |
AddIssueFunction<EIssueTypeReturn>(&removedMethod,identity, removedMethod,lineNo,parentIssueLoc); |
| 0 | 2045 |
++ret; |
2046 |
} |
|
2047 |
} |
|
2048 |
} |
|
2049 |
return ret; |
|
2050 |
} |
|
2051 |
// ---------------------------------------------------------------------------- |
|
2052 |
// ClassNodeAnalysis::compareNonvirtualFunctions |
|
2053 |
// ---------------------------------------------------------------------------- |
|
2054 |
// |
|
2055 |
int ClassNodeAnalysis::compareNonvirtualFunctions( |
|
2056 |
HANodeIterator baseline, |
|
2057 |
HANodeIterator current, |
|
2058 |
const vector<DOMNode*>& bexportedMethods, |
|
2059 |
const vector<DOMNode*>& cexportedMethods, |
|
2060 |
TIssueIdentity identity, |
|
2061 |
bool report, |
|
2062 |
ComparatorVector::const_iterator comparator, |
|
2063 |
MethodMatchMap& baseMap, |
|
2064 |
MethodMatchMap& currMap, |
|
2065 |
int comparatorRound) |
|
2066 |
{
|
|
2067 |
int ret = 0; |
|
2068 |
||
2069 |
int lineNo1 = 0; |
|
2070 |
//const XMLCh* lineNumber = current.GetAttribute(KXMLLineString); |
|
2071 |
//lineNo = atoi(toString(lineNumber).c_str()); |
|
2072 |
||
2073 |
//Exported methods |
|
2074 |
vector<DOMNode*>::const_iterator bIter = bexportedMethods.begin(); |
|
2075 |
for( ; bIter != bexportedMethods.end(); ++bIter ) |
|
2076 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2077 |
int baseCount = 0; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2078 |
int currCount = 0; |
| 0 | 2079 |
MethodMatchMap::iterator baseMapIter = baseMap.find(*bIter); |
2080 |
assert(baseMapIter != baseMap.end()); |
|
2081 |
if( baseMapIter->second.signatureMatch ) |
|
2082 |
{
|
|
2083 |
continue; // This method has already been found and analyzed. |
|
2084 |
} |
|
2085 |
HANodeIterator basemethod(baseline); |
|
2086 |
basemethod.current = *bIter; |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2087 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2088 |
vector<DOMNode*>::const_iterator cIter = cexportedMethods.begin(); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2089 |
const XMLCh* baseMathodID = basemethod->getNodeName(); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2090 |
const XMLCh* basenameatt; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2091 |
const XMLCh* basereturnatt; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2092 |
const XMLCh* basemangledatt; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2093 |
if(Equals(baseMathodID,KXMLMethodString)) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2094 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2095 |
basenameatt = basemethod.GetAttribute(KXMLNameString); |
| 12 | 2096 |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2097 |
HANodeIterator baseReturMathod(basemethod); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2098 |
bool ret = baseReturMathod.FindNodeById(basemethod.GetAttribute(KXMLReturnsString)); |
| 12 | 2099 |
basereturnatt = GetActualTypeValue(baseReturMathod); |
2100 |
||
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2101 |
basemangledatt = basemethod.GetAttribute(KXMLMangledString); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2102 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2103 |
for( ; cIter != cexportedMethods.end(); ++cIter) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2104 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2105 |
HANodeIterator currentmethod(current); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2106 |
currentmethod.current = *cIter; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2107 |
const XMLCh* lineNumber1 = GetAttribute(currentmethod.current,KXMLLineString); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2108 |
lineNo1 = atoi(toString(lineNumber1).c_str()); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2109 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2110 |
string issueLoc; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2111 |
const XMLCh* fnameNode = currentmethod.GetAttribute(KXMLFileIdString); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2112 |
if( fnameNode!= NULL) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2113 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2114 |
HANodeIterator fileNode(currentmethod); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2115 |
bool retval = fileNode.FindNodeById(fnameNode); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2116 |
issueLoc = toString(fileNode.GetAttribute(KXMLNameString)); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2117 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2118 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2119 |
MethodMatchMap::iterator currMapIter = currMap.find(*cIter); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2120 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2121 |
const XMLCh* curMathodID = currentmethod->getNodeName(); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2122 |
if(Equals(curMathodID,KXMLMethodString)) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2123 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2124 |
HANodeIterator curReturMathod(currentmethod); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2125 |
bool ret1 = curReturMathod.FindNodeById(currentmethod.GetAttribute(KXMLReturnsString)); |
| 12 | 2126 |
const XMLCh* curReturnatt = GetActualTypeValue(curReturMathod); |
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2127 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2128 |
// check for overloaded function, first time matching the name, return type and signature |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2129 |
if( Equals(baseMathodID,KXMLMethodString)&& |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2130 |
Equals(basenameatt, currentmethod.GetAttribute(KXMLNameString)) && |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2131 |
Equals(basereturnatt, curReturnatt) && |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2132 |
Equals(basemangledatt, currentmethod.GetAttribute(KXMLMangledString)) ) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2133 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2134 |
baseCount++;// match found |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2135 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2136 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2137 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2138 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2139 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2140 |
if( currMapIter != currMap.end() && |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2141 |
currMapIter->second.signatureMatch == false && |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2142 |
compareMethodsSignature(basemethod, currentmethod, **comparator) ) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2143 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2144 |
if( comparatorRound==CONSTFILTER_COMPARATOR ) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2145 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2146 |
// if one of the parameter has changed from non-const to const |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2147 |
ret++; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2148 |
if(report) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2149 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2150 |
//add the issue as it is a source compatibility break |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2151 |
AddIssueFunction<EIssueTypeParamConst>(&basemethod,identity,currentmethod,lineNo1,issueLoc); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2152 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2153 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2154 |
//make signature and return value true so that the issue is not reported again |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2155 |
if( baseMapIter != baseMap.end() ) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2156 |
baseMapIter->second.signatureMatch = true; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2157 |
currMapIter->second.signatureMatch = true; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2158 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2159 |
baseMapIter->second.returnValueMatch = true; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2160 |
currMapIter->second.returnValueMatch = true; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2161 |
break; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2162 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2163 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2164 |
else if( comparatorRound==CONSTFILTER2_COMPARATOR ) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2165 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2166 |
// if one of the parameter has changed from const to non-const |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2167 |
ret++; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2168 |
if(report) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2169 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2170 |
//add the issue as it is a source compatibility break |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2171 |
AddIssueFunction<EIssueTypeParamConst2>(&basemethod,identity,currentmethod,lineNo1,issueLoc); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2172 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2173 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2174 |
//make signature and return value true so that the issue is not reported again |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2175 |
if( baseMapIter != baseMap.end() ) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2176 |
baseMapIter->second.signatureMatch = true; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2177 |
currMapIter->second.signatureMatch = true; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2178 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2179 |
baseMapIter->second.returnValueMatch = true; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2180 |
currMapIter->second.returnValueMatch = true; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2181 |
break; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2182 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2183 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2184 |
if( baseMapIter != baseMap.end() ) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2185 |
baseMapIter->second.signatureMatch = true; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2186 |
currMapIter->second.signatureMatch = true; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2187 |
//Check also the default parameter values |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2188 |
DOMElement * baselineelement = static_cast<DOMElement*>(basemethod.current); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2189 |
DOMNodeList* baselinechilds = baselineelement->getChildNodes(); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2190 |
DOMElement * currentelement = static_cast<DOMElement*>(currentmethod.current); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2191 |
DOMNodeList* currentchilds = currentelement->getChildNodes(); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2192 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2193 |
XMLSize_t childcount = baselinechilds->getLength(); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2194 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2195 |
unsigned int i = 0; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2196 |
for (i = 0; i < childcount; ++i) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2197 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2198 |
DOMNode* baselinechild = baselinechilds->item(i); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2199 |
HANodeIterator baselinechildit(baseline); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2200 |
baselinechildit.current = baselinechild; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2201 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2202 |
DOMNode* currentchild = currentchilds->item(i); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2203 |
HANodeIterator currentchildit(current); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2204 |
currentchildit.current = currentchild; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2205 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2206 |
short nodetype = baselinechildit->getNodeType(); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2207 |
if (nodetype == DOMNode::ELEMENT_NODE) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2208 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2209 |
const XMLCh * baselinesize = FindAttributeValueForType(baselinechildit,KXMLSizeString); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2210 |
const XMLCh * currentsize = FindAttributeValueForType(currentchildit,KXMLSizeString); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2211 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2212 |
const XMLCh * baselinealign = FindAttributeValueForType(baselinechildit,KXMLAlignString); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2213 |
const XMLCh * currentalign = FindAttributeValueForType(currentchildit,KXMLAlignString); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2214 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2215 |
if ( !baselinesize ) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2216 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2217 |
baselinesize = baselinealign; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2218 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2219 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2220 |
if ( !currentsize ) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2221 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2222 |
currentsize = currentalign; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2223 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2224 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2225 |
if ( !Equals(baselinesize,currentsize) || !Equals(baselinealign, currentalign) ) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2226 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2227 |
++ret; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2228 |
if (report) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2229 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2230 |
AddIssueFunction<EIssueTypeParam>(&basemethod,identity,currentmethod,lineNo1,issueLoc); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2231 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2232 |
break; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2233 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2234 |
// if default value is changed then it should be reported as informative |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2235 |
if(!CompareAttributes(baselinechildit,currentchildit,KXMLDefaultString,EOptionalSimpleAttribute)) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2236 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2237 |
++ret; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2238 |
if (report) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2239 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2240 |
AddIssueFunction<EIssueTypeDefaultParam>(&basemethod,identity,currentmethod,lineNo1,issueLoc); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2241 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2242 |
break; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2243 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2244 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2245 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2246 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2247 |
// Check function return values |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2248 |
const ComparatorVector& cmps = ComparatorFactory::Instance().GetComparators(); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2249 |
ComparatorVector::const_iterator retComparator = cmps.begin(); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2250 |
int retComparatorRound = 1; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2251 |
for ( ; retComparator != cmps.end(); retComparator++ ) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2252 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2253 |
if ( compareMethodsReturn(basemethod,currentmethod, **retComparator) ) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2254 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2255 |
if( retComparatorRound==CONSTFILTER_COMPARATOR ) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2256 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2257 |
// if the return value has changed from const to non-const |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2258 |
ret++; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2259 |
if(report) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2260 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2261 |
//add the issue as it is a source compatibility break |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2262 |
AddIssueFunction<EIssueTypeReturnConst>(&basemethod,identity,currentmethod,lineNo1,issueLoc); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2263 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2264 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2265 |
else if( retComparatorRound==CONSTFILTER2_COMPARATOR ) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2266 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2267 |
// if the return calue has changed from non-const to const |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2268 |
ret++; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2269 |
if(report) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2270 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2271 |
//add the issue as it is a source compatibility break |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2272 |
AddIssueFunction<EIssueTypeReturnConst2>(&basemethod,identity,currentmethod,lineNo1,issueLoc); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2273 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2274 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2275 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2276 |
baseMapIter->second.returnValueMatch = true; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2277 |
currMapIter->second.returnValueMatch = true; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2278 |
break; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2279 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2280 |
retComparatorRound++; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2281 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2282 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2283 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2284 |
if ( !CheckAccessModifier(basemethod,currentmethod) ) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2285 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2286 |
if (report) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2287 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2288 |
AddIssueFunction<EIssueTypeAccess>(&basemethod,identity, currentmethod,lineNo1,issueLoc); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2289 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2290 |
++ret; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2291 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2292 |
break; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2293 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2294 |
} // end of cuurent mathod loop |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2295 |
// check for overloaded function in current having same name and return type with diff signature |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2296 |
if (baseCount) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2297 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2298 |
currCount++; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2299 |
cIter = cexportedMethods.begin(); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2300 |
int lineNo; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2301 |
string fileName; |
| 0 | 2302 |
for( ; cIter != cexportedMethods.end(); ++cIter) |
2303 |
{
|
|
2304 |
HANodeIterator currentmethod(current); |
|
2305 |
currentmethod.current = *cIter; |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2306 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2307 |
const XMLCh* curMathodID = currentmethod->getNodeName(); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2308 |
if(Equals(curMathodID,KXMLMethodString)) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2309 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2310 |
HANodeIterator curReturMathod(currentmethod); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2311 |
bool ret1 = curReturMathod.FindNodeById(currentmethod.GetAttribute(KXMLReturnsString)); |
| 12 | 2312 |
const XMLCh* curReturnatt = GetActualTypeValue(curReturMathod); |
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2313 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2314 |
const XMLCh* lineNumber1 = GetAttribute(currentmethod.current,KXMLLineString); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2315 |
lineNo = atoi(toString(lineNumber1).c_str()); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2316 |
const XMLCh* fnameNode = currentmethod.GetAttribute(KXMLFileIdString); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2317 |
if(fnameNode != NULL) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2318 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2319 |
HANodeIterator filenode1(currentmethod); |
| 12 | 2320 |
bool ret1 = filenode1.FindNodeById(fnameNode); |
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2321 |
fileName = toString(filenode1.GetAttribute(KXMLNameString)); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2322 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2323 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2324 |
if(Equals(basenameatt, currentmethod.GetAttribute(KXMLNameString)) && |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2325 |
Equals(basereturnatt, curReturnatt ) && |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2326 |
!Equals(basemangledatt, currentmethod.GetAttribute(KXMLMangledString)) ) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2327 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2328 |
currCount++;// overloaded function found in current |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2329 |
break; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2330 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2331 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2332 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2333 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2334 |
//Now check if the function is overloaded in base also or not . |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2335 |
if(currCount > 1) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2336 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2337 |
vector<DOMNode*>::const_iterator baseInnerIter = bexportedMethods.begin(); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2338 |
for( ; baseInnerIter != bexportedMethods.end(); ++baseInnerIter ) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2339 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2340 |
HANodeIterator bmethod(baseline); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2341 |
bmethod.current = *baseInnerIter; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2342 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2343 |
const XMLCh* bMathodID = bmethod->getNodeName(); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2344 |
if(Equals(bMathodID,KXMLMethodString)) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2345 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2346 |
HANodeIterator returMathod(bmethod); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2347 |
bool ret1 = returMathod.FindNodeById(bmethod.GetAttribute(KXMLReturnsString)); |
| 12 | 2348 |
const XMLCh* returnatt = GetActualTypeValue(returMathod); |
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2349 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2350 |
if(Equals(basenameatt, bmethod.GetAttribute(KXMLNameString)) && |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2351 |
Equals(basereturnatt, returnatt) && |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2352 |
!Equals(basemangledatt, bmethod.GetAttribute(KXMLMangledString)) ) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2353 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2354 |
baseCount++;// overloaded function found in base |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2355 |
break; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2356 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2357 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2358 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2359 |
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2360 |
// Report the overloaded function only if it first time overloaded |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2361 |
if(baseCount == 1) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2362 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2363 |
ret++; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2364 |
if(report) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2365 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2366 |
//add the issue as it is a binary compatibility break |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2367 |
AddIssue<EIssueIdentityExportedFunction,EIssueTypeOverload>(&basemethod, basemethod,lineNo,fileName); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2368 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2369 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2370 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2371 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2372 |
}//end of base exported mathod loop |
| 0 | 2373 |
|
2374 |
// Recursive call with next comparator (if any) and updated method maps. |
|
2375 |
const ComparatorVector& cmps = ComparatorFactory::Instance().GetComparators(); |
|
2376 |
if( ++comparator != cmps.end() ) |
|
2377 |
{
|
|
2378 |
comparatorRound++; |
|
2379 |
ret += ClassNodeAnalysis::compareNonvirtualFunctions( |
|
2380 |
baseline, |
|
2381 |
current, |
|
2382 |
bexportedMethods, |
|
2383 |
cexportedMethods, |
|
2384 |
identity, |
|
2385 |
report, |
|
2386 |
comparator, |
|
2387 |
baseMap, |
|
2388 |
currMap, |
|
2389 |
comparatorRound); |
|
2390 |
} |
|
2391 |
||
2392 |
return ret; |
|
2393 |
} |
|
2394 |
||
2395 |
// ---------------------------------------------------------------------------- |
|
2396 |
// ClassNodeAnalysis::compareOthers |
|
2397 |
// ---------------------------------------------------------------------------- |
|
2398 |
// |
|
2399 |
int ClassNodeAnalysis::compareOthers(HANodeIterator baseline,HANodeIterator current, |
|
2400 |
const vector<DOMNode*>& bothers, const vector<DOMNode*>& cothers, |
|
2401 |
bool report) |
|
2402 |
{
|
|
2403 |
int retval = 0; |
|
2404 |
return retval; |
|
2405 |
} |
|
2406 |
||
2407 |
// ---------------------------------------------------------------------------- |
|
2408 |
// printlist |
|
2409 |
// ---------------------------------------------------------------------------- |
|
2410 |
// |
|
2411 |
void printlist(const NodeIndex::dtable_t& lista) |
|
2412 |
{
|
|
2413 |
NodeIndex::dtable_t::const_iterator it = lista.begin(); |
|
2414 |
for (; it != lista.end(); ++it) |
|
2415 |
{
|
|
2416 |
cout << it->iName << " at " << it->iOffset << "with node:" << it->iNode << endl; |
|
2417 |
} |
|
2418 |
} |
|
2419 |
||
2420 |
// ---------------------------------------------------------------------------- |
|
2421 |
// ClassNodeAnalysis::compareFields |
|
2422 |
// ---------------------------------------------------------------------------- |
|
2423 |
// |
|
2424 |
int ClassNodeAnalysis::compareFields(HANodeIterator baseline,HANodeIterator current, |
|
2425 |
const vector<DOMNode*>& bfields_class, |
|
2426 |
const vector<DOMNode*>& cfields_class, |
|
2427 |
bool report) |
|
2428 |
{
|
|
2429 |
int ret = 0; |
|
2430 |
||
2431 |
const NodeIndex::dtable_t& bfields = ClassGenerateDataMemberTable(baseline); |
|
2432 |
const NodeIndex::dtable_t& cfields = ClassGenerateDataMemberTable(current); |
|
2433 |
||
2434 |
int lineNo = 0; |
|
2435 |
const XMLCh* lineNumber = current.GetAttribute(KXMLLineString); |
|
2436 |
lineNo = atoi(toString(lineNumber).c_str()); |
|
2437 |
||
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2438 |
string issueLoc; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2439 |
const XMLCh* fnameNode = current.GetAttribute(KXMLFileIdString); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2440 |
if(fnameNode != NULL) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2441 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2442 |
HANodeIterator fileNode(current); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2443 |
bool retval = fileNode.FindNodeById(fnameNode); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2444 |
issueLoc = toString(fileNode.GetAttribute(KXMLNameString)); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2445 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2446 |
|
| 0 | 2447 |
// If you don't like to see the issue about base size when the size has changed |
2448 |
// uncomment the test below |
|
2449 |
||
2450 |
//if (!iReportAddedMembers) |
|
2451 |
//{
|
|
2452 |
// Check only if size has not changed |
|
2453 |
ret += compareBaseSizes(baseline, current, bfields, cfields, report); |
|
2454 |
//} |
|
2455 |
||
2456 |
// Fields |
|
2457 |
// Order and type of accessible members matters |
|
2458 |
////////////////////////////////////////////////////////////// |
|
2459 |
vector<bool> fieldFound(cfields.size(),false); |
|
2460 |
vector<bool> fieldRemoved(bfields.size(),false); |
|
2461 |
vector<bool> fieldChanged(bfields.size(),false); |
|
2462 |
vector<int> fieldChangedCurrent(bfields.size(),-1); |
|
2463 |
vector<bool> fieldAccessible(bfields.size(),false); |
|
2464 |
||
2465 |
unsigned int i = 0; |
|
2466 |
for (i=0; i < bfields.size(); ++i) |
|
2467 |
{
|
|
2468 |
if ( !bfields[i].iNode ) |
|
2469 |
{
|
|
2470 |
unsigned int ii = 0; |
|
2471 |
for (ii=0; ii < cfields.size(); ++ii) |
|
2472 |
{
|
|
2473 |
if ( !fieldFound[ii] && (bfields[i].iName == cfields[ii].iName) ) |
|
2474 |
{
|
|
2475 |
fieldFound[ii] = true; |
|
2476 |
||
2477 |
if ( bfields[i].iOffset != cfields[ii].iOffset ) |
|
2478 |
{
|
|
2479 |
if (report) |
|
2480 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2481 |
AddIssue<EIssueIdentityVirtualTablePointer,EIssueTypeOffset>(&baseline,current, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2482 |
lineNo,issueLoc,NULL,bfields[i]); |
| 0 | 2483 |
} |
2484 |
++ret; |
|
2485 |
} |
|
2486 |
break; |
|
2487 |
} |
|
2488 |
} |
|
2489 |
||
2490 |
if ( cfields.size() == ii ) |
|
2491 |
{
|
|
2492 |
fieldRemoved[i] = true; |
|
2493 |
} |
|
2494 |
||
2495 |
continue; |
|
2496 |
} |
|
2497 |
||
2498 |
HANodeIterator basefield(baseline); |
|
2499 |
basefield.current = bfields[i].iNode; |
|
2500 |
bool dummy; |
|
2501 |
fieldAccessible[i] = CheckAccessibility(baseline, dummy, bfields[i].iAccess); |
|
2502 |
||
2503 |
unsigned int ii = 0; |
|
2504 |
for (ii=0; ii < cfields.size(); ++ii) |
|
2505 |
{
|
|
2506 |
HANodeIterator currentfield(current); |
|
2507 |
currentfield.current = cfields[ii].iNode; |
|
2508 |
||
2509 |
if ( !fieldFound[ii] && (bfields[i].iName == cfields[ii].iName) )//CompareNames(basefield,currentfield) ) |
|
2510 |
{
|
|
2511 |
fieldFound[ii] = true; |
|
2512 |
||
2513 |
if ( fieldAccessible[i] && !CheckAccessModifier(bfields[i].iAccess,cfields[ii].iAccess) ) |
|
2514 |
{
|
|
2515 |
if (report) |
|
2516 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2517 |
AddIssue<EIssueIdentityField,EIssueTypeAccess>(&baseline, currentfield,cfields[ii].iLineNo, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2518 |
issueLoc,NULL,bfields[i]); |
| 0 | 2519 |
} |
2520 |
++ret; |
|
2521 |
} |
|
2522 |
||
2523 |
if ( 0 != compareField(baseline,current,bfields[i],cfields[ii],false) ) |
|
2524 |
{
|
|
2525 |
fieldChanged[i] = true; |
|
2526 |
fieldChangedCurrent[i] = ii; |
|
2527 |
if (fieldAccessible[i]) |
|
2528 |
{
|
|
2529 |
iReportAddedMembers = true; |
|
2530 |
} |
|
2531 |
} |
|
2532 |
break; |
|
2533 |
} |
|
2534 |
} |
|
2535 |
||
2536 |
if ( cfields.size() == ii ) |
|
2537 |
{
|
|
2538 |
fieldRemoved[i] = true; |
|
2539 |
if ( fieldAccessible[i] ) |
|
2540 |
{
|
|
2541 |
iReportAddedMembers = true; |
|
2542 |
} |
|
2543 |
} |
|
2544 |
} |
|
2545 |
||
2546 |
for (i = 0; i < fieldRemoved.size(); ++i) |
|
2547 |
{
|
|
2548 |
if (fieldRemoved[i]) |
|
2549 |
{
|
|
2550 |
if ( !bfields[i].iNode ) |
|
2551 |
{
|
|
2552 |
if (report) |
|
2553 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2554 |
AddIssue<EIssueIdentityVirtualTablePointer,EIssueTypeRemoval>(&baseline,current,lineNo, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2555 |
issueLoc,NULL,bfields[i]); |
| 0 | 2556 |
} |
2557 |
continue; |
|
2558 |
} |
|
2559 |
||
2560 |
HANodeIterator basefield(baseline); |
|
2561 |
basefield.current = bfields[i].iNode; |
|
2562 |
||
2563 |
if (iReportAddedMembers || fieldAccessible[i]) |
|
2564 |
{
|
|
2565 |
if (report) |
|
2566 |
{
|
|
2567 |
if (fieldAccessible[i]) |
|
2568 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2569 |
AddIssue<EIssueIdentityField,EIssueTypeRemoval>(&baseline, basefield,lineNo, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2570 |
issueLoc,NULL,bfields[i]); |
| 0 | 2571 |
} |
2572 |
else |
|
2573 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2574 |
AddIssue<EIssueIdentityFieldInaccessible,EIssueTypeRemoval>(&baseline, basefield,lineNo, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2575 |
issueLoc,NULL,bfields[i]); |
| 0 | 2576 |
} |
2577 |
} |
|
2578 |
++ret; |
|
2579 |
} |
|
2580 |
} |
|
2581 |
||
2582 |
if (fieldChanged[i]) |
|
2583 |
{
|
|
2584 |
HANodeIterator basefield(baseline); |
|
2585 |
HANodeIterator currentfield(current); |
|
2586 |
basefield.current = bfields[i].iNode; |
|
2587 |
int ii = fieldChangedCurrent[i]; |
|
2588 |
||
2589 |
if ( -1 == ii ) |
|
2590 |
{
|
|
2591 |
continue; |
|
2592 |
} |
|
2593 |
||
2594 |
if (iReportAddedMembers || fieldAccessible[i]) |
|
2595 |
{
|
|
2596 |
if (report) |
|
2597 |
{
|
|
2598 |
compareField(baseline, current, bfields[i], cfields[ii], report); |
|
2599 |
} |
|
2600 |
++ret; |
|
2601 |
} |
|
2602 |
} |
|
2603 |
||
2604 |
} |
|
2605 |
||
2606 |
for (i = 0; i < fieldFound.size(); ++i) |
|
2607 |
{
|
|
2608 |
if (!fieldFound[i]) |
|
2609 |
{
|
|
2610 |
if ( !cfields[i].iNode ) |
|
2611 |
{
|
|
2612 |
if (report) |
|
2613 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2614 |
AddIssue<EIssueIdentityVirtualTablePointer,EIssueTypeAddition>(&baseline,current,lineNo, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2615 |
issueLoc,NULL,cfields[i]); |
| 0 | 2616 |
} |
2617 |
continue; |
|
2618 |
} |
|
2619 |
||
2620 |
HANodeIterator currentfield(current); |
|
2621 |
currentfield.current = cfields[i].iNode; |
|
2622 |
if (report && iReportAddedMembers) |
|
2623 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2624 |
AddIssue<EIssueIdentityField,EIssueTypeAddition>(¤t, currentfield,cfields[i].iLineNo, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2625 |
issueLoc,NULL,cfields[i]); |
| 0 | 2626 |
} |
2627 |
++ret; |
|
2628 |
} |
|
2629 |
} |
|
2630 |
return ret; |
|
2631 |
} |
|
2632 |
||
2633 |
// ---------------------------------------------------------------------------- |
|
2634 |
// printlist |
|
2635 |
// Output list members |
|
2636 |
// |
|
2637 |
// ---------------------------------------------------------------------------- |
|
2638 |
// |
|
2639 |
void printlist(const NodeIndex::vtable_t& lista) |
|
2640 |
{
|
|
2641 |
NodeIndex::vtable_t::const_iterator it = lista.begin(); |
|
2642 |
for (; it != lista.end(); ++it) |
|
2643 |
{
|
|
2644 |
cout << it->first << endl; |
|
2645 |
} |
|
2646 |
||
2647 |
} |
|
2648 |
||
2649 |
// ---------------------------------------------------------------------------- |
|
2650 |
// ClassNodeAnalysis::indexVirtualMethods |
|
2651 |
// ---------------------------------------------------------------------------- |
|
2652 |
// |
|
2653 |
void ClassNodeAnalysis::indexVirtualMethods(HANodeIterator node, |
|
2654 |
const vector<DOMNode*>& virtualMethods, |
|
2655 |
const NodeIndex::vtable_t& vtable, |
|
2656 |
vector<pair<DOMNode*,int> >& virtualMethodsWithIndex) |
|
2657 |
{
|
|
2658 |
vector<DOMNode*>::const_iterator it = virtualMethods.begin(); |
|
2659 |
||
2660 |
for (; it != virtualMethods.end(); ++it) |
|
2661 |
{
|
|
2662 |
NodeIndex::vtable_t::const_iterator vtableit = vtable.begin(); |
|
2663 |
for (int i = 0; vtableit != vtable.end(); ++vtableit, ++i) |
|
2664 |
{
|
|
2665 |
HANodeIterator funcnode(node); |
|
2666 |
funcnode.current = *it; |
|
2667 |
||
2668 |
char index_str[256]; |
|
2669 |
||
2670 |
sprintf(index_str, "%d",i); |
|
2671 |
||
2672 |
funcnode.SetAttribute(KXMLBBCVirtualFunctionIndex, index_str ); |
|
2673 |
||
2674 |
string funcsig = GenerateFunctionSignature(funcnode); |
|
2675 |
if (funcsig == vtableit->first) |
|
2676 |
{
|
|
2677 |
virtualMethodsWithIndex.push_back(pair<DOMNode*,int>(*it,i)); |
|
2678 |
} |
|
2679 |
} |
|
2680 |
} |
|
2681 |
} |
|
2682 |
||
2683 |
// ---------------------------------------------------------------------------- |
|
2684 |
// ClassNodeAnalysis::compareVirtualTables |
|
2685 |
// ---------------------------------------------------------------------------- |
|
2686 |
// |
|
2687 |
int ClassNodeAnalysis::compareVirtualTables(HANodeIterator baseline,HANodeIterator current, |
|
2688 |
const NodeIndex::vtable_t& basevtable, |
|
2689 |
const NodeIndex::vtable_t& currentvtable, |
|
2690 |
bool report) |
|
2691 |
{
|
|
2692 |
if ( basevtable.size() != currentvtable.size() ) |
|
2693 |
{
|
|
2694 |
return 1; |
|
2695 |
} |
|
2696 |
||
2697 |
NodeIndex::vtable_t::const_iterator baseit = basevtable.begin(); |
|
2698 |
NodeIndex::vtable_t::const_iterator currentit = currentvtable.begin(); |
|
2699 |
||
2700 |
unsigned int i = 0; |
|
2701 |
for (i=0; baseit != basevtable.end(); ++baseit,++i,++currentit) |
|
2702 |
{
|
|
2703 |
||
2704 |
if ( baseit->first != currentit->first ) |
|
2705 |
{
|
|
2706 |
return 1; |
|
2707 |
} |
|
2708 |
} |
|
2709 |
return 0; |
|
2710 |
} |
|
2711 |
||
2712 |
// ---------------------------------------------------------------------------- |
|
2713 |
// ClassNodeAnalysis::compareVirtualFunctions |
|
2714 |
// ---------------------------------------------------------------------------- |
|
2715 |
// |
|
2716 |
int ClassNodeAnalysis::compareVirtualFunctions(HANodeIterator baseline,HANodeIterator current, |
|
2717 |
const vector<DOMNode*>& bvirtualMethods, |
|
2718 |
const vector<DOMNode*>& cvirtualMethods, |
|
2719 |
bool report) |
|
2720 |
{
|
|
2721 |
int ret = 0; |
|
2722 |
//Analyse virtual methods, not a single change is tolerated |
|
2723 |
||
2724 |
// First we build virtual tables for baseline and current classes. |
|
2725 |
const NodeIndex::vtable_t& basevtable = ClassGenerateVirtualTable(baseline); |
|
2726 |
const NodeIndex::vtable_t& currentvtable = ClassGenerateVirtualTable(current); |
|
2727 |
||
2728 |
int parentLineNo = 0; |
|
2729 |
int lineNo = 0; |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2730 |
string parentIssueLoc; |
| 0 | 2731 |
const XMLCh* parentlineNumber = current.GetAttribute(KXMLLineString); |
2732 |
parentLineNo = atoi(toString(parentlineNumber).c_str()); |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2733 |
const XMLCh* fnameNode = current.GetAttribute(KXMLFileIdString); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2734 |
if(fnameNode != NULL) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2735 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2736 |
HANodeIterator fileNode(current); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2737 |
bool retval = fileNode.FindNodeById(fnameNode); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2738 |
parentIssueLoc = toString(fileNode.GetAttribute(KXMLNameString)); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2739 |
} |
| 0 | 2740 |
if ( 0 != compareVirtualTables(baseline,current,basevtable,currentvtable,report) ) |
2741 |
{
|
|
2742 |
// Virtual table has been changed. |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2743 |
AddIssue<EIssueIdentityVirtualTable,EIssueTypeChange>(&baseline, current, parentLineNo, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2744 |
parentIssueLoc, NULL, "[Primary-vtable]"); |
| 0 | 2745 |
} |
2746 |
||
2747 |
vector<pair<DOMNode*,int> > bvirtualMethodsWithIndex; |
|
2748 |
vector<pair<DOMNode*,int> > cvirtualMethodsWithIndex; |
|
2749 |
||
2750 |
// Add virtual methods to vectors with their indexes (i.e. order inside a class). |
|
2751 |
indexVirtualMethods(baseline,bvirtualMethods,basevtable,bvirtualMethodsWithIndex); |
|
2752 |
indexVirtualMethods(current,cvirtualMethods,currentvtable,cvirtualMethodsWithIndex); |
|
2753 |
||
2754 |
unsigned int i = 0; |
|
2755 |
vector<bool> virtualMethodFound(cvirtualMethodsWithIndex.size(),false); |
|
2756 |
||
2757 |
// Use only default comparator here, since virtual functions should have strict match. |
|
2758 |
const ComparatorVector& cmps = ComparatorFactory::Instance().GetComparators(); |
|
2759 |
ComparatorVector::const_iterator defaultcomparator = cmps.begin(); |
|
2760 |
assert( defaultcomparator != cmps.end() ); |
|
2761 |
||
2762 |
for (i=0; i < bvirtualMethodsWithIndex.size(); ++i) |
|
2763 |
{
|
|
2764 |
HANodeIterator basemethod(baseline); |
|
2765 |
basemethod.current = bvirtualMethodsWithIndex[i].first; |
|
2766 |
||
2767 |
unsigned int ii = 0; |
|
2768 |
for (ii=0; ii < cvirtualMethodsWithIndex.size(); ++ii) |
|
2769 |
{
|
|
2770 |
HANodeIterator currentmethod(current); |
|
2771 |
currentmethod.current = cvirtualMethodsWithIndex[ii].first; |
|
2772 |
||
2773 |
lineNo = 0; |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2774 |
string issueLoc; |
| 0 | 2775 |
const XMLCh* lineNumber = currentmethod.GetAttribute(KXMLLineString); |
2776 |
lineNo = atoi(toString(lineNumber).c_str()); |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2777 |
const XMLCh* fnameNode = currentmethod.GetAttribute(KXMLFileIdString); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2778 |
if( fnameNode!= NULL) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2779 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2780 |
HANodeIterator fileNode1(currentmethod); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2781 |
bool retval = fileNode1.FindNodeById(fnameNode); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2782 |
issueLoc = toString(fileNode1.GetAttribute(KXMLNameString)); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2783 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2784 |
if ( compareMethodsSignature(basemethod,currentmethod, **defaultcomparator) ) |
| 0 | 2785 |
{
|
2786 |
virtualMethodFound[ii] = true; |
|
2787 |
if (bvirtualMethodsWithIndex[i].second != cvirtualMethodsWithIndex[ii].second) |
|
2788 |
{
|
|
2789 |
// Here the indexes don't match --> The order of virtual methods has been |
|
2790 |
// changed. This means that the layout of the virtual table has been changed |
|
2791 |
// and the binary compatibility is broken. |
|
2792 |
if (report) |
|
2793 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2794 |
AddIssue<EIssueIdentityVirtualFunction,EIssueTypeOrderChange>(&basemethod, currentmethod, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2795 |
lineNo,issueLoc); |
| 0 | 2796 |
} |
2797 |
++ret; |
|
2798 |
} |
|
2799 |
||
2800 |
//Check also the default parameter values |
|
2801 |
DOMElement * baselineelement = static_cast<DOMElement*>(basemethod.current); |
|
2802 |
DOMNodeList* baselinechilds = baselineelement->getChildNodes(); |
|
2803 |
DOMElement * currentelement = static_cast<DOMElement*>(currentmethod.current); |
|
2804 |
DOMNodeList* currentchilds = currentelement->getChildNodes(); |
|
2805 |
||
2806 |
XMLSize_t childcount = baselinechilds->getLength(); |
|
2807 |
||
2808 |
unsigned int i = 0; |
|
2809 |
for (i = 0; i < childcount; ++i) |
|
2810 |
{
|
|
2811 |
DOMNode* baselinechild = baselinechilds->item(i); |
|
2812 |
HANodeIterator baselinechildit(baseline); |
|
2813 |
baselinechildit.current = baselinechild; |
|
2814 |
||
2815 |
DOMNode* currentchild = currentchilds->item(i); |
|
2816 |
HANodeIterator currentchildit(current); |
|
2817 |
currentchildit.current = currentchild; |
|
2818 |
||
2819 |
short nodetype = baselinechildit->getNodeType(); |
|
2820 |
if (nodetype == DOMNode::ELEMENT_NODE) |
|
2821 |
{
|
|
2822 |
const XMLCh * baselinesize = FindAttributeValueForType(baselinechildit,KXMLSizeString); |
|
2823 |
const XMLCh * currentsize = FindAttributeValueForType(currentchildit,KXMLSizeString); |
|
2824 |
||
2825 |
const XMLCh * baselinealign = FindAttributeValueForType(baselinechildit,KXMLAlignString); |
|
2826 |
const XMLCh * currentalign = FindAttributeValueForType(currentchildit,KXMLAlignString); |
|
2827 |
||
2828 |
if ( !baselinesize ) |
|
2829 |
{
|
|
2830 |
baselinesize = baselinealign; |
|
2831 |
} |
|
2832 |
||
2833 |
if ( !currentsize ) |
|
2834 |
{
|
|
2835 |
currentsize = currentalign; |
|
2836 |
} |
|
2837 |
||
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2838 |
if ( !Equals(baselinesize,currentsize) || !Equals(baselinealign, currentalign) ) |
| 0 | 2839 |
{
|
2840 |
++ret; |
|
2841 |
if (report) |
|
2842 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2843 |
AddIssue<EIssueIdentityVirtualFunction,EIssueTypeParam>(&basemethod,currentmethod, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2844 |
lineNo,issueLoc); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2845 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2846 |
break; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2847 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2848 |
// if default value is changed then it should be reported as informative |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2849 |
if(!CompareAttributes(baselinechildit,currentchildit,KXMLDefaultString,EOptionalSimpleAttribute)) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2850 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2851 |
++ret; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2852 |
if (report) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2853 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2854 |
AddIssue<EIssueIdentityVirtualFunction,EIssueTypeDefaultParam>(&basemethod,currentmethod, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2855 |
lineNo,issueLoc); |
| 0 | 2856 |
} |
2857 |
break; |
|
2858 |
} |
|
2859 |
} |
|
2860 |
} |
|
2861 |
// check the return types of the methods |
|
2862 |
if ( !compareMethodsReturn(basemethod,currentmethod,**defaultcomparator) ) |
|
2863 |
{
|
|
2864 |
if (report) |
|
2865 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2866 |
AddIssue<EIssueIdentityVirtualFunction,EIssueTypeReturn>(&basemethod, currentmethod,lineNo,issueLoc); |
| 0 | 2867 |
} |
2868 |
++ret; |
|
2869 |
} |
|
2870 |
||
2871 |
if ( !CheckAccessModifier(basemethod,currentmethod) ) |
|
2872 |
{
|
|
2873 |
if (report) |
|
2874 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2875 |
AddIssue<EIssueIdentityVirtualFunction,EIssueTypeAccess>(&basemethod, currentmethod,lineNo,issueLoc); |
| 0 | 2876 |
} |
2877 |
++ret; |
|
2878 |
} |
|
2879 |
break; |
|
2880 |
} |
|
2881 |
} |
|
2882 |
||
2883 |
if ( cvirtualMethodsWithIndex.size() == ii ) |
|
2884 |
{
|
|
2885 |
//Method not found |
|
2886 |
||
2887 |
/* |
|
2888 |
// This code detects if the removed virtual function was actually an removed override. |
|
2889 |
unsigned int baseindex = bvirtualMethodsWithIndex[i].second; |
|
2890 |
HANodeIterator basemethod(baseline); |
|
2891 |
basemethod.current = bvirtualMethodsWithIndex[i].first; |
|
2892 |
||
2893 |
if ( (baseindex < currentvtable.size()) && (currentvtable[baseindex].first == GenerateFunctionSignature(basemethod)) ) |
|
2894 |
{
|
|
2895 |
//This is a new override and we should report this if the class is derivable |
|
2896 |
if (ClassIsDerivable(baseline)) |
|
2897 |
{
|
|
2898 |
if (report) |
|
2899 |
{
|
|
2900 |
AddIssue<EIssueIdentityVirtualFunction,EIssueTypeRemovedOverride>(&basemethod, basemethod); |
|
2901 |
} |
|
2902 |
++ret; |
|
2903 |
} |
|
2904 |
} |
|
2905 |
else*/ |
|
2906 |
{
|
|
2907 |
if (report) |
|
2908 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2909 |
AddIssue<EIssueIdentityVirtualFunction,EIssueTypeRemoval>(&basemethod, basemethod, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2910 |
parentLineNo,parentIssueLoc); |
| 0 | 2911 |
} |
2912 |
++ret; |
|
2913 |
} |
|
2914 |
} |
|
2915 |
} |
|
2916 |
||
2917 |
for (i = 0; i < virtualMethodFound.size(); ++i) |
|
2918 |
{
|
|
2919 |
if (!virtualMethodFound[i]) |
|
2920 |
{
|
|
2921 |
HANodeIterator currentmethod(current); |
|
2922 |
currentmethod.current = cvirtualMethodsWithIndex[i].first; |
|
2923 |
||
2924 |
lineNo = 0; |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2925 |
string issueLoc; |
| 0 | 2926 |
const XMLCh* lineNumber = currentmethod.GetAttribute(KXMLLineString); |
2927 |
lineNo = atoi(toString(lineNumber).c_str()); |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2928 |
const XMLCh* fnameNode = currentmethod.GetAttribute(KXMLFileIdString); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2929 |
if( fnameNode!= NULL) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2930 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2931 |
HANodeIterator fileNode1(currentmethod); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2932 |
bool retval = fileNode1.FindNodeById(fnameNode); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2933 |
issueLoc = toString(fileNode1.GetAttribute(KXMLNameString)); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2934 |
} |
| 0 | 2935 |
//Check the base vtable for entry for this function |
2936 |
unsigned int baseindex = cvirtualMethodsWithIndex[i].second; |
|
2937 |
||
2938 |
if ( (baseindex < basevtable.size()) && (basevtable[baseindex].first == GenerateFunctionSignature(currentmethod)) ) |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2939 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2940 |
// New rule is added for Q_OBJECT macro defining virtual functions. |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2941 |
// Do - add the Q_OBJECT macro to a class if the class already inherits from QObject , |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2942 |
// should not report as overridden. |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2943 |
if( basevtable[baseindex].first == __Q_OBJECT_METAOBJECT__ |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2944 |
|| basevtable[baseindex].first == __Q_OBJECT_METACALL__ |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2945 |
|| basevtable[baseindex].first == __Q_OBJECT_METACAST__ ) |
| 0 | 2946 |
{
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2947 |
} |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2948 |
else if(ClassIsDerivable(baseline)) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2949 |
{//This is a new overwrite and we should report this if the class is derivable
|
| 0 | 2950 |
if (report) |
2951 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2952 |
AddIssue<EIssueIdentityVirtualFunction,EIssueTypeNewOverride>(¤tmethod, currentmethod, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2953 |
lineNo,issueLoc); |
| 0 | 2954 |
} |
2955 |
++ret; |
|
2956 |
} |
|
2957 |
} |
|
2958 |
else |
|
2959 |
{
|
|
2960 |
//This method really modifies the primary vtable |
|
2961 |
// If you also want to find out if this function overrides entry in vtable of non-primary base |
|
2962 |
// then generate virtual table for them and search for the function signature from them |
|
2963 |
if (report) |
|
2964 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2965 |
AddIssue<EIssueIdentityVirtualFunction,EIssueTypeAddition>(¤tmethod, currentmethod, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2966 |
lineNo,issueLoc); |
| 0 | 2967 |
} |
2968 |
++ret; |
|
2969 |
} |
|
2970 |
} |
|
2971 |
} |
|
2972 |
return ret; |
|
2973 |
} |
|
2974 |
||
2975 |
// ---------------------------------------------------------------------------- |
|
2976 |
// ClassNodeAnalysis::compareBaseSizes |
|
2977 |
// ---------------------------------------------------------------------------- |
|
2978 |
// |
|
2979 |
int ClassNodeAnalysis::compareBaseSizes(HANodeIterator baseline, HANodeIterator current, const NodeIndex::dtable_t& bfields, const NodeIndex::dtable_t& cfields, bool report) |
|
2980 |
{
|
|
2981 |
int ret = 0; |
|
2982 |
||
2983 |
if ( ClassIsDerivable(baseline) ) |
|
2984 |
{
|
|
2985 |
int bbasesize = ClassBaseSize(baseline,bfields); |
|
2986 |
int cbasesize = ClassBaseSize(current,cfields); |
|
2987 |
||
2988 |
if ( (bbasesize) != (cbasesize) ) |
|
2989 |
{
|
|
2990 |
int lineNo = 0; |
|
2991 |
const XMLCh* lineNumber = current.GetAttribute(KXMLLineString); |
|
2992 |
lineNo = atoi(toString(lineNumber).c_str()); |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2993 |
string issueLoc; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2994 |
const XMLCh* fnameNode = current.GetAttribute(KXMLFileIdString); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2995 |
if(fnameNode != NULL) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2996 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2997 |
HANodeIterator fileNode(current); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2998 |
bool retval = fileNode.FindNodeById(fnameNode); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
2999 |
issueLoc = toString(fileNode.GetAttribute(KXMLNameString)); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3000 |
} |
| 0 | 3001 |
++ret; |
3002 |
if (report) |
|
3003 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3004 |
AddIssueClass<EIssueTypeBaseSize>(&baseline,iIdentity, current,lineNo,issueLoc); |
| 0 | 3005 |
} |
3006 |
} |
|
3007 |
} |
|
3008 |
return ret; |
|
3009 |
} |
|
3010 |
||
3011 |
// ---------------------------------------------------------------------------- |
|
3012 |
// ClassNodeAnalysis::compareClassMembers |
|
3013 |
// ---------------------------------------------------------------------------- |
|
3014 |
// |
|
3015 |
int ClassNodeAnalysis::compareClassMembers(HANodeIterator baseline,HANodeIterator current, bool report) |
|
3016 |
{
|
|
3017 |
int ret = 0; |
|
3018 |
//Base material |
|
3019 |
vector<DOMNode*> bvirtualMethods; |
|
3020 |
vector<DOMNode*> binlineMethods; |
|
3021 |
vector<DOMNode*> bexportedMethods; |
|
3022 |
vector<DOMNode*> bexportedvirtualMethods; |
|
3023 |
vector<DOMNode*> bmethods; |
|
3024 |
vector<DOMNode*> bfields; |
|
3025 |
vector<DOMNode*> bothers; |
|
3026 |
||
3027 |
//Current material |
|
3028 |
vector<DOMNode*> cvirtualMethods; |
|
3029 |
vector<DOMNode*> cinlineMethods; |
|
3030 |
vector<DOMNode*> cexportedMethods; |
|
3031 |
vector<DOMNode*> cexportedvirtualMethods; |
|
3032 |
vector<DOMNode*> cmethods; |
|
3033 |
vector<DOMNode*> cfields; |
|
3034 |
vector<DOMNode*> cothers; |
|
3035 |
||
3036 |
//Reserve some space for efficiency |
|
3037 |
bvirtualMethods.reserve(10); |
|
3038 |
bexportedMethods.reserve(10); |
|
3039 |
bmethods.reserve(10); |
|
3040 |
bfields.reserve(10); |
|
3041 |
bothers.reserve(10); |
|
3042 |
||
3043 |
cvirtualMethods.reserve(10); |
|
3044 |
cexportedMethods.reserve(10); |
|
3045 |
cmethods.reserve(10); |
|
3046 |
cfields.reserve(10); |
|
3047 |
cothers.reserve(10); |
|
3048 |
||
3049 |
//Order members |
|
3050 |
ClassOrderMembers(baseline,bvirtualMethods,binlineMethods,bexportedMethods,bexportedvirtualMethods,bmethods,bfields,bothers); |
|
3051 |
ClassOrderMembers(current,cvirtualMethods,cinlineMethods,cexportedMethods,cexportedvirtualMethods,cmethods,cfields,cothers); |
|
3052 |
||
3053 |
//Virtual functions |
|
3054 |
ret += compareVirtualFunctions(baseline, current, bvirtualMethods, cvirtualMethods, report); |
|
3055 |
||
3056 |
//if ( baseline.CheckForBooleanAttribute(KXMLBBCVirtualString) ) |
|
3057 |
//{
|
|
3058 |
//ret += compareExportedVirtualFunctions(baseline, current, bexportedvirtualMethods, cexportedvirtualMethods, report); |
|
3059 |
//}else if ( current.CheckForBooleanAttribute(KXMLBBCVirtualString) ) |
|
3060 |
//{
|
|
3061 |
//The class has changed from non-dynamic class to dynamic class |
|
3062 |
//Do we need to report something? |
|
3063 |
//} |
|
3064 |
||
3065 |
//Exported methods |
|
3066 |
ret += compareNonvirtualFunctions(baseline,current,bexportedMethods,cexportedMethods,EIssueIdentityExportedFunction,report); |
|
3067 |
||
3068 |
//Inlined methods |
|
3069 |
ret += compareNonvirtualFunctions(baseline, current, binlineMethods, cinlineMethods,EIssueIdentityInlineFunction, report); |
|
3070 |
||
3071 |
//Fields |
|
3072 |
ret += compareFields(baseline,current,bfields, cfields, report); |
|
3073 |
||
3074 |
//Others |
|
3075 |
ret += compareOthers(baseline, current, bothers, cothers, report); |
|
3076 |
||
3077 |
return ret; |
|
3078 |
} |
|
3079 |
||
3080 |
// ---------------------------------------------------------------------------- |
|
3081 |
// ClassNodeAnalysis::compareBases |
|
3082 |
// ---------------------------------------------------------------------------- |
|
3083 |
// |
|
3084 |
int ClassNodeAnalysis::compareBases(HANodeIterator baseline,HANodeIterator current,bool report) |
|
3085 |
{
|
|
3086 |
//Check base classes |
|
3087 |
int ret = 0; |
|
3088 |
||
3089 |
DOMNodeList* baselinechilds = baseline.GetElementsByTagName(KXMLBaseString); |
|
3090 |
DOMNodeList* currentchilds = current.GetElementsByTagName(KXMLBaseString); |
|
3091 |
||
3092 |
XMLSize_t baselinechildcount = baselinechilds->getLength(); |
|
3093 |
XMLSize_t currentchildcount = currentchilds->getLength(); |
|
3094 |
||
3095 |
int lineNo = 0; |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3096 |
string issueLoc; |
| 0 | 3097 |
const XMLCh* lineNumber = current.GetAttribute(KXMLLineString); |
3098 |
lineNo = atoi(toString(lineNumber).c_str()); |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3099 |
const XMLCh* fnameNode = current.GetAttribute(KXMLFileIdString); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3100 |
if(fnameNode!= NULL) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3101 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3102 |
HANodeIterator fileNode(current); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3103 |
bool retval = fileNode.FindNodeById(fnameNode); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3104 |
issueLoc = toString(fileNode.GetAttribute(KXMLNameString)); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3105 |
} |
| 0 | 3106 |
if ( baselinechildcount == currentchildcount ) |
3107 |
{
|
|
3108 |
unsigned int i = 0; |
|
3109 |
for (i = 0; i < baselinechildcount; ++i) |
|
3110 |
{
|
|
3111 |
HANodeIterator baselineit(baseline); |
|
3112 |
HANodeIterator currentit(current); |
|
3113 |
baselineit.current = baselinechilds->item(i); |
|
3114 |
||
3115 |
HANodeIterator basenameit(baseline); |
|
3116 |
basenameit.FindNodeById(baselineit.GetAttribute(KXMLTypeString)); |
|
3117 |
string basename( GenerateFullyQualifiedName(basenameit) ); |
|
3118 |
||
3119 |
unsigned int ii = 0; |
|
3120 |
for (ii = 0; ii < currentchildcount; ++ii) |
|
3121 |
{
|
|
3122 |
currentit.current = currentchilds->item(ii); |
|
3123 |
||
3124 |
HANodeIterator currentnameit(current); |
|
3125 |
currentnameit.FindNodeById(currentit.GetAttribute(KXMLTypeString)); |
|
3126 |
string currentname( GenerateFullyQualifiedName(currentnameit) ); |
|
3127 |
if ( basename == currentname ) |
|
3128 |
{
|
|
3129 |
if ( basenameit.CheckForBooleanAttribute(KXMLBBCVirtualString) ) |
|
3130 |
{
|
|
3131 |
||
3132 |
const NodeIndex::vtable_t& basevtable = ClassGenerateVirtualTable(basenameit); |
|
3133 |
const NodeIndex::vtable_t& currentvtable = ClassGenerateVirtualTable(currentnameit); |
|
3134 |
||
3135 |
if ( 0 != compareVirtualTables(basenameit,currentnameit,basevtable,currentvtable,report) ) |
|
3136 |
{
|
|
3137 |
string vtablename = "["; |
|
3138 |
vtablename += basename; |
|
3139 |
vtablename += "-vtable]"; |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3140 |
AddIssue<EIssueIdentityVirtualTable,EIssueTypeChange>(&baseline, current, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3141 |
lineNo, issueLoc,NULL, vtablename); |
| 0 | 3142 |
} |
3143 |
||
3144 |
} |
|
3145 |
if ( |
|
3146 |
!Equals( baselineit.GetAttribute(KXMLVirtualString), currentit.GetAttribute(KXMLVirtualString)) ) |
|
3147 |
{
|
|
3148 |
//Virtuality differs |
|
3149 |
if (report) |
|
3150 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3151 |
AddIssueClass<EIssueTypeInheritance>(&baseline,iIdentity, current,lineNo,issueLoc); |
| 0 | 3152 |
} |
3153 |
++ret; |
|
3154 |
} |
|
3155 |
||
3156 |
if ( !Equals( baselineit.GetAttribute(KXMLOffsetString), currentit.GetAttribute(KXMLOffsetString)) ) |
|
3157 |
{
|
|
3158 |
if (report) |
|
3159 |
{
|
|
3160 |
string subobjectname = "[" + basename; |
|
3161 |
subobjectname += "]"; |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3162 |
AddIssue<EIssueIdentitySubobject,EIssueTypeOffset>(&baseline,current,lineNo, |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3163 |
issueLoc,NULL,subobjectname); |
| 0 | 3164 |
} |
3165 |
++ret; |
|
3166 |
} |
|
3167 |
break; |
|
3168 |
} |
|
3169 |
} |
|
3170 |
if ( currentchildcount == ii ) |
|
3171 |
{
|
|
3172 |
if (report) |
|
3173 |
{
|
|
3174 |
//AddIssueClass<EIssueTypeInheritance>(&baseline,iIdentity, current); |
|
3175 |
//base class removed from inheritance |
|
3176 |
string subobjectname = "[" + basename; |
|
3177 |
subobjectname += "]"; |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3178 |
AddIssue<EIssueIdentitySubobject,EIssueTypeRemoval>(&baseline,current,lineNo,issueLoc,NULL,subobjectname); |
| 0 | 3179 |
} |
3180 |
++ret; |
|
3181 |
} |
|
3182 |
} |
|
3183 |
} else |
|
3184 |
{
|
|
3185 |
//Different amount of bases |
|
3186 |
if (report) |
|
3187 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3188 |
AddIssueClass<EIssueTypeInheritance>(&baseline,iIdentity, current,lineNo,issueLoc); |
| 0 | 3189 |
} |
3190 |
++ret; |
|
3191 |
||
3192 |
//check if a base class is removed from inheritance |
|
3193 |
unsigned int i = 0; |
|
3194 |
for (i = 0; i < baselinechildcount; ++i) |
|
3195 |
{
|
|
3196 |
HANodeIterator baselineit(baseline); |
|
3197 |
HANodeIterator currentit(current); |
|
3198 |
baselineit.current = baselinechilds->item(i); |
|
3199 |
||
3200 |
HANodeIterator basenameit(baseline); |
|
3201 |
basenameit.FindNodeById(baselineit.GetAttribute(KXMLTypeString)); |
|
3202 |
string basename( GenerateFullyQualifiedName(basenameit) ); |
|
3203 |
||
3204 |
unsigned int ii = 0; |
|
3205 |
for (ii = 0; ii < currentchildcount; ++ii) |
|
3206 |
{
|
|
3207 |
currentit.current = currentchilds->item(ii); |
|
3208 |
||
3209 |
HANodeIterator currentnameit(current); |
|
3210 |
currentnameit.FindNodeById(currentit.GetAttribute(KXMLTypeString)); |
|
3211 |
||
3212 |
string currentname( GenerateFullyQualifiedName(currentnameit) ); |
|
3213 |
if ( basename == currentname ) |
|
3214 |
{
|
|
3215 |
break; |
|
3216 |
} |
|
3217 |
} |
|
3218 |
if ( currentchildcount == ii ) |
|
3219 |
{
|
|
3220 |
if (report) |
|
3221 |
{
|
|
3222 |
string subobjectname = "[" + basename; |
|
3223 |
subobjectname += "]"; |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3224 |
AddIssue<EIssueIdentitySubobject,EIssueTypeRemoval>(&baseline,current,lineNo,issueLoc,NULL,subobjectname); |
| 0 | 3225 |
} |
3226 |
++ret; |
|
3227 |
} |
|
3228 |
} |
|
3229 |
} |
|
3230 |
||
3231 |
return ret; |
|
3232 |
||
3233 |
} |
|
3234 |
||
3235 |
// ---------------------------------------------------------------------------- |
|
3236 |
// ClassNodeAnalysis::ClassNodeAnalysis |
|
3237 |
// ---------------------------------------------------------------------------- |
|
3238 |
// |
|
3239 |
ClassNodeAnalysis::ClassNodeAnalysis() |
|
3240 |
: iReportAddedMembers(false), |
|
3241 |
iIdentity(EIssueIdentityClass) |
|
3242 |
{
|
|
3243 |
} |
|
3244 |
||
3245 |
||
3246 |
// ---------------------------------------------------------------------------- |
|
3247 |
// ClassNodeAnalysis::Construct |
|
3248 |
// ---------------------------------------------------------------------------- |
|
3249 |
// |
|
3250 |
NodeAnalysis* ClassNodeAnalysis::Construct() |
|
3251 |
{
|
|
3252 |
return new ClassNodeAnalysis; |
|
3253 |
} |
|
3254 |
||
3255 |
// ---------------------------------------------------------------------------- |
|
3256 |
// ClassNodeAnalysis::FindNodeAndAnalyse |
|
3257 |
// ---------------------------------------------------------------------------- |
|
3258 |
// |
|
3259 |
int ClassNodeAnalysis::FindNodeAndAnalyse(HANodeIterator baseline,HANodeIterator current) |
|
3260 |
{
|
|
3261 |
if ( baseline.CheckForBooleanAttribute(KXMIncompleteString) ) |
|
3262 |
{
|
|
3263 |
return 0; |
|
3264 |
} |
|
3265 |
||
3266 |
DOMNode* node = NodeAnalysis::findNode(baseline,current); |
|
3267 |
if ( !node ) |
|
3268 |
{
|
|
3269 |
//AddIssue<>(&baseline,EIssue_class_removal); |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3270 |
AddIssue<EIssueIdentityClass,EIssueTypeRemoval>(&baseline, baseline,0,""); |
| 0 | 3271 |
return 1; |
3272 |
} |
|
3273 |
current.current = node; |
|
3274 |
||
3275 |
return this->Analyse(baseline,current); |
|
3276 |
} |
|
3277 |
||
3278 |
// ---------------------------------------------------------------------------- |
|
3279 |
// ClassNodeAnalysis::Analyse |
|
3280 |
// ---------------------------------------------------------------------------- |
|
3281 |
// |
|
3282 |
int ClassNodeAnalysis::Analyse(HANodeIterator baseline,HANodeIterator current, bool report) |
|
3283 |
{
|
|
3284 |
//ASSERTS |
|
3285 |
int ret=0; |
|
3286 |
short nodetype = baseline->getNodeType(); |
|
3287 |
assert(nodetype == DOMNode::ELEMENT_NODE); |
|
3288 |
nodetype = current->getNodeType(); |
|
3289 |
assert(nodetype == DOMNode::ELEMENT_NODE); |
|
3290 |
int lineNo = 0; |
|
3291 |
const XMLCh* lineNumber = current.GetAttribute(KXMLLineString); |
|
3292 |
lineNo = atoi(toString(lineNumber).c_str()); |
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3293 |
string issueLoc; |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3294 |
const XMLCh* fnameNode = current.GetAttribute(KXMLFileIdString); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3295 |
if( fnameNode!= NULL) |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3296 |
{
|
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3297 |
HANodeIterator fileNode(current); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3298 |
bool retval = fileNode.FindNodeById(fnameNode); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3299 |
issueLoc =toString(fileNode.GetAttribute(KXMLNameString)); |
|
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3300 |
} |
| 0 | 3301 |
|
3302 |
const XMLCh* baseanalysisstatus = baseline.GetAttribute(KXMLBBCAnalysisStatus); |
|
3303 |
||
3304 |
if (baseanalysisstatus) |
|
3305 |
{
|
|
3306 |
if ( Equals(baseanalysisstatus,KXMLBBCAnalysisStatusAnalysing) ) |
|
3307 |
{
|
|
3308 |
//We are analysing recursively, should not happen |
|
3309 |
assert(false); |
|
3310 |
} |
|
3311 |
else if ( Equals(baseanalysisstatus,KXMLBBCAnalysisStatusClean) ) |
|
3312 |
{
|
|
3313 |
return 0; |
|
3314 |
} |
|
3315 |
||
3316 |
if (!report) |
|
3317 |
{
|
|
3318 |
return 1; |
|
3319 |
} |
|
3320 |
} |
|
3321 |
||
3322 |
||
3323 |
baseline.SetAttribute(KXMLBBCAnalysisStatus,KXMLBBCAnalysisStatusAnalysing); |
|
3324 |
||
3325 |
bool bincomplete = baseline.CheckForBooleanAttribute(KXMIncompleteString); |
|
3326 |
bool cincomplete = current.CheckForBooleanAttribute(KXMIncompleteString); |
|
3327 |
||
3328 |
// Check if either baseline or current node is of incomplete type. |
|
3329 |
// Type is incomplete if the type is just forward declared or the |
|
3330 |
// analysed header file can be compiled without resolving the details |
|
3331 |
// of the type. This kind of situation occurs for example when only |
|
3332 |
// a reference or pointer to the class is used in the analyzed header, |
|
3333 |
// and the class is declared in other header file. |
|
3334 |
// |
|
3335 |
// If the type is incomplete, we cannot compare the nodes. |
|
3336 |
if ( bincomplete || cincomplete ) |
|
3337 |
{
|
|
3338 |
if ( bincomplete && cincomplete ) |
|
3339 |
{
|
|
3340 |
ret = 0; |
|
3341 |
} |
|
3342 |
else if (bincomplete) |
|
3343 |
{
|
|
3344 |
ret = 0; |
|
3345 |
} |
|
3346 |
else |
|
3347 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3348 |
AddIssueClass<EIssueTypeNotAnalysed>(&baseline,iIdentity, baseline,0,issueLoc); |
| 0 | 3349 |
ret = 1; |
3350 |
} |
|
3351 |
} |
|
3352 |
else |
|
3353 |
{
|
|
3354 |
// Check that the access level of the current node has not been changed |
|
3355 |
// to more restricted. |
|
3356 |
if (!CheckAccessModifier(baseline,current)) |
|
3357 |
{
|
|
3358 |
if (report) |
|
3359 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3360 |
AddIssueClass<EIssueTypeAccess>(&baseline,iIdentity, current,lineNo,issueLoc); |
| 0 | 3361 |
} |
3362 |
ret += 1; |
|
3363 |
} |
|
3364 |
||
3365 |
||
3366 |
// Check if the class has virtual bases |
|
3367 |
if ( baseline.CheckForBooleanAttribute(KXMLBBCVirtualInheritanceString) ) |
|
3368 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3369 |
AddIssueClass<EIssueTypeVirtualBases>(&baseline,iIdentity, current,lineNo,issueLoc); |
| 0 | 3370 |
++ret; |
3371 |
} |
|
3372 |
||
3373 |
if ( current.CheckForBooleanAttribute(KXMLBBCVirtualInheritanceString) ) |
|
3374 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3375 |
AddIssueClass<EIssueTypeVirtualBases>(¤t,iIdentity, current,lineNo,issueLoc); |
| 0 | 3376 |
++ret; |
3377 |
} |
|
3378 |
||
3379 |
// Check if the class is istantiable or derivable |
|
3380 |
if ( ClassIsInstantiable(baseline) || (ClassIsDerivable(baseline) && EIssueIdentityUnion != iIdentity) ) |
|
3381 |
{
|
|
3382 |
||
3383 |
if ( !CompareAttributes(baseline,current,KXMLAlignString,ESimpleAttribute) ) |
|
3384 |
{
|
|
3385 |
if (report) |
|
3386 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3387 |
AddIssueClass<EIssueTypeAlign>(&baseline,iIdentity, current,lineNo,issueLoc); |
| 0 | 3388 |
iReportAddedMembers = true; |
3389 |
} |
|
3390 |
ret += 1; |
|
3391 |
} |
|
3392 |
||
3393 |
if ( !CompareAttributes(baseline,current,KXMLSizeString,ESimpleAttribute) ) |
|
3394 |
{
|
|
3395 |
if (report) |
|
3396 |
{
|
|
|
3
ebe3f8f03b59
Compatibility Analyser updated to version 2.8.4. Support for Qt code analysis added.
noe\swadi
parents:
0
diff
changeset
|
3397 |
AddIssueClass<EIssueTypeSize>(&baseline,iIdentity, current,lineNo,issueLoc); |
| 0 | 3398 |
iReportAddedMembers = true; |
3399 |
} |
|
3400 |
ret += 1; |
|
3401 |
} |
|
3402 |
} |
|
3403 |
//ret += compareBaseSizes(baseline,current,report); |
|
3404 |
ret += compareClassMembers(baseline,current,report); |
|
3405 |
ret += compareBases(baseline,current,report); |
|
3406 |
} |
|
3407 |
||
3408 |
if ( ret == 0 ) |
|
3409 |
{
|
|
3410 |
baseline.SetAttribute(KXMLBBCAnalysisStatus,KXMLBBCAnalysisStatusClean); |
|
3411 |
} else |
|
3412 |
{
|
|
3413 |
baseline.SetAttribute(KXMLBBCAnalysisStatus,KXMLBBCAnalysisStatusIssues); |
|
3414 |
} |
|
3415 |
||
3416 |
return ret; |
|
3417 |
} |
|
3418 |
||
3419 |
//////////////////////////////////////////////////////////////////////////////////////// |
|
3420 |
///////////////////////////////StructNodeAnalysis/////////////////////////////////////// |
|
3421 |
||
3422 |
// ---------------------------------------------------------------------------- |
|
3423 |
// StructNodeAnalysis::Construct |
|
3424 |
// ---------------------------------------------------------------------------- |
|
3425 |
// |
|
3426 |
NodeAnalysis* StructNodeAnalysis::Construct() |
|
3427 |
{
|
|
3428 |
return new StructNodeAnalysis; |
|
3429 |
} |
|
3430 |
||
3431 |
// ---------------------------------------------------------------------------- |
|
3432 |
// StructNodeAnalysis::StructNodeAnalysis |
|
3433 |
// ---------------------------------------------------------------------------- |
|
3434 |
// |
|
3435 |
StructNodeAnalysis::StructNodeAnalysis() |
|
3436 |
{
|
|
3437 |
iIdentity = EIssueIdentityStruct; |
|
3438 |
} |
|
3439 |
//////////////////////////////////////////////////////////////////////////////////////// |
|
3440 |