yodamaster / include-what-you-use

Automatically exported from code.google.com/p/include-what-you-use
Other
0 stars 0 forks source link

Support catch statements #171

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Catching user-defined types requires that the caught type is fully defined. For 
example, compiling:

  class MyType;

  void f() {
    try {}
    catch (const MyType&) {}
  }

will say:

tests/cxx/catch.cc:5:20: error: unknown type name 'CatchByValue'
  catch (const MyType&) {}
               ^

So, IWYU should require the full type for all exception declarations (the var 
decl in the catch statement). Without this patch it only sees that MyType is 
mentioned by reference, and so assumes a forward declaration is enough.

Original issue reported on code.google.com by kim.gras...@gmail.com on 29 Jan 2015 at 8:28

Attachments:

GoogleCodeExporter commented 9 years ago
Uh, actually that's not exactly what it will say, my example was botched.

It does, however, require that MyType is not incomplete.

Original comment by kim.gras...@gmail.com on 29 Jan 2015 at 8:31

GoogleCodeExporter commented 9 years ago
Great catch, Kim. Patch looks good to me and tests pass on Mac OS X. Test is 
complete, you don't need to test && because "error: cannot catch exceptions by 
rvalue reference".

The only nitpick is header guards. If you want to have them, they should follow 
the existing style, which is 
DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_CATCH_BYPTR_H_ if I'm not mistaken.

Original comment by vsap...@gmail.com on 2 Feb 2015 at 1:30

GoogleCodeExporter commented 9 years ago
Thanks for the timely review, committed in r598 with the header guards fixed.

Original comment by kim.gras...@gmail.com on 4 Feb 2015 at 8:54