"clang-cl --analyze" and exceptions

Hi!

As already observed in [1], things changed with regard to exceptions.

However, this also seems to break the clang static analyzer use case, which worked fine before. Is there a workaround for the *analyzer* case for 3.7.x? No actual code generation or catching of exceptions should be needed for this one.

Details:

--8<----main.cpp----------
#include <iostream>

int main()
{
   try {
     throw 1;
   } catch (int) {
     return 1;
   }

   return 0;
}
--8<----------------------

This works fine with 3.6.1:

  $ llvm-3.6.1\bin\clang-cl.exe --analyze /EHcs main.cpp

It stopped working with 3.7.0:

  $ llvm-3.7.0_64\bin\clang-cl.exe --analyze /EHcs main.cpp
main.cpp(6,5) : error: cannot use 'throw' with exceptions disabled
     throw 1;
     ^
main.cpp(5,3) : error: cannot use 'try' with exceptions disabled
   try {
   ^
2 errors generated.

Same results without the "/EHcs" flag. In [1] the following flags are suggested:

   -Xclang -fexceptions -Xclang -fcxx-exceptions -Xclang -fnew-ms-eh

However, 3.7.0 does not know '-fnew-ms-eh' and will crash with the remaining options.

Nikolai

[1] Redirecting to Google Groups

I actually undid the effect of [1] last Thursday in r249704, so one way to solve your problem is to build a fresh clang-cl or wait until Hans puts together a weekly build.

If you’re only interested in static analyzer results, and you want to stick with clang 3.7, you may be able to convince clang that it doesn’t need to emit code in order to bypass the assertions by adding -fsyntax-only to the command line.

If you need clang 3.7 with code generation and static analyzer results, I think you’re out of luck.

(fwiw, I just built r250039. It's available on http://llvm.org/builds/)

Hi again!