aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2012-05-08 22:10:46 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2012-05-08 22:10:46 +0000
commitb3198a841e7f356f171f1e11faff014b2deb1eb8 (patch)
treef115cc1178faeca731a111d9a02f0ccad49f9dba /lib/Frontend
parent4213e389d6f8fa96ab30eec0d932e4e3eee32997 (diff)
add -fbounds-checking option.
When enabled, clang generates bounds checks for array and pointers dereferences. Work to follow in LLVM's backend. OK'ed by Chad; thanks for the review. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156431 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend')
-rw-r--r--lib/Frontend/CompilerInvocation.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index 0635be6667..3a7efbcdab 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -675,6 +675,8 @@ static void LangOptsToArgs(const LangOptions &Opts, ToArgsList &Res) {
Res.push_back("-fno-operator-names");
if (Opts.PascalStrings)
Res.push_back("-fpascal-strings");
+ if (Opts.BoundsChecking > 0)
+ Res.push_back("-fbounds-checking=" + llvm::utostr(Opts.BoundsChecking));
if (Opts.CatchUndefined)
Res.push_back("-fcatch-undefined-behavior");
if (Opts.AddressSanitizer)
@@ -1953,7 +1955,11 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
Opts.ObjCNonFragileABI2 = true;
Opts.ObjCDefaultSynthProperties =
Args.hasArg(OPT_fobjc_default_synthesize_properties);
- Opts.CatchUndefined = Args.hasArg(OPT_fcatch_undefined_behavior);
+ Opts.BoundsChecking = 0;
+ if ((Opts.CatchUndefined = Args.hasArg(OPT_fcatch_undefined_behavior)))
+ Opts.BoundsChecking = 5;
+ Opts.BoundsChecking = Args.getLastArgIntValue(OPT_fbounds_checking_EQ,
+ Opts.BoundsChecking, Diags);
Opts.EmitAllDecls = Args.hasArg(OPT_femit_all_decls);
Opts.PackStruct = Args.getLastArgIntValue(OPT_fpack_struct_EQ, 0, Diags);
Opts.PICLevel = Args.getLastArgIntValue(OPT_pic_level, 0, Diags);