From 0f4ed4f9dfaa3af468b15c88e782c994cba6604d Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Fri, 26 Jul 2024 14:11:30 -0400 Subject: [PATCH 1/5] Revert "Revert "Issue a warning instead of throwing an exception."" This reverts commit abc9b1677411c3738dc042f5e7f37b523197b9e0. --- .../com/ibm/wala/cast/python/util/Util.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/util/Util.java b/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/util/Util.java index 5e5f9f5d..233fc038 100644 --- a/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/util/Util.java +++ b/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/util/Util.java @@ -168,29 +168,28 @@ private Util() {} /** * If the given {@link ConstantKey}'s value is null, then issue a warning and return - * null. Otherwise, throw an {@link IllegalArgumentException} stating that an {@link - * AllocationSiteInNode} cannot be extracted from the given {@link ConstantKey}. A value of + * null. Otherwise, issue a warning stating that an {@link AllocationSiteInNode} + * cannot be extracted from the given {@link ConstantKey}. A value of * null most likely indicates that a receiver can potentially be null. * * @param constantKey The {@link ConstantKey} from which to extract the corresponding {@link * AllocationSiteInNode}. - * @return null if the given {@link ConstantKey}'s value is null. - * @throws IllegalArgumentException If the constant's value is another else other than null - * . + * @return null. */ private static AllocationSiteInNode getAllocationSiteInNode(ConstantKey constantKey) { Object value = constantKey.getValue(); - if (value == null) { + if (value == null) LOGGER.warning("Can't extract AllocationSiteInNode from: " + constantKey + "."); - return null; - } else - throw new IllegalArgumentException( + else + LOGGER.warning( "Can't extract AllocationSiteInNode from: " + constantKey + ". Not expecting value of: " + value + " from ConstantKey."); + + return null; } /** From 11993eb6eafbf69351f6bdd67233d1525defbaa5 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Fri, 26 Jul 2024 14:18:57 -0400 Subject: [PATCH 2/5] Add TODO comment. Per https://github.com/wala/ML/pull/208#issuecomment-2253018494. --- .../callgraph/PythonInstanceMethodTrampolineTargetSelector.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/ipa/callgraph/PythonInstanceMethodTrampolineTargetSelector.java b/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/ipa/callgraph/PythonInstanceMethodTrampolineTargetSelector.java index 7b997fe4..5dc108a4 100644 --- a/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/ipa/callgraph/PythonInstanceMethodTrampolineTargetSelector.java +++ b/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/ipa/callgraph/PythonInstanceMethodTrampolineTargetSelector.java @@ -88,6 +88,8 @@ protected boolean shouldProcess(CGNode caller, CallSiteReference site, IClass re @Override public IMethod getCalleeTarget(CGNode caller, CallSiteReference site, IClass receiver) { + // TODO: Callable detection may need to be moved. See https://github.com/wala/ML/issues/207. If + // it stays here, we should further document the receiver swapping process. if (isCallable(receiver)) { LOGGER.fine("Encountered callable."); From 4e39344a308ee527cf2619f5899a8902cbf207f3 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Mon, 29 Jul 2024 13:44:19 -0400 Subject: [PATCH 3/5] Don't assume number of parameters. This can happen now since we continue processing after a parse error. --- .../ipa/callgraph/PythonConstructorTargetSelector.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/ipa/callgraph/PythonConstructorTargetSelector.java b/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/ipa/callgraph/PythonConstructorTargetSelector.java index 6312868c..8a6b5d2c 100644 --- a/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/ipa/callgraph/PythonConstructorTargetSelector.java +++ b/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/ipa/callgraph/PythonConstructorTargetSelector.java @@ -184,10 +184,11 @@ public IMethod getCalleeTarget(CGNode caller, CallSiteReference site, IClass rec PythonTypes.Root))); pc++; - int[] cps = new int[init.getNumberOfParameters()]; + int numberOfParameters = init.getNumberOfParameters(); + int[] cps = new int[numberOfParameters > 1 ? numberOfParameters : 2]; cps[0] = fv; cps[1] = inst; - for (int j = 2; j < init.getNumberOfParameters(); j++) { + for (int j = 2; j < numberOfParameters; j++) { cps[j] = j; } From 4a349dd95fdd58b15dee23464e82d37c81bbf63e Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Thu, 1 Aug 2024 09:05:58 -0400 Subject: [PATCH 4/5] Convert exception throw to warning. --- .../ipa/callgraph/PythonSSAPropagationCallGraphBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/ipa/callgraph/PythonSSAPropagationCallGraphBuilder.java b/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/ipa/callgraph/PythonSSAPropagationCallGraphBuilder.java index 96ed805d..346972d9 100644 --- a/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/ipa/callgraph/PythonSSAPropagationCallGraphBuilder.java +++ b/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/ipa/callgraph/PythonSSAPropagationCallGraphBuilder.java @@ -462,7 +462,7 @@ private void processWildcardImports( Set nodes = callGraph.getNodes(importMethodReference); if (nodes.isEmpty()) - throw new IllegalStateException( + logger.warning( "Can't find CG node for import method: " + importMethodReference.getSignature() + "."); From f87d99d5605cb24aa554af36aec8acd2e3351c3c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 09:11:24 +0000 Subject: [PATCH 5/5] Bump black from 24.4.2 to 24.8.0 Bumps [black](https://github.com/psf/black) from 24.4.2 to 24.8.0. - [Release notes](https://github.com/psf/black/releases) - [Changelog](https://github.com/psf/black/blob/main/CHANGES.md) - [Commits](https://github.com/psf/black/compare/24.4.2...24.8.0) --- updated-dependencies: - dependency-name: black dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index b4f398b4..6876f3ca 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -black==24.4.2 +black==24.8.0