systemc-clang icon indicating copy to clipboard operation
systemc-clang copied to clipboard

Refactor the destruction of the objects

Open rseac opened this issue 4 years ago • 1 comments

Description

The destruction of objects with Matchers and SystemCClang should be revisited. It seems that the destruction of dynamically objects are not done properly.

rseac avatar Apr 07 '20 11:04 rseac

The current design creates an incomplete ModuleDecl in Matchers. The ports are populated there. Then, for each instance that is recognized, a new ModuleDecl is created, and information from the incomplete ModuleDecl is copied into the new instance-specific ModuleDecl. When deleting an instance of ModuleDecl, we have to be careful. This is because we do not want to delete the instance-specific ModuleDecl, which has structures with pointers in it (PortDecl), and then delete the incomplete ModuleDecl because the latter will cause a double free memory error. This is because the deletion of the instance-specific ModuleDecl will free the objects identified in the incomplete ModuleDecl.

The current solution is to clear the information for the instance-specific ModuleDecl before deleting it. Then, the deletion of the incomplete ModuleDecl will free the other objects such as PortDecl. clearOnlyGlobal does exactly this.

rseac avatar Apr 08 '20 14:04 rseac