clang based diff tool

G’day everybody,
I vaguely remember that there was some tought/work on having a semantics-based diff tool on top of clang. Did I dream of this? any pointers to the discussion?

Maurizio

I’m only aware of semanticmerge, but they’re just promising C++ support at this point. And I’m not even sure they’re using clang, but I’d be surprised if it’s anything else.

One of my students worked on a project to do this using libclang and the Python bindings last year. His goal was to identify common refactorings and present them in a human-readable form (including things like 'Variable x was renamed y in every use except those in foo.c'). His code probably isn't in a very good state to be reusable, but I'm sure he'd be happy to share his experiences with you.

David

I’d love to see someone pursue this.
There’s lots of things that one could build upon a smart diff tool.

Finding similar chunks of code.
Detecting botched refactoring.
Etc. Etc.

Rambling to follow …

A long time ago, I worked on a horrible code base; the result of years of copy/paste development.
We had a tool called (I think) Pattern Insight that found these two chunks of code (actual duplicated code was about 60 lines long)

blah blah global1 blah blah
blah blah blah blah blah
blah blah blah blah global1
blah global1 blah global1 blah blah
global1 blah blah blah blah
blah blah global1 blah blah

— and —

blah blah global2 blah blah
blah blah blah blah blah
blah blah blah blah global2
blah global1 blah global2 blah blah
global2 blah blah blah blah
blah blah global2 blah blah

And said (paraphrased) “Did you really mean ‘global1’ on line 4 of that second chunk?”

— Marshall

Maurizio, what you mentioned remind me about this discussion…

http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-February/035129.html

regards,
Laszlo

Thanks, I think this is the thread I remembered.
Although I must be getting old faster than I’d like: in my mind it was further back in the past.