Can llvm generate warnings for unused C++ code using global analysis? If I could use llvm to figure out what code I can delete in a 20 year old app with millions of lines of code, this alone would defend spending time on making the app build with llvm, even if we don't actually run the code generated... -- Øyvind Harboe - Can Zylin Consulting help on your project? US toll free 1-866-980-3434 / International +47 51 87 40 27 http://www.zylin.com/
On Вс. 03 июля 2011 23:07:37, Øyvind Harboe wrote:> Can llvm generate warnings for unused C++ code using global > analysis? > > If I could use llvm to figure out what code I can delete in a 20 > year old app with millions of lines of code, this alone would defend > spending time on making the app build with llvm, even if we don't > actually run the code generated...You can try Clang Static Analyzer (http://clang-analyzer.llvm.org/), but I'm not sure that it has such analysis.
An easier way would be to use a coverage tool like gcov to see what's actually *used* when the app is run normally. Then you can ask the question, what percentage of all lines of code are dead? A static analysis will not be able to see through things like virtual method calls. Reid On Sun, Jul 3, 2011 at 3:07 PM, Øyvind Harboe <oyvind.harboe at zylin.com> wrote:> Can llvm generate warnings for unused C++ code using global > analysis? > > If I could use llvm to figure out what code I can delete in a 20 > year old app with millions of lines of code, this alone would defend > spending time on making the app build with llvm, even if we don't > actually run the code generated... > > -- > Øyvind Harboe - Can Zylin Consulting help on your project? > US toll free 1-866-980-3434 / International +47 51 87 40 27 > http://www.zylin.com/ > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
On Sun, Jul 3, 2011 at 10:34 PM, Reid Kleckner <reid.kleckner at gmail.com> wrote:> An easier way would be to use a coverage tool like gcov to see what's > actually *used* when the app is run normally. Then you can ask the > question, what percentage of all lines of code are dead?We need something that can do this using static analysis... Otherwise we can just use Eclipse and search for reference as a first approximation and try a rebuild. Tedious process. gcov is out of question we'd have to execute the entire program, which is a non-starter. That said, it would be interesting to add gcov to the testsuite to get a measure of how many percent of the application we're exercising....> A static analysis will not be able to see through things like virtual > method calls.Not even in theory? -- Øyvind Harboe - Can Zylin Consulting help on your project? US toll free 1-866-980-3434 / International +47 51 87 40 27 http://www.zylin.com/