forked from OSchip/llvm-project
Driver: Dissect -Wl, and -Xlinker arguments to remove --no-demangle, which was a
collect2 option that is passed by some projects (notably WebKit). llvm-svn: 105964
This commit is contained in:
parent
3f1a1ffd95
commit
fb3d747fc6
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -91,6 +92,13 @@ namespace driver {
|
||||||
return Values;
|
return Values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool containsValue(llvm::StringRef Value) const {
|
||||||
|
for (unsigned i = 0, e = getNumValues(); i != e; ++i)
|
||||||
|
if (Values[i] == Value)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// render - Append the argument onto the given array as strings.
|
/// render - Append the argument onto the given array as strings.
|
||||||
void render(const ArgList &Args, ArgStringList &Output) const;
|
void render(const ArgList &Args, ArgStringList &Output) const;
|
||||||
|
|
||||||
|
|
|
@ -715,3 +715,6 @@ def _warn_ : Joined<"--warn-">, Alias<W_Joined>;
|
||||||
def _write_dependencies : Flag<"--write-dependencies">, Alias<MD>;
|
def _write_dependencies : Flag<"--write-dependencies">, Alias<MD>;
|
||||||
def _write_user_dependencies : Flag<"--write-user-dependencies">, Alias<MMD>;
|
def _write_user_dependencies : Flag<"--write-user-dependencies">, Alias<MMD>;
|
||||||
def _ : Joined<"--">, Flags<[Unsupported]>;
|
def _ : Joined<"--">, Flags<[Unsupported]>;
|
||||||
|
|
||||||
|
// Special internal option to handle -Xlinker --no-demangle.
|
||||||
|
def Z_Xlinker__no_demangle : Flag<"-Z-Xlinker-no-demangle">, Flags<[Unsupported]>;
|
||||||
|
|
|
@ -114,8 +114,32 @@ DerivedArgList *Driver::TranslateInputArgs(const InputArgList &Args) const {
|
||||||
DerivedArgList *DAL = new DerivedArgList(Args);
|
DerivedArgList *DAL = new DerivedArgList(Args);
|
||||||
|
|
||||||
for (ArgList::const_iterator it = Args.begin(),
|
for (ArgList::const_iterator it = Args.begin(),
|
||||||
ie = Args.end(); it != ie; ++it)
|
ie = Args.end(); it != ie; ++it) {
|
||||||
|
const Arg *A = *it;
|
||||||
|
|
||||||
|
// Unfortunately, we have to parse some forwarding options (-Xassembler,
|
||||||
|
// -Xlinker, -Xpreprocessor) because we either integrate their functionality
|
||||||
|
// (assembler and preprocessor), or bypass a previous driver ('collect2').
|
||||||
|
if (A->getOption().matches(options::OPT_Xlinker) &&
|
||||||
|
A->getValue(Args) == llvm::StringRef("--no-demangle")) {
|
||||||
|
DAL->AddFlagArg(A, Opts->getOption(options::OPT_Z_Xlinker__no_demangle));
|
||||||
|
continue;
|
||||||
|
} else if (A->getOption().matches(options::OPT_Wl_COMMA) &&
|
||||||
|
A->containsValue("--no-demangle")) {
|
||||||
|
// Add the rewritten no-demangle argument.
|
||||||
|
DAL->AddFlagArg(A, Opts->getOption(options::OPT_Z_Xlinker__no_demangle));
|
||||||
|
|
||||||
|
// Add the remaining values as Xlinker arguments.
|
||||||
|
for (unsigned i = 0, e = A->getNumValues(); i != e; ++i)
|
||||||
|
if (llvm::StringRef(A->getValue(Args, i)) != "--no-demangle")
|
||||||
|
DAL->AddSeparateArg(A, Opts->getOption(options::OPT_Xlinker),
|
||||||
|
A->getValue(Args, i));
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
DAL->append(*it);
|
DAL->append(*it);
|
||||||
|
}
|
||||||
|
|
||||||
return DAL;
|
return DAL;
|
||||||
}
|
}
|
||||||
|
@ -322,7 +346,7 @@ bool Driver::HandleImmediateArgs(const Compilation &C) {
|
||||||
llvm::outs() << CLANG_VERSION_STRING "\n";
|
llvm::outs() << CLANG_VERSION_STRING "\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (C.getArgs().hasArg(options::OPT__print_diagnostic_categories)) {
|
if (C.getArgs().hasArg(options::OPT__print_diagnostic_categories)) {
|
||||||
PrintDiagnosticCategories(llvm::outs());
|
PrintDiagnosticCategories(llvm::outs());
|
||||||
return false;
|
return false;
|
||||||
|
@ -1230,7 +1254,7 @@ const HostInfo *Driver::GetHostInfo(const char *TripleStr) const {
|
||||||
|
|
||||||
// TCE is an osless target
|
// TCE is an osless target
|
||||||
if (Triple.getArchName() == "tce")
|
if (Triple.getArchName() == "tce")
|
||||||
return createTCEHostInfo(*this, Triple);
|
return createTCEHostInfo(*this, Triple);
|
||||||
|
|
||||||
switch (Triple.getOS()) {
|
switch (Triple.getOS()) {
|
||||||
case llvm::Triple::AuroraUX:
|
case llvm::Triple::AuroraUX:
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
// Check that we extract --no-demangle from '-Xlinker' and '-Wl,', since that
|
||||||
|
// was a collect2 argument.
|
||||||
|
|
||||||
|
// RUN: %clang --ccc-host-triple i386-apple-darwin9 -### \
|
||||||
|
// RUN: -Xlinker one -Xlinker --no-demangle \
|
||||||
|
// RUN: -Wl,two,--no-demangle,three -Xlinker four %s 2> %t
|
||||||
|
// RUN: FileCheck < %t %s
|
||||||
|
//
|
||||||
|
// CHECK: "one" "two" "three" "four"
|
Loading…
Reference in New Issue