summaryrefslogtreecommitdiff
path: root/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorSylvestre Ledru <sylvestre@debian.org>2013-11-15 15:39:14 +0000
committerSylvestre Ledru <sylvestre@debian.org>2013-11-15 15:39:14 +0000
commiteb4d7c3fceed6c6e4151489c0572cff36500db78 (patch)
tree1d459aa7bc8b949ec304c9d645d7f6609dd6b403 /lib/Frontend/CompilerInvocation.cpp
parent71940883821bd55028f4c2773de10a532c1d8aea (diff)
downloadclang-eb4d7c3fceed6c6e4151489c0572cff36500db78.tar.gz
clang-eb4d7c3fceed6c6e4151489c0572cff36500db78.tar.bz2
clang-eb4d7c3fceed6c6e4151489c0572cff36500db78.tar.xz
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: optimization level '-O20' is unsupported; using '-O3' instead. 1 warning generated. This matches the gcc behavior (with a warning added) Pass all tests: Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. Testing Time: 94.14s Expected Passes : 6721 Expected Failures : 20 Unsupported Tests : 17 (which was not the case of http://llvm-reviews.chandlerc.com/D2125) Reviewers: chandlerc, rafael, rengolin, hfinkel Reviewed By: rengolin CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2152 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194817 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--lib/Frontend/CompilerInvocation.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index 581d56d462..f5079dd2a4 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_optimization_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(