clang-cl: Fix unused argument warning when combining /O2 and /Ob2

llvm-svn: 270642
This commit is contained in:
Hans Wennborg 2016-05-25 00:43:45 +00:00
parent 293772e72e
commit debfed9ef0
2 changed files with 8 additions and 1 deletions

View File

@ -819,7 +819,12 @@ MSVCToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
continue;
StringRef OptStr = A->getValue();
for (size_t I = 0, E = OptStr.size(); I != E; ++I) {
const char &OptChar = *(OptStr.data() + I);
char OptChar = OptStr[I];
char PrevChar = I > 0 ? OptStr[I - 1] : '0';
if (PrevChar == 'b') {
// OptChar does not expand; it's an argument to the previous char.
continue;
}
if (OptChar == '1' || OptChar == '2' || OptChar == 'x' || OptChar == 'd')
ExpandChar = OptStr.data() + I;
}

View File

@ -99,6 +99,8 @@
// RUN: %clang_cl /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
// RUN: %clang_cl /Odb2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
// RUN: %clang_cl /O2 /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
// Ob2-NOT: warning: argument unused during compilation: '/O2'
// Ob2: -finline-functions
// RUN: %clang_cl /Od -### -- %s 2>&1 | FileCheck -check-prefix=Od %s