diff options
author | Nuno Lopes <nunoplopes@sapo.pt> | 2012-05-08 22:10:46 +0000 |
---|---|---|
committer | Nuno Lopes <nunoplopes@sapo.pt> | 2012-05-08 22:10:46 +0000 |
commit | 3d6311d5f7e5078df992c5167b53a586cfb7213a (patch) | |
tree | 6daffe4e34e3129dc4f01776be1a20311d2575c3 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | a777dc2abe4525b34a0e9d6433b41ea9728b27a2 (diff) | |
download | bcm5719-llvm-3d6311d5f7e5078df992c5167b53a586cfb7213a.tar.gz bcm5719-llvm-3d6311d5f7e5078df992c5167b53a586cfb7213a.zip |
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.
llvm-svn: 156431
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 0635be66673..3a7efbcdab2 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/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); |