Merge pull request #12323 from MathiasVP/fix-enclosing-callable

C++: Fix missing enclosing callables
This commit is contained in:
Mathias Vorreiter Pedersen
2023-02-27 17:19:06 +00:00
committed by GitHub
4 changed files with 9 additions and 21 deletions

View File

@@ -461,7 +461,7 @@ class PostFieldUpdateNode extends TPostFieldUpdateNode, PartialDefinitionNode {
PostFieldUpdateNode() { this = TPostFieldUpdateNode(fieldAddress, indirectionIndex) }
override Function getFunction() { result = fieldAddress.getUse().getEnclosingFunction() }
override Declaration getFunction() { result = fieldAddress.getUse().getEnclosingFunction() }
override Declaration getEnclosingCallable() { result = this.getFunction() }
@@ -543,7 +543,7 @@ class SideEffectOperandNode extends Node, IndirectOperand {
override Declaration getEnclosingCallable() { result = this.getFunction() }
override Function getFunction() { result = call.getEnclosingFunction() }
override Declaration getFunction() { result = call.getEnclosingFunction() }
Expr getArgument() { result = call.getArgument(argumentIndex).getUnconvertedResultExpression() }
}
@@ -629,7 +629,7 @@ class IndirectParameterNode extends Node, IndirectInstruction {
override Declaration getEnclosingCallable() { result = this.getFunction() }
override Function getFunction() { result = this.getInstruction().getEnclosingFunction() }
override Declaration getFunction() { result = this.getInstruction().getEnclosingFunction() }
override string toStringImpl() {
result = this.getParameter().toString() + " indirection"
@@ -702,7 +702,7 @@ class IndirectArgumentOutNode extends Node, TIndirectArgumentOutNode, PartialDef
override Declaration getEnclosingCallable() { result = this.getFunction() }
override Function getFunction() { result = this.getCallInstruction().getEnclosingFunction() }
override Declaration getFunction() { result = this.getCallInstruction().getEnclosingFunction() }
override Node getPreUpdateNode() { hasOperandAndIndex(result, operand, indirectionIndex) }
@@ -847,7 +847,7 @@ class RawIndirectOperand extends Node, TRawIndirectOperand {
/** Gets the underlying indirection index. */
int getIndirectionIndex() { result = indirectionIndex }
override Function getFunction() { result = this.getOperand().getDef().getEnclosingFunction() }
override Declaration getFunction() { result = this.getOperand().getDef().getEnclosingFunction() }
override Declaration getEnclosingCallable() { result = this.getFunction() }
@@ -888,7 +888,7 @@ class FinalParameterNode extends Node, TFinalParameterNode {
/** Gets the argument index associated with this final use. */
final int getArgumentIndex() { result = p.getIndex() }
override Function getFunction() { result = p.getFunction() }
override Declaration getFunction() { result = p.getFunction() }
override Declaration getEnclosingCallable() { result = this.getFunction() }
@@ -945,7 +945,7 @@ class RawIndirectInstruction extends Node, TRawIndirectInstruction {
/** Gets the underlying indirection index. */
int getIndirectionIndex() { result = indirectionIndex }
override Function getFunction() { result = this.getInstruction().getEnclosingFunction() }
override Declaration getFunction() { result = this.getInstruction().getEnclosingFunction() }
override Declaration getEnclosingCallable() { result = this.getFunction() }

View File

@@ -1,8 +1,4 @@
uniqueEnclosingCallable
| globals.cpp:9:5:9:19 | flowTestGlobal1 indirection | Node should have one enclosing callable but has 0. |
| globals.cpp:9:5:9:19 | flowTestGlobal1 indirection | Node should have one enclosing callable but has 0. |
| globals.cpp:16:12:16:26 | flowTestGlobal2 indirection | Node should have one enclosing callable but has 0. |
| globals.cpp:16:12:16:26 | flowTestGlobal2 indirection | Node should have one enclosing callable but has 0. |
uniqueType
uniqueNodeLocation
missingLocation

View File

@@ -1,12 +1,4 @@
uniqueEnclosingCallable
| cpp11.cpp:36:5:36:14 | global_int indirection | Node should have one enclosing callable but has 0. |
| cpp11.cpp:36:5:36:14 | global_int indirection | Node should have one enclosing callable but has 0. |
| misc.c:10:5:10:13 | topLevel1 indirection | Node should have one enclosing callable but has 0. |
| misc.c:10:5:10:13 | topLevel1 indirection | Node should have one enclosing callable but has 0. |
| misc.c:11:5:11:13 | topLevel2 indirection | Node should have one enclosing callable but has 0. |
| misc.c:11:5:11:13 | topLevel2 indirection | Node should have one enclosing callable but has 0. |
| misc.c:210:5:210:20 | global_with_init indirection | Node should have one enclosing callable but has 0. |
| misc.c:210:5:210:20 | global_with_init indirection | Node should have one enclosing callable but has 0. |
uniqueType
uniqueNodeLocation
| allocators.cpp:14:5:14:8 | Phi | Node should have one location but has 4. |

View File

@@ -35,7 +35,7 @@ void test3_2(InputSource &data) {
SAX2XMLReader *p_3_3 = XMLReaderFactory::createXMLReader();
void test3_3(InputSource &data) {
p_3_3->parse(data); // BAD (parser not correctly configured) [NOT DETECTED]
p_3_3->parse(data); // BAD (parser not correctly configured)
}
SAX2XMLReader *p_3_4 = XMLReaderFactory::createXMLReader();
@@ -53,7 +53,7 @@ void test3_5_init() {
void test3_5(InputSource &data) {
test3_5_init();
p_3_5->parse(data); // GOOD
p_3_5->parse(data); // GOOD [FALSE POSITIVE]
}
void test3_6(InputSource &data) {