Skip to content

Commit

Permalink
Merge pull request #1081 from soot-oss/1080-bug-localnamestandardizer…
Browse files Browse the repository at this point in the history
…-not-handling-integer1type-integer127type

fix lns Interger1Type, Interger127Type, etc
  • Loading branch information
swissiety authored Sep 26, 2024
2 parents 13a7637 + c29bdf2 commit c5fd96c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
import sootup.core.transform.BodyInterceptor;
import sootup.core.types.Type;
import sootup.core.views.View;
import sootup.interceptors.typeresolving.types.BottomType;

// https://github.com/Sable/soot/blob/master/src/main/java/soot/jimple/toolkits/scalar/LocalNameStandardizer.java

/** @author Zun Wang */
public class LocalNameStandardizer implements BodyInterceptor {
Expand Down Expand Up @@ -67,13 +64,6 @@ public void interceptBody(@Nonnull Body.BodyBuilder builder, @Nonnull View view)
Local local = iterator.next();
Local newLocal;
Type type = local.getType();

if (type instanceof BottomType) {
// TODO: log that likely the jimple is not formed correctly
// TODO: handle module signatures
type = view.getIdentifierFactory().getClassType("java.lang.Object");
}

newLocal = lgen.generateLocal(type);
builder.replaceLocal(local, newLocal);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public boolean resolve(@Nonnull Body.BodyBuilder builder) {
new TypePromotionVisitor(builder, evalFunction, hierarchy);
typings = typings.stream().map(promotionVisitor::getPromotedTyping).collect(Collectors.toSet());

// Promote `null`/`BottomType` types to `Object`.
// Promote `null`/`BottomType`/'TopType' types to `Object`, and other types which have
// UnsupportedOperation in TypePromotionVisitor.
for (Typing typing : typings) {
for (Local local : locals) {
typing.set(local, convertUnderspecifiedType(typing.getType(local)));
Expand Down Expand Up @@ -353,6 +354,12 @@ private Type convertUnderspecifiedType(@Nonnull Type type) {
// It is probably possible to use the debug information to choose a type here, but that
// complexity is not worth it for such an edge case.
return objectType;
} else if (type instanceof AugmentIntegerTypes.Integer1Type) {
return PrimitiveType.getBoolean();
} else if (type instanceof AugmentIntegerTypes.Integer127Type) {
return PrimitiveType.getByte();
} else if (type instanceof AugmentIntegerTypes.Integer32767Type) {
return PrimitiveType.getShort();
} else {
return type;
}
Expand Down

0 comments on commit c5fd96c

Please sign in to comment.