0

I have found out that Doxygen does not trace C++ exceptions (it does it for Java).

Please skip statements that you can never be certain as to whether a function throws an exception, as it can also pop up from bsearch() - I know. This doesn't matter much for me - Doxygen isn't perfect anyway and I don't expect it to be perfect, I just expect it to be useful.

I just need some solution that can trace the call graphs - which Doxygen actually does indeed, at least when generating data for drawing a call/caller graph - and find out what exceptions are thrown from particular function. It's enough that it trace just those functions which's code it can see and it can see an explicit 'throw' there - and every function which has it, as well as every function that calls such a function, is declared that it throws an exception of specified type.

Does anybody know something like that, at least that can give me any automaton-readable text form report that I can at least use to add @throws tags in Doxygen documentation?

Ethouris
  • 1,791
  • 13
  • 18
  • Well, I personally stopped adding `throw` specifications to function signatures: [Throw keyword in function's signature](http://stackoverflow.com/a/1055407/1413395) – πάντα ῥεῖ Jan 26 '15 at 17:53
  • You cannot compare the behavior with exceptions in Java and C++, one has declared exceptions in the interface, the other doesn't. Does it track `RuntimeException` in Java? I bet it doesn't. There are different problems with what you propose, it would give false positives (say a function that may throw is passed arguments that guarantee success), code is not *visible* in C++. In most cases you include a header, and use the implementation that is in some other translation unit which is not visible. Even if you have all the code in your program, you don't build it all at once. – David Rodríguez - dribeas Jan 26 '15 at 18:29
  • ... other than that, Doxygen is a utility to *document* not to analyze code. For that you could consider using a clang-based library that builds a database of locations in the compiled code where an exception is thrown together with the calling graph and then build the information externally. At least it would be a compiler interpreting the code, rather than a text processing utility... – David Rodríguez - dribeas Jan 26 '15 at 18:30
  • Guys, I perfectly know what the difference of exception declaration is in C++ and Java - and probably you're right that `java.lang.RuntimeException`-derived exceptions are not tracked. May happen it will give false positives (there may be deducible conditions under which the exception will never be thrown, even though there's a theoretical path that leads to it - actually with Java and `IOException` thrown from `close()` there's exactly the same problem). Perfect would be that doxy track exceptions and report warnings for no @throws statement. – Ethouris Jan 27 '15 at 08:47

0 Answers0