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 | 26386be1837ee7328827d6363071ce91d28d9010 (patch) | |
tree | d3a62a85239f1ad75253a141b2ea90dee244cbf1 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | b89e172ab643281e6189ff1c55769ec028b27994 (diff) | |
download | llvm-26386be1837ee7328827d6363071ce91d28d9010.zip llvm-26386be1837ee7328827d6363071ce91d28d9010.tar.gz llvm-26386be1837ee7328827d6363071ce91d28d9010.tar.bz2 |
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
llvm-svn: 194403
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 98745ac..d02e4a3 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/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( |