Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4063,17 +4063,18 @@ void Driver::handleArguments(Compilation &C, DerivedArgList &Args,
YcArg = YuArg = nullptr;
}

unsigned LastPLSize = 0;
bool LinkOnly = phases::Link == FinalPhase && Inputs.size() > 0;
for (auto &I : Inputs) {
types::ID InputType = I.first;
const Arg *InputArg = I.second;

auto PL = types::getCompilationPhases(InputType);
LastPLSize = PL.size();

phases::ID InitialPhase = PL[0];
LinkOnly = LinkOnly && phases::Link == InitialPhase && PL.size() == 1;

// If the first step comes after the final phase we are doing as part of
// this compilation, warn the user about it.
phases::ID InitialPhase = PL[0];
if (InitialPhase > FinalPhase) {
if (InputArg->isClaimed())
continue;
Expand Down Expand Up @@ -4128,10 +4129,8 @@ void Driver::handleArguments(Compilation &C, DerivedArgList &Args,
}
}

// If we are linking, claim any options which are obviously only used for
// compilation.
// FIXME: Understand why the last Phase List length is used here.
if (FinalPhase == phases::Link && LastPLSize == 1) {
// Claim any options which are obviously only used for compilation.
if (LinkOnly) {
Args.ClaimAllArgs(options::OPT_CompileOnly_Group);
Args.ClaimAllArgs(options::OPT_cl_compile_Group);
}
Expand Down
10 changes: 10 additions & 0 deletions clang/test/Driver/unsupported-option.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,13 @@
// RUN: not %clang -fprofile-sample-use=code.prof --target=powerpc-ibm-aix %s 2>&1 | \
// RUN: FileCheck %s --check-prefix=AIX-PROFILE-SAMPLE
// AIX-PROFILE-SAMPLE: error: unsupported option '-fprofile-sample-use=' for target

// -mhtm is unsupported on x86_64. Test that using it in different command
// line permutations generates an `unsupported option` error.
// RUN: not %clang --target=x86_64 -### %s -mhtm 2>&1 \
// RUN: | FileCheck %s -check-prefix=UNSUP_OPT
// RUN: not %clang --target=x86_64 -### %s -mhtm -lc 2>&1 \
// RUN: | FileCheck %s -check-prefix=UNSUP_OPT
// RUN: not %clang --target=x86_64 -### -mhtm -lc %s 2>&1 \
// RUN: | FileCheck %s -check-prefix=UNSUP_OPT
// UNSUP_OPT: error: unsupported option