forked from OSchip/llvm-project
Fix depfile name construction
- When using -o, the provided filename is using for constructing the depfile name (when -MMD is passed). - The logic looks for the rightmost '.' character and replaces what comes after with 'd'. - This works incorrectly when the filename has no extension and the directories have '.' in them (e.g. out.dir/test) - This replaces the funciton to just llvm::sys::path functionality Differential Revision: https://reviews.llvm.org/D67542 llvm-svn: 371853
This commit is contained in:
parent
d48ea5da94
commit
ab9acda026
|
@ -6066,15 +6066,14 @@ const char *Clang::getBaseInputStem(const ArgList &Args,
|
|||
const char *Clang::getDependencyFileName(const ArgList &Args,
|
||||
const InputInfoList &Inputs) {
|
||||
// FIXME: Think about this more.
|
||||
std::string Res;
|
||||
|
||||
if (Arg *OutputOpt = Args.getLastArg(options::OPT_o)) {
|
||||
std::string Str(OutputOpt->getValue());
|
||||
Res = Str.substr(0, Str.rfind('.'));
|
||||
} else {
|
||||
Res = getBaseInputStem(Args, Inputs);
|
||||
SmallString<128> OutputFilename(OutputOpt->getValue());
|
||||
llvm::sys::path::replace_extension(OutputFilename, llvm::Twine('d'));
|
||||
return Args.MakeArgString(OutputFilename);
|
||||
}
|
||||
return Args.MakeArgString(Res + ".d");
|
||||
|
||||
return Args.MakeArgString(std::string(getBaseInputStem(Args, Inputs)) + ".d");
|
||||
}
|
||||
|
||||
// Begin ClangAs
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
// REQUIRES: shell
|
||||
// RUN: mkdir -p out.dir
|
||||
// RUN: cat %s > out.dir/test.c
|
||||
// RUN: %clang -E -MMD %s -o out.dir/test
|
||||
// RUN: test ! -f %out.d
|
||||
// RUN: test -f out.dir/test.d
|
||||
// RUN: rm -rf out.dir/test.d out.dir/ out.d
|
||||
int main (void)
|
||||
{
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue