Bug 1247666 - Correctly test isSuppressConstructor, r=jonco

--HG--
extra : rebase_source : cb756ce8aa84d17c8279e272d49281fd5a55e338
extra : amend_source : 5efe68066999a3429d6e9d0bffd8d92c3f5de3fe
This commit is contained in:
Steve Fink 2016-02-15 15:40:47 -08:00
parent 8624ceb0db
commit 2fd69645f5
2 changed files with 16 additions and 10 deletions

View File

@ -37,7 +37,7 @@ function isMatchingDestructor(constructor, edge)
return false;
var variable = callee.Variable;
assert(variable.Kind == "Func");
if (!/::~/.test(variable.Name[0]))
if (variable.Name[1].charAt(0) != '~')
return false;
var constructExp = constructor.PEdgeCallInstance.Exp;
@ -50,8 +50,11 @@ function isMatchingDestructor(constructor, edge)
return sameVariable(constructExp.Variable, destructExp.Variable);
}
// Return all calls within the RAII scope of the constructor matched by
// isConstructor()
// Return all calls within the RAII scope of any constructor matched by
// isConstructor(). (Note that this would be insufficient if you needed to
// treat each instance separately, such as when different regions of a function
// body were guarded by these constructors and you needed to do something
// different with each.)
function allRAIIGuardedCallPoints(body, isConstructor)
{
if (!("PEdge" in body))
@ -67,7 +70,7 @@ function allRAIIGuardedCallPoints(body, isConstructor)
continue;
var variable = callee.Variable;
assert(variable.Kind == "Func");
if (!isConstructor(variable.Name[0]))
if (!isConstructor(variable.Name))
continue;
if (!("PEdgeCallInstance" in edge))
continue;

View File

@ -311,13 +311,16 @@ function isUnsafeStorage(typeName)
return typeName.startsWith('UniquePtr<');
}
function isSuppressConstructor(name)
function isSuppressConstructor(varName)
{
return name.indexOf("::AutoSuppressGC") != -1
|| name.indexOf("::AutoAssertGCCallback") != -1
|| name.indexOf("::AutoEnterAnalysis") != -1
|| name.indexOf("::AutoSuppressGCAnalysis") != -1
|| name.indexOf("::AutoIgnoreRootingHazards") != -1;
// varName[1] contains the unqualified name
return [
"AutoSuppressGC",
"AutoAssertGCCallback",
"AutoEnterAnalysis",
"AutoSuppressGCAnalysis",
"AutoIgnoreRootingHazards"
].indexOf(varName[1]) != -1;
}
// nsISupports subclasses' methods may be scriptable (or overridden