Skip to content

Wala merge #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions lib/WALASupport/InstrKindInfoGetter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,29 @@ jobject InstrKindInfoGetter::handleIntegerLiteralInst() {
if (outs != NULL) {
*outs << "<< IntegerLiteralInst >>" << "\n";
}

IntegerLiteralInst* castInst = cast<IntegerLiteralInst>(instr);
APInt value = castInst->getValue();

jobject node = (*wala)->makeConstant((int) value.getSExtValue());
nodeMap->insert(std::make_pair(castInst, node));

return node;
IntegerLiteralInst* Inst = cast<IntegerLiteralInst>(instr);
APInt Value = Inst->getValue();
jobject Node = nullptr;
if (Value.isNegative()) {
if (Value.getMinSignedBits() <= 32) {
Node = (*wala)->makeConstant(static_cast<int>(Value.getSExtValue()));
}
else if (Value.getMinSignedBits() <= 64) {
Node = (*wala)->makeConstant(Value.getSExtValue());
}
}
else {
if (Value.getActiveBits() <= 32) {
Node = (*wala)->makeConstant(static_cast<int>(Value.getZExtValue()));
}
else if (Value.getActiveBits() <= 64) {
Node = (*wala)->makeConstant(static_cast<long>(Value.getZExtValue()));
}
}
if (Node != nullptr) {
nodeMap->insert(std::make_pair(Inst, Node));
}
return Node;
}

jobject InstrKindInfoGetter::handleStringLiteralInst() {
Expand Down Expand Up @@ -837,8 +852,8 @@ SILInstructionKind InstrKindInfoGetter::get() {
}

case SILInstructionKind::IntegerLiteralInst: {
// node = handleIntegerLiteralInst();
*outs << "<< IntegerLiteralInst Broken >>" << "\n";
node = handleIntegerLiteralInst();
*outs << "<< IntegerLiteralInst >>" << "\n";
break;
}

Expand Down Expand Up @@ -1394,4 +1409,4 @@ SILInstructionKind InstrKindInfoGetter::get() {

*outs << *instr << "\n";
return instrKind;
}
}
5 changes: 5 additions & 0 deletions wala-tests/IntegerLiterals/int_decl.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let x = 2147483647
let y = 9223372036854775807
let z = 0
let a = -9223372036854775808
let b = -2147483648
3 changes: 3 additions & 0 deletions wala-tests/IntegerLiterals/uint_decl.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let x: UInt = 4294967295
let y: UInt = 18446744073709551615
let z: UInt = 0