Add -fobjc-gc and -fobjc-gc-only options to the driver.
Add corresponding enum in LangOptions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50387 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/clang.cpp b/Driver/clang.cpp
index f077952..0b98416 100644
--- a/Driver/clang.cpp
+++ b/Driver/clang.cpp
@@ -283,7 +283,7 @@
NoPreprocess = true;
// FALLTHROUGH
case langkind_objc:
- Options.ObjC1 = Options.ObjC2 = 1;
+ Options.ObjC1 = Options.ObjC2 = 1;
break;
case langkind_objcxx_cpp:
NoPreprocess = true;
@@ -358,6 +358,7 @@
llvm::cl::desc("Allow implicit conversions between vectors"
" with a different number of elements or "
"different element types."));
+
// FIXME: add:
// -ansi
// -trigraphs
@@ -425,6 +426,23 @@
Options.LaxVectorConversions = LaxVectorConversions;
}
+static llvm::cl::opt<bool>
+ObjCExclusiveGC("fobjc-gc-only",
+ llvm::cl::desc("Use GC exclusively for Objective-C related "
+ "memory management."));
+
+static llvm::cl::opt<bool>
+ObjCEnableGC("fobjc-gc",
+ llvm::cl::desc("Enable Objective-C garbage collection."));
+
+void InitializeGCMode(LangOptions &Options) {
+ if (ObjCExclusiveGC)
+ Options.setGCMode(LangOptions::GCOnly);
+ else if (ObjCEnableGC)
+ Options.setGCMode(LangOptions::HybridGC);
+}
+
+
//===----------------------------------------------------------------------===//
// Our DiagnosticClient implementation
//===----------------------------------------------------------------------===//
@@ -1399,6 +1417,7 @@
LangKind LK = GetLanguage(InFile);
InitializeLangOptions(LangInfo, LK);
InitializeLanguageStandard(LangInfo, LK);
+ InitializeGCMode(LangInfo);
// Process the -I options and set them in the HeaderInfo.
HeaderSearch HeaderInfo(FileMgr);