Kaydet (Commit) 85cf4d25 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:mergeclasses fix ignoring some stuff

Seems that calling getCanonicalDecl here results in us sometimes picking
up forward-decl's, which hides stuff

Also make the python processing code spit out a message if I manage to
mess up the log files

Change-Id: I08bf50eb26cf463c126507b51535b0a0fc9f7ecf
üst 0d7193bd
...@@ -35,6 +35,8 @@ with io.open("workdir/loplugin.countusersofdefaultparams.log", "rb", buffering=1 ...@@ -35,6 +35,8 @@ with io.open("workdir/loplugin.countusersofdefaultparams.log", "rb", buffering=1
if not funcInfo in callDict: if not funcInfo in callDict:
callDict[funcInfo] = set() callDict[funcInfo] = set()
callDict[funcInfo].add(sourceLocationOfCall) callDict[funcInfo].add(sourceLocationOfCall)
else:
print( "unknown line: " + line)
# Invert the definitionToSourceLocationMap. # Invert the definitionToSourceLocationMap.
sourceLocationToDefinitionMap = {} sourceLocationToDefinitionMap = {}
......
...@@ -29,6 +29,9 @@ with open("workdir/loplugin.finalclasses.log") as txt: ...@@ -29,6 +29,9 @@ with open("workdir/loplugin.finalclasses.log") as txt:
parent = parent[7:] parent = parent[7:]
inheritFromSet.add(parent); inheritFromSet.add(parent);
else:
print( "unknown line: " + line)
tmpset = set() tmpset = set()
for clazz in sorted(definitionSet - inheritFromSet): for clazz in sorted(definitionSet - inheritFromSet):
file = definitionToFileDict[clazz] file = definitionToFileDict[clazz]
......
...@@ -148,7 +148,7 @@ bool MergeClasses::VisitCXXRecordDecl(const CXXRecordDecl* decl) ...@@ -148,7 +148,7 @@ bool MergeClasses::VisitCXXRecordDecl(const CXXRecordDecl* decl)
} }
if (decl->isThisDeclarationADefinition()) if (decl->isThisDeclarationADefinition())
{ {
SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(decl->getCanonicalDecl()->getLocStart()); SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(decl->getLocStart());
std::string filename = compiler.getSourceManager().getFilename(spellingLocation); std::string filename = compiler.getSourceManager().getFilename(spellingLocation);
filename = filename.substr(strlen(SRCDIR)); filename = filename.substr(strlen(SRCDIR));
std::string s = decl->getQualifiedNameAsString(); std::string s = decl->getQualifiedNameAsString();
......
...@@ -56,6 +56,7 @@ def extractModuleName(clazz): ...@@ -56,6 +56,7 @@ def extractModuleName(clazz):
with open("compilerplugins/clang/mergeclasses.results", "wt") as f: with open("compilerplugins/clang/mergeclasses.results", "wt") as f:
# loop over defined, but not instantiated classes # loop over defined, but not instantiated classes
for clazz in sorted(definitionSet - instantiatedSet): for clazz in sorted(definitionSet - instantiatedSet):
if clazz == "svl::IUndoManager": print parentChildDict[clazz]
# ignore classes without any children, and classes with more than one child # ignore classes without any children, and classes with more than one child
if (clazz not in parentChildDict) or (len(parentChildDict[clazz]) != 1): if (clazz not in parentChildDict) or (len(parentChildDict[clazz]) != 1):
continue continue
...@@ -68,6 +69,8 @@ with open("compilerplugins/clang/mergeclasses.results", "wt") as f: ...@@ -68,6 +69,8 @@ with open("compilerplugins/clang/mergeclasses.results", "wt") as f:
if ("mutex" in clazz) or ("Mutex" in clazz): if ("mutex" in clazz) or ("Mutex" in clazz):
continue continue
otherclazz = next(iter(parentChildDict[clazz])) otherclazz = next(iter(parentChildDict[clazz]))
if clazz == "svl::IUndoManager": print extractModuleName(clazz)
if clazz == "svl::IUndoManager": print extractModuleName(otherclazz)
# exclude combinations that span modules because we often use those to make cross-module dependencies more manageable. # exclude combinations that span modules because we often use those to make cross-module dependencies more manageable.
if extractModuleName(clazz) != extractModuleName(otherclazz): if extractModuleName(clazz) != extractModuleName(otherclazz):
continue continue
......
...@@ -34,6 +34,8 @@ with io.open("workdir/loplugin.singlevalfields.log", "rb", buffering=1024*1024) ...@@ -34,6 +34,8 @@ with io.open("workdir/loplugin.singlevalfields.log", "rb", buffering=1024*1024)
if not fieldInfo in fieldAssignDict: if not fieldInfo in fieldAssignDict:
fieldAssignDict[fieldInfo] = set() fieldAssignDict[fieldInfo] = set()
fieldAssignDict[fieldInfo].add(assignValue) fieldAssignDict[fieldInfo].add(assignValue)
else:
print( "unknown line: " + line)
tmp1list = list() tmp1list = list()
for fieldInfo, assignValues in fieldAssignDict.iteritems(): for fieldInfo, assignValues in fieldAssignDict.iteritems():
......
...@@ -20,7 +20,9 @@ with io.open("workdir/loplugin.virtualdown.log", "rb", buffering=1024*1024) as t ...@@ -20,7 +20,9 @@ with io.open("workdir/loplugin.virtualdown.log", "rb", buffering=1024*1024) as t
elif tokens[0] == "call:": elif tokens[0] == "call:":
fullMethodName = tokens[1] fullMethodName = tokens[1]
callSet.add(fullMethodName) callSet.add(fullMethodName)
else:
print( "unknown line: " + line)
unnecessaryVirtualSet = set() unnecessaryVirtualSet = set()
for clazz in (definitionSet - callSet): for clazz in (definitionSet - callSet):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment