[PATCH] D67542: Fix depfile name construction

Luke Cheeseman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 13 06:14:06 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL371853: Fix depfile name construction (authored by LukeCheeseman, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67542?vs=220067&id=220083#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67542/new/

https://reviews.llvm.org/D67542

Files:
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/test/Driver/metadata-with-dots.c


Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -6066,15 +6066,14 @@
 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
Index: cfe/trunk/test/Driver/metadata-with-dots.c
===================================================================
--- cfe/trunk/test/Driver/metadata-with-dots.c
+++ cfe/trunk/test/Driver/metadata-with-dots.c
@@ -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;
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67542.220083.patch
Type: text/x-patch
Size: 1459 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190913/bcbe2e6b/attachment.bin>


More information about the cfe-commits mailing list