[cfe-commits] r54643 - in /cfe/trunk: Driver/clang.cpp include/clang/Basic/LangOptions.h lib/CodeGen/CodeGenModule.cpp

Daniel Dunbar daniel at zuster.org
Mon Aug 11 10:36:15 PDT 2008


Author: ddunbar
Date: Mon Aug 11 12:36:14 2008
New Revision: 54643

URL: http://llvm.org/viewvc/llvm-project?rev=54643&view=rev
Log:
Add -fexceptions to Driver
 - Maps to LangOptions.Exceptions
 - Currently always off, should autoselect based on language.

Update CodeGen to set unwind attribute on functions definitions based
       on LangOptions.Exceptions.
 - Still need to set attributes appropriately on calls.

Modified:
    cfe/trunk/Driver/clang.cpp
    cfe/trunk/include/clang/Basic/LangOptions.h
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=54643&r1=54642&r2=54643&view=diff

==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Mon Aug 11 12:36:14 2008
@@ -362,6 +362,17 @@
                                     " with a different number of elements or "
                                     "different element types"));
 
+// FIXME: This (and all GCC -f options) really come in -f... and
+// -fno-... forms, and additionally support automagic behavior when
+// they are not defined. For example, -fexceptions defaults to on or
+// off depending on the language. We should support this behavior in
+// some form (perhaps just add a facility for distinguishing when an
+// has its default value from when it has been set to its default
+// value).
+static llvm::cl::opt<bool>
+Exceptions("fexceptions",
+           llvm::cl::desc("Enable support for exception handling."));
+
 // FIXME: add:
 //   -ansi
 //   -trigraphs
@@ -427,6 +438,7 @@
   Options.Microsoft = MSExtensions;
   Options.WritableStrings = WritableStrings;
   Options.LaxVectorConversions = LaxVectorConversions;
+  Options.Exceptions = Exceptions;
 }
 
 static llvm::cl::opt<bool>

Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=54643&r1=54642&r2=54643&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Mon Aug 11 12:36:14 2008
@@ -42,6 +42,7 @@
   unsigned Boolean           : 1;  // Allow bool/true/false
   unsigned WritableStrings   : 1;  // Allow writable strings
   unsigned LaxVectorConversions : 1;
+  unsigned Exceptions        : 1;  // Support exception handling.
   
 private:
   unsigned GC : 2; // Objective-C Garbage Collection modes.  We declare
@@ -57,7 +58,7 @@
     GC = ObjC1 = ObjC2 = 0;
     C99 = Microsoft = CPlusPlus = CPlusPlus0x = NoExtensions = 0;
     CXXOperatorNames = PascalStrings = Boolean = WritableStrings = 0;
-    LaxVectorConversions = 0;
+    LaxVectorConversions = Exceptions = 0;
   }
   
   GCMode getGCMode() const { return (GCMode) GC; }

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=54643&r1=54642&r2=54643&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Aug 11 12:36:14 2008
@@ -751,6 +751,12 @@
     llvm::Function *Fn = cast<llvm::Function>(Entry);    
     CodeGenFunction(*this).GenerateCode(D, Fn);
 
+    // Set attributes specific to definition. 
+    // FIXME: This needs to be cleaned up by clearly emitting the
+    // declaration / definition at separate times.
+    if (!Features.Exceptions)
+      Fn->addParamAttr(0, llvm::ParamAttr::NoUnwind);  
+
     if (const ConstructorAttr *CA = D->getAttr<ConstructorAttr>()) {
       AddGlobalCtor(Fn, CA->getPriority());
     } else if (const DestructorAttr *DA = D->getAttr<DestructorAttr>()) {





More information about the cfe-commits mailing list