compilerplugins/clang/constantparam.py                   |    8 +++----
 compilerplugins/clang/expandablemethods.py               |    2 -
 compilerplugins/clang/fieldcanbelocal.py                 |    2 -
 compilerplugins/clang/fieldcast.py                       |    2 -
 compilerplugins/clang/finalclasses.py                    |    2 -
 compilerplugins/clang/methodcycles.py                    |   14 ++++++-------
 compilerplugins/clang/pahole-all-classes.py              |    4 +--
 compilerplugins/clang/singlevalfields.py                 |    4 +--
 compilerplugins/clang/store/constfields.py               |    2 -
 compilerplugins/clang/store/countusersofdefaultparams.py |    4 +--
 compilerplugins/clang/store/inlinefields.py              |    4 +--
 compilerplugins/clang/unusedenumconstants.py             |   10 ++++-----
 compilerplugins/clang/unusedfields.py                    |   16 +++++++--------
 compilerplugins/clang/unusedmethods.py                   |   10 ++++-----
 compilerplugins/clang/unusedvarsglobal.py                |    2 -
 compilerplugins/clang/virtualdead.py                     |    6 ++---
 16 files changed, 46 insertions(+), 46 deletions(-)

New commits:
commit 52b08068c90875ec5fd55ddea5662695216611b2
Author:     Leonard Sasse <l.sa...@fz-juelich.de>
AuthorDate: Thu Mar 28 09:53:29 2024 +0100
Commit:     Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>
CommitDate: Tue May 21 11:40:31 2024 +0200

    tdf#158803 compilerplugins: remove semicolons; improve membership checks
    
    Change-Id: Ifd5fdee23e5adba2b5a667f74c38ba6fb28f54b4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165446
    Tested-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>
    Tested-by: Jenkins
    Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>

diff --git a/compilerplugins/clang/constantparam.py 
b/compilerplugins/clang/constantparam.py
index 3df25994c3f5..d2d33087a4c9 100755
--- a/compilerplugins/clang/constantparam.py
+++ b/compilerplugins/clang/constantparam.py
@@ -13,7 +13,7 @@ def normalizeTypeParams( line ):
 
 # reading as binary (since we known it is pure ascii) is much faster than 
reading as unicode
 with io.open("workdir/loplugin.constantparam.log", "r") as txt:
-    line_no = 1;
+    line_no = 1
     try:
         for line in txt:
             tokens = line.strip().split("      ")
@@ -26,7 +26,7 @@ with io.open("workdir/loplugin.constantparam.log", "r") as 
txt:
             paramType = normalizeTypeParams(tokens[4])
             callValue = tokens[5]
             callInfo = (returnType, nameAndParams, paramName, paramType, 
sourceLocation)
-            if not callInfo in callDict:
+            if callInfo not in callDict:
                 callDict[callInfo] = set()
             callDict[callInfo].add(callValue)
             line_no += 1
@@ -151,8 +151,8 @@ for callInfo, callValues in iter(callDict.items()):
     if len(callValues) < 2:
         continue
     # we are only interested in enum parameters
-    if not "enum" in callInfo[3]: continue
-    if not "Flag" in callInfo[3] and not "flag" in callInfo[3] and not "Bit" 
in callInfo[3] and not "State" in callInfo[3]: continue
+    if "enum" not in callInfo[3]: continue
+    if "Flag" not in callInfo[3] and "flag" not in callInfo[3] and "Bit" not 
in callInfo[3] and "State" not in callInfo[3]: continue
     # try to ignore setter methods
     if ("," not in nameAndParams) and (("::set" in nameAndParams) or ("::Set" 
in nameAndParams)):
         continue
