[cfe-commits] r133025 - in /cfe/trunk: include/clang/Basic/LangOptions.h include/clang/Driver/CC1Options.td lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp lib/Sema/SemaDeclObjC.cpp lib/Serialization/ASTReader.cpp lib/Serialization/ASTWriter.cpp test/Driver/rewrite-objc.m
Douglas Gregor
dgregor at apple.com
Tue Jun 14 16:20:43 PDT 2011
Author: dgregor
Date: Tue Jun 14 18:20:43 2011
New Revision: 133025
URL: http://llvm.org/viewvc/llvm-project?rev=133025&view=rev
Log:
Introduce a -cc1-level option to turn off related result type
inference, to be used (only) by the Objective-C rewriter.
Modified:
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/Driver/rewrite-objc.m
Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=133025&r1=133024&r2=133025&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Tue Jun 14 18:20:43 2011
@@ -46,7 +46,8 @@
unsigned ObjCNonFragileABI : 1; // Objective-C modern abi enabled
unsigned ObjCNonFragileABI2 : 1; // Objective-C enhanced modern abi enabled
unsigned ObjCDefaultSynthProperties : 1; // Objective-C auto-synthesized properties.
-
+ unsigned ObjCInferRelatedResultType : 1; // Infer Objective-C related return
+ // types
unsigned AppleKext : 1; // Allow apple kext features.
unsigned PascalStrings : 1; // Allow Pascal strings
@@ -174,6 +175,7 @@
GC = ObjC1 = ObjC2 = ObjCNonFragileABI = ObjCNonFragileABI2 = 0;
AppleKext = 0;
ObjCDefaultSynthProperties = 0;
+ ObjCInferRelatedResultType = 1;
NoConstantCFStrings = 0; InlineVisibilityHidden = 0;
C99 = C1X = Microsoft = Borland = CPlusPlus = CPlusPlus0x = 0;
CXXOperatorNames = PascalStrings = WritableStrings = ConstStrings = 0;
Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=133025&r1=133024&r2=133025&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Tue Jun 14 18:20:43 2011
@@ -493,6 +493,10 @@
HelpText<"Enable Objective-C Ivar layout bitmap print trace">;
def fobjc_nonfragile_abi : Flag<"-fobjc-nonfragile-abi">,
HelpText<"enable objective-c's nonfragile abi">;
+def fno_objc_infer_related_result_type : Flag<
+ "-fno-objc-infer-related-result-type">,
+ HelpText<
+ "do not infer Objective-C related result type based on method family">;
def ftrapv : Flag<"-ftrapv">,
HelpText<"Trap on integer overflow">;
def ftrapv_handler : Separate<"-ftrapv-handler">,
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=133025&r1=133024&r2=133025&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Jun 14 18:20:43 2011
@@ -1542,6 +1542,11 @@
options::OPT_fno_lax_vector_conversions))
CmdArgs.push_back("-fno-lax-vector-conversions");
+ // -fobjc-infer-related-result-type is the default, except in the Objective-C
+ // rewriter.
+ if (IsRewriter)
+ CmdArgs.push_back("-fno-objc-infer-related-result-type");
+
// Handle -fobjc-gc and -fobjc-gc-only. They are exclusive, and -fobjc-gc-only
// takes precedence.
const Arg *GCArg = Args.getLastArg(options::OPT_fobjc_gc_only);
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=133025&r1=133024&r2=133025&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Jun 14 18:20:43 2011
@@ -670,6 +670,9 @@
Res.push_back("-fobjc-gc-only");
}
}
+ if (!Opts.ObjCInferRelatedResultType)
+ Res.push_back("-fno-objc-infer-related-result-type");
+
if (Opts.AppleKext)
Res.push_back("-fapple-kext");
@@ -1485,6 +1488,9 @@
else if (Args.hasArg(OPT_fobjc_gc))
Opts.setGCMode(LangOptions::HybridGC);
+ if (Args.hasArg(OPT_fno_objc_infer_related_result_type))
+ Opts.ObjCInferRelatedResultType = 0;
+
if (Args.hasArg(OPT_fapple_kext)) {
if (!Opts.CPlusPlus)
Diags.Report(diag::warn_c_kext);
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=133025&r1=133024&r2=133025&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Tue Jun 14 18:20:43 2011
@@ -2112,7 +2112,8 @@
mergeObjCMethodDecls(ObjCMethod, InterfaceMD);
}
- if (!ObjCMethod->hasRelatedResultType()) {
+ if (!ObjCMethod->hasRelatedResultType() &&
+ getLangOptions().ObjCInferRelatedResultType) {
bool InferRelatedResultType = false;
switch (ObjCMethod->getMethodFamily()) {
case OMF_None:
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=133025&r1=133024&r2=133025&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Jun 14 18:20:43 2011
@@ -92,6 +92,7 @@
PARSE_LANGOPT_IMPORTANT(AppleKext, diag::warn_pch_apple_kext);
PARSE_LANGOPT_IMPORTANT(ObjCDefaultSynthProperties,
diag::warn_pch_objc_auto_properties);
+ PARSE_LANGOPT_BENIGN(ObjCInferRelatedResultType)
PARSE_LANGOPT_IMPORTANT(NoConstantCFStrings,
diag::warn_pch_no_constant_cfstrings);
PARSE_LANGOPT_BENIGN(PascalStrings);
@@ -2934,6 +2935,7 @@
PARSE_LANGOPT(ObjCNonFragileABI2);
PARSE_LANGOPT(AppleKext);
PARSE_LANGOPT(ObjCDefaultSynthProperties);
+ PARSE_LANGOPT(ObjCInferRelatedResultType);
PARSE_LANGOPT(NoConstantCFStrings);
PARSE_LANGOPT(PascalStrings);
PARSE_LANGOPT(WritableStrings);
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=133025&r1=133024&r2=133025&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Tue Jun 14 18:20:43 2011
@@ -1050,6 +1050,7 @@
Record.push_back(LangOpts.AppleKext); // Apple's kernel extensions ABI
Record.push_back(LangOpts.ObjCDefaultSynthProperties); // Objective-C auto-synthesized
// properties enabled.
+ Record.push_back(LangOpts.ObjCInferRelatedResultType);
Record.push_back(LangOpts.NoConstantCFStrings); // non cfstring generation enabled..
Record.push_back(LangOpts.PascalStrings); // Allow Pascal strings
Modified: cfe/trunk/test/Driver/rewrite-objc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/rewrite-objc.m?rev=133025&r1=133024&r2=133025&view=diff
==============================================================================
--- cfe/trunk/test/Driver/rewrite-objc.m (original)
+++ cfe/trunk/test/Driver/rewrite-objc.m Tue Jun 14 18:20:43 2011
@@ -3,7 +3,7 @@
// TEST0: clang{{.*}}" "-cc1"
// TEST0: "-rewrite-objc"
// FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
-// TEST0: "-fmessage-length" "0" "-fobjc-exceptions" "-fdiagnostics-show-option"
+// TEST0: "-fmessage-length" "0" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fdiagnostics-show-option"
// TEST0: rewrite-objc.m"
// RUN: not %clang -ccc-no-clang -ccc-host-triple unknown -rewrite-objc %s -o - -### 2>&1 | \
More information about the cfe-commits
mailing list