NoPreprocess = true;
// FALLTHROUGH
case langkind_objc:
- Options.ObjC1 = Options.ObjC2 = 1;
+ Options.ObjC1 = Options.ObjC2 = 1;
break;
case langkind_objcxx_cpp:
NoPreprocess = true;
llvm::cl::desc("Allow implicit conversions between vectors"
" with a different number of elements or "
"different element types."));
+
// FIXME: add:
// -ansi
// -trigraphs
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
//===----------------------------------------------------------------------===//
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);
/// LangOptions - This class keeps track of the various options that can be
/// enabled, which controls the dialect of C that is accepted.
struct LangOptions {
+
unsigned Trigraphs : 1; // Trigraphs in source files.
unsigned BCPLComment : 1; // BCPL-style '//' comments.
unsigned DollarIdents : 1; // '$' allowed in identifiers.
unsigned NoExtensions : 1; // All extensions are disabled, strict mode.
unsigned CXXOperatorNames : 1; // Treat C++ operator names as keywords.
- unsigned ObjC1 : 1; // Objective C 1 support enabled.
- unsigned ObjC2 : 1; // Objective C 2 support enabled.
-
+ unsigned ObjC1 : 1; // Objective-C 1 support enabled.
+ unsigned ObjC2 : 1; // Objective-C 2 support enabled.
+
unsigned PascalStrings : 1; // Allow Pascal strings
unsigned Boolean : 1; // Allow bool/true/false
unsigned WritableStrings : 1; // Allow writable strings
unsigned LaxVectorConversions : 1;
-
+
+private:
+ unsigned GC : 2; // Objective-C Garbage Collection modes. We declare
+ // this enum as unsigned because MSVC insists on making enums
+ // signed. Set/Query this value using accessors.
+public:
+
+ enum GCMode { NonGC, GCOnly, HybridGC };
+
LangOptions() {
Trigraphs = BCPLComment = DollarIdents = ImplicitInt = Digraphs = 0;
HexFloats = 0;
- ObjC1 = ObjC2 = 0;
+ GC = ObjC1 = ObjC2 = 0;
C99 = Microsoft = CPlusPlus = CPlusPlus0x = NoExtensions = 0;
CXXOperatorNames = PascalStrings = Boolean = WritableStrings = 0;
LaxVectorConversions = 0;
}
+ GCMode getGCMode() const { return (GCMode) GC; }
+ void setGCMode(GCMode m) { GC = (unsigned) m; }
+
/// Emit - Emit this LangOptions object to bitcode.
void Emit(llvm::Serializer& S) const;
S.EmitBool((bool) NoExtensions);
S.EmitBool((bool) CXXOperatorNames);
S.EmitBool((bool) ObjC1);
- S.EmitBool((bool) ObjC2);
+ S.EmitBool((bool) ObjC2);
+ S.EmitBool((unsigned) GC);
S.EmitBool((bool) PascalStrings);
S.EmitBool((bool) Boolean);
S.EmitBool((bool) WritableStrings);
CXXOperatorNames = D.ReadBool() ? 1 : 0;
ObjC1 = D.ReadBool() ? 1 : 0;
ObjC2 = D.ReadBool() ? 1 : 0;
+ GC = D.ReadInt();
PascalStrings = D.ReadBool() ? 1 : 0;
Boolean = D.ReadBool() ? 1 : 0;
WritableStrings = D.ReadBool() ? 1 : 0;