-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
Some node attributes, in particular Varreference's decl and nodes' types, still point to the old AST's nodes. Function calls seem to be unaffected.
One can replicate this issue using the following clava script and c input file:
import Query from "@specs-feup/lara/api/weaver/Query.js"
import Clava from "@specs-feup/clava/api/clava/Clava.js";
import { Vardecl, Varref, FunctionJp, Call } from "@specs-feup/clava/api/Joinpoints.js"
const vardeclBefore: Vardecl = Query.search(Vardecl).getFirst()!;
const varrefBefore: Varref = Query.search(Varref).getFirst()!;
const fooFunBefore: FunctionJp = Query.search(FunctionJp, { name: "foo"}).getFirst()!;
const fooCallBefore: Call = Query.search(Call, { name: "foo"}).getFirst()!;
console.log(`before push vardecl hashCode: ${(vardeclBefore.node as any).hashCode()}`);
console.log(`before push varref.decl hashCode: ${(varrefBefore.decl.node as any).hashCode()}`);
console.log(`before push vardecl's type's hashCode: ${(vardeclBefore.type.node as any).hashCode()}`);
console.log();
console.log(`before push fooFun hashcode : ${(fooFunBefore.node as any).hashCode()}`);
console.log(`before push fooCall.fun hashcode : ${(fooCallBefore.function.node as any).hashCode()}`);
Clava.pushAst();
console.log("\n----------\n");
const vardeclAfter: Vardecl = Query.search(Vardecl).getFirst()!;
const varrefAfter: Varref = Query.search(Varref).getFirst()!;
const fooFunAfter: FunctionJp = Query.search(FunctionJp, { name: "foo"}).getFirst()!;
const fooCallAfter: Call = Query.search(Call, { name: "foo"}).getFirst()!;
console.log(`after push vardecl hashCode: ${(vardeclAfter.node as any).hashCode()}`);
console.log(`after push varref.decl hashCode: ${(varrefAfter.decl.node as any).hashCode()}`);
console.log(`after push vardecl's type's hashCode: ${(vardeclAfter.type.node as any).hashCode()}`);
console.log();
console.log(`after push fooFun hashcode : ${(fooFunAfter.node as any).hashCode()}`);
console.log(`after push fooCall.fun hashcode : ${(fooCallAfter.function.node as any).hashCode()}`);void foo(void) {}
int main() {
int a = 1;
a + 2;
foo();
}which will output something like
before push vardecl hashCode: 824881806
before push varref.decl hashCode: 824881806
before push vardecl's type's hashCode: 104431
before push fooFun hashcode : 547923534
before push fooCall.fun hashcode : 547923534
----------
after push vardecl hashCode: 379121284
after push varref.decl hashCode: 824881806
after push vardecl's type's hashCode: 104431
after push fooFun hashcode : 281421502
after push fooCall.fun hashcode : 281421502
As we can see, the varref.decl's hashcode still corresponds to the old vardecl's hashcode, rather than the new one. The type's hashcode is also unchanged.
Metadata
Metadata
Assignees
Labels
No labels