llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.77k stars 11.9k forks source link

libclang/Windows: exceptions are not supported by default [regression from 3.6.2] #27698

Open llvmbot opened 8 years ago

llvmbot commented 8 years ago
Bugzilla Link 27324
Version 3.8
OS Linux
Reporter LLVM Bugzilla Contributor
CC @majnemer,@rnk

Extended Description

libclang 3.6.2 on Windows can parse code with exceptions just fine, whereas lib clang 3.8.0 produces "error: cannot use 'try' with exceptions disabled".

Providing -### as argument shows that libclang 3.8.0 does not have the corresponding options -fcxx-exceptions and -fexceptions internally (libclang 3.6.2 did).

This forces libclang clients to explicitly pass in those options in order to parse MSVC headers.

Details:

Given the following program making use of libclang:

include <clang-c/Index.h>

include

include

int main(int argc, char *argv[]) { if (argc != 2) { fprintf(stderr, "Usage: $0 \n"); return 0; }

  CXIndex index = clang_createIndex(0, /*displayDiagnostics*/ 1);
  clang_parseTranslationUnit(index, argv[1], 0, 0, NULL, 0, 0);

  return 0;

}

and the sample "inputfile.cpp":

int main() { try { } catch (...) {} }

shows that:

libclang 3.8.0:

$ libclangclient.exe intputfile.cpp: inputfile.cpp:3:5: error: cannot use 'try' with exceptions disabled $

libclang 3.6.2:

$ libclangclient.exe intputfile.cpp: $

rnk commented 8 years ago

The codegen support for MSVC-style EH was unstable, so it was off by default. David Majnemer enabled it this February in r261195, which was after the 3.8 branch on Jan 13.

There were other EH fixes between the 3.8 branch and that change, such as r258877. If we want 3.8.1 to enable EH by default, we'll need to merge all of them to the 3.8 branch.

llvmbot commented 8 years ago

Reid: Do you know more about this one?

llvmbot commented 8 years ago

Changing component to "Frontend" since this is reproducible with clang.exe, too.