[cfe-dev] "clang-cl --analyze" and exceptions

Nikolai Kosjar via cfe-dev cfe-dev at lists.llvm.org
Mon Oct 12 07:02:11 PDT 2015


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] https://groups.google.com/forum/#!topic/llvm-dev/WPn8uSpgCis



More information about the cfe-dev mailing list