tags:

views:

228

answers:

4

I've found only abandoned projects, theories and feature lists. But I could not find a tool which can compare two C++ source files and show semantic differences.

Of course I would not compare two unrelated files, or changes accumulated during 10 years of development and maintenance. But changes usually discussed at a code review would be understood more easily, if presented together with proper meaning, instead of textual changes at char/word/line level

+2  A: 

It's not possible, in general. One program cannot even tell whether another will terminate (the famous Halting Problem). For more limited programs (finitely bounded loops, and maybe other constraints) you can do more, but it's heavy-duty stuff, and the language would have to be, not C++ but something less tricky, a limited subset or a simpler language altogether. That's probably why you're finding nothing that's been more than started.

JDonner
+2  A: 

Yes, it is called "writing comments for commits" and "issue tracking". Consider it metadata for semantic analysis.

ima
But that would be ISO layer 8 processing of information, instead of using a tool
CsTamas
True. Every version control can show history with comments, but I've never seen it integrated into merge tool, on per-change basis. Might become quite a useful feature... on the other, might clash with comments in code.
ima
Integrated into the merge tool? Like Git?
greyfade
What issue tracking integrated into what merge tool in _Git_? Git has neither half-decent integration with issue tracking, nor built-in merge tool, so I can only guess it doesn't have integration of those two.
ima
I'm probably misunderstanding you, but `git merge` handles merges as cleanly and simply as it does simple commits, with complete histories and commits from the source repository. With good commit comments (and with reviewers using --signoff), it's pretty easy to track the history of specific issues. Integration with issue/bug trackers would be nice, but it shouldn't be difficult to add with a couple Perl scripts.
greyfade
Please, read the question before posting - even git users can do it."git merge" handles branches, question is about files.
ima
Idea was - for files diff and merge - to have issues and comments and histories readily available for each individual change.
ima
+1  A: 

A true "semantic diff" is impossible. Closer would be a tool that compared two source files to see how one was derived from the other by abstract editing operations (delete, copy, move, rename) on program structures (variables, expressions, statements, methods). See Smart Differencer for a tool that does this for a few languages, with C++ coming soon.

Ira Baxter
How soon ? All similar tools were just started...
CsTamas
Expected in 30-60 days.
Ira Baxter
March 2010: Its been available for several months, just got back to this particular SO question.
Ira Baxter
+1  A: 

There is one for C used by linux kernel developers. Not for C++ though

http://coccinelle.lip6.fr

bradgonesurfing
@Brad: they talk about semantic patches, but it appears that what they mean are "pattern matches" that are insensitive to changes in white spaces, variable names, etc across multiple versions of a file, but it isn't clear they *compare* two files to determine that they are similar. Can you point specifically to where they say that?
Ira Baxter
You have the spdiff tool to infer semantic patches http://www.diku.dk/hjemmesider/ansatte/jespera/doc.html .
LB