usethesource / clair

C Language Analysis in Rascal
BSD 2-Clause "Simplified" License
25 stars 12 forks source link

Declarations of class in M3.declarations lead to all usages as well. #48

Closed jurgenvinju closed 1 year ago

jurgenvinju commented 1 year ago

When we experiment with C++ code in clair we figured out that m.declarations[classLoc] led to more than just the declaration of the class. It also contains field definitions of the type of that class in other classes and friend declarations, etc. This is breaking analysis accuracy.

jurgenvinju commented 1 year ago

the actual declarations of those fields are not present in m3.declarations. So it seems that the declarations of the fields are replaced by the type of the thing they are declaring.

rodinaarssen commented 1 year ago

Having an example here would be very helpful, as I can only guess what you're looking at now.

What I can comment is that this table is filled using a couple of deep matches in lang::cpp::M3.rsc, lines 53-57. It's possible that this is not precise enough for your current analysis; this would be the place to improve the logic (in particular, line 55 looks most peculiar).

jurgenvinju commented 1 year ago

I'll try and make an example, either from memory or using a typical C++ example like the snakes and ladders game.

rodinaarssen commented 1 year ago

Just something small and constructed would suffice, I suppose

jurgenvinju commented 1 year ago

solved this by fixing the code that @rodinaarssen pointed to, and also added tests