diff --git a/compilerplugins/clang/expandablemethods.py 
b/compilerplugins/clang/expandablemethods.py
index 707215f96828..0ec4be9fa667 100755
--- a/compilerplugins/clang/expandablemethods.py
+++ b/compilerplugins/clang/expandablemethods.py
@@ -40,7 +40,7 @@ with io.open("workdir/loplugin.expandablemethods.log", "rb", 
buffering=1024*1024
             returnType = tokens[2]
             nameAndParams = tokens[3]
             funcInfo = (normalizeTypeParams(returnType), 
normalizeTypeParams(nameAndParams))
-            if not funcInfo in calledFromDict:
+            if funcInfo not in calledFromDict:
                 calledFromDict[funcInfo] = set()
             calledFromDict[funcInfo].add(calleeLocation)
         elif tokens[0] == "outside:":
diff --git a/compilerplugins/clang/fieldcanbelocal.py 
b/compilerplugins/clang/fieldcanbelocal.py
index 3266574445c5..f5307e710851 100755
--- a/compilerplugins/clang/fieldcanbelocal.py
+++ b/compilerplugins/clang/fieldcanbelocal.py
@@ -54,7 +54,7 @@ with io.open("workdir/loplugin.fieldcanbelocal.log", "r", 
buffering=1024*1024) a
 
 outputSet = set()
 for d in definitionSet:
-    if not d in touchedMap:
+    if d not in touchedMap:
         continue
     fieldType = definitionToTypeMap[d]
     # ignore some types that are known false+
diff --git a/compilerplugins/clang/fieldcast.py 
b/compilerplugins/clang/fieldcast.py
index fc09063571ee..72640a361cd8 100755
--- a/compilerplugins/clang/fieldcast.py
+++ b/compilerplugins/clang/fieldcast.py
@@ -33,7 +33,7 @@ with io.open("workdir/loplugin.fieldcast.log", "r", 
buffering=1024*1024) as txt:
             definitionToTypeMap[fieldInfo] = fieldType
             definitionToSourceLocationMap[fieldInfo] = srcLoc
 
-            if not (fieldInfo in castMap):
+            if fieldInfo not in castMap:
                 castMap[fieldInfo] = castToType
             elif castMap[fieldInfo] != "": # if we are not ignoring it
                 # if it is cast to more than one type, mark it as being ignored
diff --git a/compilerplugins/clang/finalclasses.py 
b/compilerplugins/clang/finalclasses.py
index 5e9f25a24a51..55b3d1c5acb1 100755
--- a/compilerplugins/clang/finalclasses.py
+++ b/compilerplugins/clang/finalclasses.py
@@ -26,7 +26,7 @@ with open("workdir/loplugin.finalclasses.log") as txt:
                 parent = parent[6:]
             elif (parent.startswith("struct ")):
                 parent = parent[7:]
-            inheritFromSet.add(parent);
+            inheritFromSet.add(parent)
 
         else:
             print( "unknown line: " + line)
diff --git a/compilerplugins/clang/methodcycles.py 
b/compilerplugins/clang/methodcycles.py
index 5a1b731cc9d5..ddb72ec50db2 100755
--- a/compilerplugins/clang/methodcycles.py
+++ b/compilerplugins/clang/methodcycles.py
@@ -77,7 +77,7 @@ def remove_reachable(callDict, startCaller):
     worklist.append(startCaller)
     while len(worklist) > 0:
         caller = worklist.pop()
-        if not caller in callDict:
+        if caller not in callDict:
             continue
         calleeSet = callDict[caller]
         del callDict[caller]
@@ -92,9 +92,9 @@ to_be_removed.add("int main(int,char **)")
 # random dynload entrypoints that we don't otherwise find
 to_be_removed.add("bool TestImportOLE2(SvStream &)")
 to_be_removed.add("void SbiRuntime::StepREDIMP()")
-to_be_removed.add("_object * (anonymous 
namespace)::createUnoStructHelper(_object *,_object *,_object *)");
+to_be_removed.add("_object * (anonymous 
namespace)::createUnoStructHelper(_object *,_object *,_object *)")
 for caller in definitionSet:
-    if not caller in definitionToSourceLocationMap:
+    if caller not in definitionToSourceLocationMap:
         to_be_removed.append(caller)
         continue
     location = definitionToSourceLocationMap[caller]
@@ -161,7 +161,7 @@ def print_tree(f, callDict, caller, depth):
         return
     # when printing out trees, things that are not in the map are things that 
are reachable,
     # so we're not interested in them
-    if not caller in callDict:
+    if caller not in callDict:
         return
     print_tree_recurse_set.add(caller)
     f.write("  " * depth + caller + "
")
@@ -174,7 +174,7 @@ def print_tree(f, callDict, caller, depth):
 def dump_possible_roots():
     possibleRootList = list()
     for caller in callDict:
-        if not caller in inverseCallDict and caller in 
definitionToSourceLocationMap:
+        if caller not in inverseCallDict and caller in 
definitionToSourceLocationMap:
             possibleRootList.append(caller)
     possibleRootList.sort()
 
@@ -206,7 +206,7 @@ def print_cycles():
             # the code is still in use.
             for p in path:
                 for caller in inverseCallDict[p]:
-                    if not caller in path:
+                    if caller not in path:
                         return
             f.write("found cycle
")
             for p in path:
@@ -242,7 +242,7 @@ def print_partitions():
         to_be_removed.clear()
         for caller in callDict2:
             if len(callDict2[caller]) == 0 \
-                or not caller in inverseCallDict[caller]:
+                or caller not in inverseCallDict[caller]:
                 to_be_removed.add(caller)
         if len(to_be_removed) == 0:
             break
diff --git a/compilerplugins/clang/pahole-all-classes.py 
b/compilerplugins/clang/pahole-all-classes.py
index 4163adc6a8da..4990a01f2c79 100755
--- a/compilerplugins/clang/pahole-all-classes.py
+++ b/compilerplugins/clang/pahole-all-classes.py
@@ -56,7 +56,7 @@ def write_pahole_commands(classes):
 # to split them up, and that creates a mess in the parsing logic.
 def read_generator(gdbOutput):
     while True:
-        line = gdbOutput.readline();
+        line = gdbOutput.readline()
         if line == "": return # end of file
         line = line.decode('utf8').strip()
         print("gdb: " + line)
@@ -79,7 +79,7 @@ with open("compilerplugins/clang/pahole.results", "wt") as f:
     # This number is chosen to make gdb peak at around 8G.
     while len(classList) > 0:
 
-        currClassList = classList[0:500];
+        currClassList = classList[0:500]
         classList = classList[500:]
 
         gdbProc = subprocess.Popen("gdb", stdin=subprocess.PIPE, 
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
diff --git a/compilerplugins/clang/singlevalfields.py 
b/compilerplugins/clang/singlevalfields.py
index fe2f4697638f..43416b7e4016 100755
--- a/compilerplugins/clang/singlevalfields.py
+++ b/compilerplugins/clang/singlevalfields.py
@@ -35,7 +35,7 @@ with io.open("workdir/loplugin.singlevalfields.log", "r", 
buffering=1024*1024) a
             else:
                 assignValue = ""
             fieldInfo = (parentClass, fieldName)
-            if not fieldInfo in fieldAssignDict:
+            if fieldInfo not in fieldAssignDict:
                 fieldAssignDict[fieldInfo] = set()
             fieldAssignDict[fieldInfo].add(assignValue)
         else:
@@ -92,7 +92,7 @@ for fieldInfo, assignValues in fieldAssignDict.items():
     if len(assignValues) == 2:
         if "0" in assignValues and "1" in assignValues:
             fieldType = definitionToTypeMap[fieldInfo]
-            if not "_Bool" in fieldType and not "enum " in fieldType and not 
"boolean" in fieldType:
+            if "_Bool" not in fieldType and "enum " not in fieldType and 
"boolean" not in fieldType:
                 tmp2list.append((v0,v1,v2,fieldType))
     elif len(assignValues) == 1:
         # ignore timers/idles
diff --git a/compilerplugins/clang/store/constfields.py 
b/compilerplugins/clang/store/constfields.py
index 311b372bc958..ef3154d7b348 100755
--- a/compilerplugins/clang/store/constfields.py
+++ b/compilerplugins/clang/store/constfields.py
@@ -46,7 +46,7 @@ canBeConstFieldSet = set()
 for d in definitionSet:
     if d in writeFromOutsideConstructorSet:
         continue
-    srcLoc = definitionToSourceLocationMap[d];
+    srcLoc = definitionToSourceLocationMap[d]
     fieldType = definitionToTypeMap[d]
     if fieldType.startswith("const "):
         continue
diff --git a/compilerplugins/clang/store/countusersofdefaultparams.py 
b/compilerplugins/clang/store/countusersofdefaultparams.py
index 64ef6604af65..47334432401c 100755
--- a/compilerplugins/clang/store/countusersofdefaultparams.py
+++ b/compilerplugins/clang/store/countusersofdefaultparams.py
@@ -24,14 +24,14 @@ with 
io.open("workdir/loplugin.countusersofdefaultparams.log", "rb", buffering=1
             sourceLocation = tokens[4]
             funcInfo = normalizeTypeParams(returnType) + " " + 
normalizeTypeParams(nameAndParams)
             definitionToSourceLocationMap[funcInfo] = sourceLocation
-            if not funcInfo in callDict:
+            if funcInfo not in callDict:
                 callDict[funcInfo] = set()
         elif tokens[0] == "call:":
             returnType = tokens[1]
             nameAndParams = tokens[2]
             sourceLocationOfCall = tokens[3]
             funcInfo = normalizeTypeParams(returnType) + " " + 
normalizeTypeParams(nameAndParams)
-            if not funcInfo in callDict:
+            if funcInfo not in callDict:
                 callDict[funcInfo] = set()
             callDict[funcInfo].add(sourceLocationOfCall)
         else:
diff --git a/compilerplugins/clang/store/inlinefields.py 
b/compilerplugins/clang/store/inlinefields.py
index e569431d37f7..398eb5debeed 100755
--- a/compilerplugins/clang/store/inlinefields.py
+++ b/compilerplugins/clang/store/inlinefields.py
@@ -7,7 +7,7 @@ definitionToSourceLocationMap = dict() # dict of 
tuple(parentClass, fieldName) t
 definitionSet = set()
 excludedSet = set()
 deletedInDestructorSet = set()
-newedInConstructorSet = set();
+newedInConstructorSet = set()
 
 # clang does not always use exactly the same numbers in the type-parameter 
vars it generates
 # so I need to substitute them to ensure we can match correctly.
@@ -50,7 +50,7 @@ for d in definitionSet:
 #    if d in excludedSet or d not in deletedInDestructorSet or d not in 
newedInConstructorSet:
     if d in excludedSet or d not in newedInConstructorSet:
         continue
-    srcLoc = definitionToSourceLocationMap[d];
+    srcLoc = definitionToSourceLocationMap[d]
     tmp1list.append((d[0] + " " + d[1], srcLoc))
 
 # sort results by filename:lineno
diff --git a/compilerplugins/clang/unusedenumconstants.py 
b/compilerplugins/clang/unusedenumconstants.py
index ebceffca0234..795659c75001 100755
--- a/compilerplugins/clang/unusedenumconstants.py
+++ b/compilerplugins/clang/unusedenumconstants.py
@@ -45,8 +45,8 @@ with io.open("workdir/loplugin.unusedenumconstants.log", "r", 
buffering=1024*102
 def startswith_one_of( srcLoc, fileSet ):
     for f in fileSet:
         if srcLoc.startswith(f):
-            return True;
-    return False;
+            return True
+    return False
 
 def is_ignore(srcLoc):
     if startswith_one_of(srcLoc,
@@ -200,7 +200,7 @@ untouchedSet = set()
 for d in definitionSet:
     if d in readSet or d in writeSet:
         continue
-    srcLoc = definitionToSourceLocationMap[d];
+    srcLoc = definitionToSourceLocationMap[d]
     if (is_ignore(srcLoc)):
         continue
 
@@ -213,7 +213,7 @@ for d in writeSet:
     # can happen with stuff in workdir or external
     if d not in definitionSet:
         continue
-    srcLoc = definitionToSourceLocationMap[d];
+    srcLoc = definitionToSourceLocationMap[d]
     if (is_ignore(srcLoc)):
         continue
     writeonlySet.add((d[0] + " " + d[1], srcLoc))
@@ -225,7 +225,7 @@ for d in readSet:
     # can happen with stuff in workdir or external
     if d not in definitionSet:
         continue
-    srcLoc = definitionToSourceLocationMap[d];
+    srcLoc = definitionToSourceLocationMap[d]
     if (is_ignore(srcLoc)):
         continue
     readonlySet.add((d[0] + " " + d[1], srcLoc))
diff --git a/compilerplugins/clang/unusedfields.py 
b/compilerplugins/clang/unusedfields.py
index 131303442ef9..5863182d1ced 100755
--- a/compilerplugins/clang/unusedfields.py
+++ b/compilerplugins/clang/unusedfields.py
@@ -63,7 +63,7 @@ untouchedSetD = set()
 for d in definitionSet:
     if d in touchedFromOutsideSet or d in touchedFromInsideSet:
         continue
-    srcLoc = definitionToSourceLocationMap[d];
+    srcLoc = definitionToSourceLocationMap[d]
     # this is all representations of on-disk data structures
     if (srcLoc.startswith("sc/source/filter/inc/scflt.hxx")
         or srcLoc.startswith("sw/source/filter/ww8/")
@@ -105,7 +105,7 @@ onlyUsedInConstructorSet = set()
 for d in definitionSet:
     if d in touchedFromOutsideSet or d in touchedFromOutsideConstructorSet:
         continue
-    srcLoc = definitionToSourceLocationMap[d];
+    srcLoc = definitionToSourceLocationMap[d]
     # this is all representations of on-disk data structures
     if (srcLoc.startswith("sc/source/filter/inc/scflt.hxx")
         or srcLoc.startswith("sw/source/filter/ww8/")
@@ -138,10 +138,10 @@ for d in definitionSet:
 
 writeonlySet = set()
 for d in definitionSet:
-    parentClazz = d[0];
+    parentClazz = d[0]
     if d in readFromSet or d in untouchedSetD:
         continue
-    srcLoc = definitionToSourceLocationMap[d];
+    srcLoc = definitionToSourceLocationMap[d]
     # this is all representations of on-disk data structures
     if (srcLoc.startswith("sc/source/filter/inc/scflt.hxx")
         or srcLoc.startswith("sw/source/filter/ww8/")
@@ -193,11 +193,11 @@ for d in definitionSet:
 
 readonlySet = set()
 for d in definitionSet:
-    parentClazz = d[0];
+    parentClazz = d[0]
     if d in writeToSet or d in untouchedSetD:
         continue
     fieldType = definitionToTypeMap[d]
-    srcLoc = definitionToSourceLocationMap[d];
+    srcLoc = definitionToSourceLocationMap[d]
     if "ModuleClient" in fieldType:
         continue
     # this is all representations of on-disk data structures
@@ -226,7 +226,7 @@ for d in protectedAndPublicDefinitionSet:
     clazz = d[0] + " " + d[1]
     if d in touchedFromOutsideSet:
         continue
-    srcLoc = definitionToSourceLocationMap[d];
+    srcLoc = definitionToSourceLocationMap[d]
 
     canBePrivateSet.add((clazz + " " + definitionToTypeMap[d], srcLoc))
 
@@ -250,7 +250,7 @@ allFieldsCanBePrivateSet = set()
 for d in (potentialClasses - excludedClasses):
     sourceLoc = potentialClassesSourceLocationMap[d]
     # when the class is inside a compile unit, assume that the compiler can 
figure this out for itself, much less interesting to me
-    if not ".cxx" in sourceLoc:
+    if ".cxx" not in sourceLoc:
         allFieldsCanBePrivateSet.add((d, sourceLoc))
 
 # sort the results using a "natural order" so sequences like 
[item1,item2,item10] sort nicely
diff --git a/compilerplugins/clang/unusedmethods.py 
b/compilerplugins/clang/unusedmethods.py
index 9d8297f4935d..485647450c24 100755
--- a/compilerplugins/clang/unusedmethods.py
+++ b/compilerplugins/clang/unusedmethods.py
@@ -169,7 +169,7 @@ for d in definitionSet:
     # stuff generated by Qt
     if "::tr(" in method or "::trUtf8(" in method: continue
 
-    location = definitionToSourceLocationMap[d];
+    location = definitionToSourceLocationMap[d]
     # whacky template stuff
     if location.startswith("sc/source/ui/vba/vbaformat.hxx"): continue
     # not sure how this stuff is called
@@ -234,12 +234,12 @@ for d in definitionSet:
         continue
     # ignore lambdas
     if "::__invoke(" in d[1]:
-        continue;
+        continue
     if "(lambda at " in d[1]:
-        continue;
+        continue
     if "::operator " in d[1] and "(*)(" in d[1]:
-        continue;
-    location = definitionToSourceLocationMap[d];
+        continue
+    location = definitionToSourceLocationMap[d]
     # windows only
     if location.startswith("include/svl/svdde.hxx"): continue
     # fluent API (return ref to self)
diff --git a/compilerplugins/clang/unusedvarsglobal.py 
b/compilerplugins/clang/unusedvarsglobal.py
index ccb7305ccc23..af41759b92da 100755
--- a/compilerplugins/clang/unusedvarsglobal.py
+++ b/compilerplugins/clang/unusedvarsglobal.py
@@ -115,7 +115,7 @@ for d in definitionSet2:
     if "exception" in vartype and vartype.endswith(" &"):
         continue
     # TODO for now, focus on the simple stuff
-    if not (vartype in ["rtl::OUString", "Bool"]):
+    if vartype not in ["rtl::OUString", "Bool"]:
         continue
     readonlySet.add(d)
 
diff --git a/compilerplugins/clang/virtualdead.py 
b/compilerplugins/clang/virtualdead.py
index e653c7e23832..e32de264ed68 100755
--- a/compilerplugins/clang/virtualdead.py
+++ b/compilerplugins/clang/virtualdead.py
@@ -23,7 +23,7 @@ with io.open("workdir/loplugin.virtualdead.log", "r", 
encoding="ascii", errors="
                 sourceLocation = tokens[2]
                 returnValue = tokens[3]
                 callInfo = (nameAndParams, sourceLocation)
-                if not callInfo in callDict:
+                if callInfo not in callDict:
                     callDict[callInfo] = set()
                 callDict[callInfo].add(returnValue)
                 definitionToSourceLocationMap[nameAndParams] = sourceLocation
@@ -74,7 +74,7 @@ def merge_bitfield(a, b):
             ret += "1"
         else:
             ret += "0"
-    return ret;
+    return ret
 tmp2dict = dict()
 tmp2list = list()
 for paramInfo in paramSet:
@@ -84,7 +84,7 @@ for paramInfo in paramSet:
     if re.match( r"\w+ ooo::vba::", name): continue
     if re.match( r"\w+ orcus::", name): continue
     if re.match( r"\w+ std::", name): continue
-    if not name in tmp2dict:
+    if name not in tmp2dict:
         tmp2dict[name] = bitfield
     else:
         tmp2dict[name] = merge_bitfield(tmp2dict[name], bitfield)

Reply via email to