Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2159256

Browse files
committed
C++: Define 'ReturnKind's in terms of SSA instead of 'Function'.
1 parent e3ce7c6 commit 2159256

1 file changed

Lines changed: 10 additions & 16 deletions

File tree

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -457,18 +457,14 @@ newtype TPosition =
457457

458458
private newtype TReturnKind =
459459
TNormalReturnKind(int indirectionIndex) {
460-
indirectionIndex =
461-
[0 .. max(Ssa::Function f |
462-
|
463-
Ssa::getMaxIndirectionsForType(f.getUnspecifiedType()) - 1 // -1 because a returned value is a prvalue not a glvalue
464-
)]
460+
Ssa::hasIndirectOperand(any(ReturnValueInstruction ret).getReturnAddressOperand(),
461+
indirectionIndex + 1) // We subtract one because the return loads the value.
465462
} or
466463
TIndirectReturnKind(int argumentIndex, int indirectionIndex) {
467-
indirectionIndex =
468-
[0 .. max(Ssa::Function f |
469-
|
470-
Ssa::getMaxIndirectionsForType(f.getParameter(argumentIndex).getUnspecifiedType()) - 1 // -1 because an argument is a prvalue not a glvalue
471-
)]
464+
exists(Ssa::FinalParameterUse use |
465+
use.getIndirectionIndex() = indirectionIndex and
466+
use.getArgumentIndex() = argumentIndex
467+
)
472468
}
473469

474470
/**
@@ -994,11 +990,10 @@ class CastNode extends Node {
994990

995991
cached
996992
newtype TDataFlowCallable =
997-
TSourceCallable(Cpp::Declaration decl) { not decl instanceof FlowSummaryImpl::Public::SummarizedCallable }
998-
or
999-
TSummarizedCallable(
1000-
FlowSummaryImpl::Public::SummarizedCallable c
1001-
)
993+
TSourceCallable(Cpp::Declaration decl) {
994+
not decl instanceof FlowSummaryImpl::Public::SummarizedCallable
995+
} or
996+
TSummarizedCallable(FlowSummaryImpl::Public::SummarizedCallable c)
1002997

1003998
/**
1004999
* A callable, which may be:
@@ -1182,7 +1177,6 @@ class SummaryCall extends DataFlowCall, TSummaryCall {
11821177
// or `getArgumentOperand(int index)`. This is because the flow summary
11831178
// library is responsible for finding the call target, and there are no
11841179
// IR nodes available for the call target operand or argument operands.
1185-
11861180
override DataFlowCallable getEnclosingCallable() { result = TSummarizedCallable(c) }
11871181

11881182
override string toString() { result = "[summary] call to " + receiver + " in " + c }

0 commit comments

Comments
 (0)