diff options
author | Sylvestre Ledru <sylvestre@debian.org> | 2013-11-11 19:01:05 +0000 |
---|---|---|
committer | Sylvestre Ledru <sylvestre@debian.org> | 2013-11-11 19:01:05 +0000 |
commit | 1cd76b1a44d74e9e2e8b8fcacc2d7ec290b54b76 (patch) | |
tree | 9beb908c9c14314924378f849c4d1618be6a768b /lib/Frontend/CompilerInvocation.cpp | |
parent | 246e2f65dcdb47a2a07b6d0f8f6f338954e24c45 (diff) | |
download | clang-1cd76b1a44d74e9e2e8b8fcacc2d7ec290b54b76.tar.gz |
Using an invalid -O falls back on -O3 instead of an error
Summary:
Currently with clang:
$ clang -O20 foo.c
error: invalid value '20' in '-O20'
With the patch:
$ clang -O20 foo.c
warning: invalid value '20' in '-O20'. Fall back on value '3'
Reviewers: rengolin, hfinkel
Reviewed By: rengolin
CC: cfe-commits, hfinkel, rengolin
Differential Revision: http://llvm-reviews.chandlerc.com/D2125
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194403 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | lib/Frontend/CompilerInvocation.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 98745aca68..d02e4a3e98 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -299,14 +299,14 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, using namespace options; bool Success = true; - unsigned OptLevel = getOptimizationLevel(Args, IK, Diags); - if (OptLevel > 3) { - Diags.Report(diag::err_drv_invalid_value) - << Args.getLastArg(OPT_O)->getAsString(Args) << OptLevel; - OptLevel = 3; - Success = false; + Opts.OptimizationLevel = getOptimizationLevel(Args, IK, Diags); + unsigned MaxOptLevel = 3; + if (Opts.OptimizationLevel > MaxOptLevel) { + // If the optimization level is not supported, fall back on the default optimization + Diags.Report(diag::warn_drv_invalid_value) + << Args.getLastArg(OPT_O)->getAsString(Args) << "-O" << MaxOptLevel; + Opts.OptimizationLevel = MaxOptLevel; } - Opts.OptimizationLevel = OptLevel; // We must always run at least the always inlining pass. Opts.setInlining( |