[cfe-commits] [patch] Fix -fno-exceptions for c++
Douglas Gregor
dgregor at apple.com
Tue Sep 29 08:27:36 PDT 2009
On Sep 28, 2009, at 4:31 PM, Rafael Espindola wrote:
> Currently __EXCEPTIONS=1 is always defined when compiling c++. The
> attached patch fixes it:
>
> clang -E -fno-exceptions test.c disabled
> clang -E -fexceptions test.c enabled
> clang -E test.c disabled
> clang -E -fno-exceptions test.cc disabled
> clang -E -fexceptions test.cc enabled
> clang -E test.cc enabled
>
> But it looks silly :-)
>
> Is there a way in clang-cc to test that an option was not given (as
> opposed to having the default value)?
I think the getPosition() member function will return > 0 when an
option was given, 0 when it was not given.
The -fexceptions/-fno-exceptions option and the current language
dialect should be used to set the Exceptions field of LangOptions. We
shouldn't do this:
Index: include/clang/Basic/LangOptions.h
===================================================================
--- include/clang/Basic/LangOptions.h (revision 83024)
+++ include/clang/Basic/LangOptions.h (working copy)
@@ -44,6 +44,7 @@
unsigned LaxVectorConversions : 1;
unsigned AltiVec : 1; // Support AltiVec-style vector
initializers.
unsigned Exceptions : 1; // Support exception handling.
+ unsigned NoExceptions : 1; // Don't support exception handling.
unsigned Rtti : 1; // Support rtti information.
unsigned NeXTRuntime : 1; // Use NeXT runtime.
because all clients would have to reason about -fexceptions/-fno-
exceptions/language defauls, PCH would have to serialize NoExceptions,
etc.
- Doug
More information about the cfe-commits
mailing list