mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-24 06:10:12 +00:00
Driver: tweak the code for determining default image name
It seemed odd to have to make DefaultImageName be a mutable member of Driver. We don't need to the full result of computeTargetTriple() to determine the image name; just base it on DefaultTargetTriple. llvm-svn: 225530
This commit is contained in:
parent
1440bb2a26
commit
a7707220e3
@ -104,9 +104,6 @@ public:
|
||||
/// Default target triple.
|
||||
std::string DefaultTargetTriple;
|
||||
|
||||
/// Default name for linked images (e.g., "a.out").
|
||||
mutable std::string DefaultImageName;
|
||||
|
||||
/// Driver title to use with help.
|
||||
std::string DriverTitle;
|
||||
|
||||
@ -365,6 +362,9 @@ public:
|
||||
const char *LinkingOutput,
|
||||
InputInfo &Result) const;
|
||||
|
||||
/// Returns the default name for linked images (e.g., "a.out").
|
||||
const char *getDefaultImageName() const;
|
||||
|
||||
/// GetNamedOutputPath - Return the name to use for the output of
|
||||
/// the action \p JA. The result is appended to the compilation's
|
||||
/// list of temporary or result files, as appropriate.
|
||||
|
@ -50,7 +50,6 @@ Driver::Driver(StringRef ClangExecutable,
|
||||
: Opts(createDriverOptTable()), Diags(Diags), Mode(GCCMode),
|
||||
ClangExecutable(ClangExecutable), SysRoot(DEFAULT_SYSROOT),
|
||||
UseStdLib(true), DefaultTargetTriple(DefaultTargetTriple),
|
||||
DefaultImageName("a.out"),
|
||||
DriverTitle("clang LLVM compiler"),
|
||||
CCPrintOptionsFilename(nullptr), CCPrintHeadersFilename(nullptr),
|
||||
CCLogDiagnosticsFilename(nullptr),
|
||||
@ -1411,7 +1410,7 @@ void Driver::BuildJobs(Compilation &C) const {
|
||||
if (FinalOutput)
|
||||
LinkingOutput = FinalOutput->getValue();
|
||||
else
|
||||
LinkingOutput = DefaultImageName.c_str();
|
||||
LinkingOutput = getDefaultImageName();
|
||||
}
|
||||
|
||||
InputInfo II;
|
||||
@ -1624,6 +1623,11 @@ void Driver::BuildJobsForAction(Compilation &C,
|
||||
}
|
||||
}
|
||||
|
||||
const char *Driver::getDefaultImageName() const {
|
||||
llvm::Triple Target(llvm::Triple::normalize(DefaultTargetTriple));
|
||||
return Target.isOSWindows() ? "a.exe" : "a.out";
|
||||
}
|
||||
|
||||
/// \brief Create output filename based on ArgValue, which could either be a
|
||||
/// full filename, filename without extension, or a directory. If ArgValue
|
||||
/// does not provide a filename, then use BaseName, and use the extension
|
||||
@ -1742,12 +1746,12 @@ const char *Driver::GetNamedOutputPath(Compilation &C,
|
||||
NamedOutput = MakeCLOutputFilename(C.getArgs(), "", BaseName,
|
||||
types::TY_Image);
|
||||
} else if (MultipleArchs && BoundArch) {
|
||||
SmallString<128> Output(DefaultImageName.c_str());
|
||||
SmallString<128> Output(getDefaultImageName());
|
||||
Output += "-";
|
||||
Output.append(BoundArch);
|
||||
NamedOutput = C.getArgs().MakeArgString(Output.c_str());
|
||||
} else
|
||||
NamedOutput = DefaultImageName.c_str();
|
||||
NamedOutput = getDefaultImageName();
|
||||
} else {
|
||||
const char *Suffix = types::getTypeTempSuffix(JA.getType(), IsCLMode());
|
||||
assert(Suffix && "All types used for output should have a suffix.");
|
||||
@ -1996,8 +2000,6 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
|
||||
StringRef DarwinArchName) const {
|
||||
llvm::Triple Target = computeTargetTriple(DefaultTargetTriple, Args,
|
||||
DarwinArchName);
|
||||
if (Target.isOSWindows())
|
||||
DefaultImageName = "a.exe";
|
||||
|
||||
ToolChain *&TC = ToolChains[Target.str()];
|
||||
if (!TC) {
|
||||
|
7
clang/test/Driver/default-image-name.c
Normal file
7
clang/test/Driver/default-image-name.c
Normal file
@ -0,0 +1,7 @@
|
||||
// RUN: %clang -target i386-unknown-linux-gnu %s -### 2>&1 | FileCheck -check-prefix=LINUX %s
|
||||
// LINUX: a.out
|
||||
|
||||
// RUN: %clang -target i686-pc-windows-msvc %s -### 2>&1 | FileCheck -check-prefix=WIN %s
|
||||
// RUN: %clang -target i686-pc-windows-gnu %s -### 2>&1 | FileCheck -check-prefix=WIN %s
|
||||
// RUN: %clang -target i686-windows-gnu %s -### 2>&1 | FileCheck -check-prefix=WIN %s
|
||||
// WIN: a.exe
|
Loading…
Reference in New Issue
Block a user