r202669 - Disable all dependency output options when using the Tooling library.

Peter Collingbourne peter at pcc.me.uk
Sun Mar 2 15:37:26 PST 2014


Author: pcc
Date: Sun Mar  2 17:37:26 2014
New Revision: 202669

URL: http://llvm.org/viewvc/llvm-project?rev=202669&view=rev
Log:
Disable all dependency output options when using the Tooling library.

It isn't appropriate for a tool to be stomping over the dependency files,
especially if the actual build uses a compiler other than Clang or the tool
cannot find all the headers for some reason (which would cause the existing
dependency file to be deleted).

If a tool actually needs to care about dependency files we can think about
adding a mechanism for getting to this information.

Differential Revision: http://llvm-reviews.chandlerc.com/D2912

Modified:
    cfe/trunk/lib/Tooling/Tooling.cpp
    cfe/trunk/unittests/Tooling/ToolingTest.cpp

Modified: cfe/trunk/lib/Tooling/Tooling.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=202669&r1=202668&r2=202669&view=diff
==============================================================================
--- cfe/trunk/lib/Tooling/Tooling.cpp (original)
+++ cfe/trunk/lib/Tooling/Tooling.cpp Sun Mar  2 17:37:26 2014
@@ -99,6 +99,7 @@ static clang::CompilerInvocation *newInv
       *Diagnostics);
   Invocation->getFrontendOpts().DisableFree = false;
   Invocation->getCodeGenOpts().DisableFree = false;
+  Invocation->getDependencyOutputOpts() = DependencyOutputOptions();
   return Invocation;
 }
 

Modified: cfe/trunk/unittests/Tooling/ToolingTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/ToolingTest.cpp?rev=202669&r1=202668&r2=202669&view=diff
==============================================================================
--- cfe/trunk/unittests/Tooling/ToolingTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/ToolingTest.cpp Sun Mar  2 17:37:26 2014
@@ -236,6 +236,17 @@ TEST(runToolOnCode, TestSkipFunctionBody
                              "int skipMeNot() { an_error_here }"));
 }
 
+TEST(runToolOnCodeWithArgs, TestNoDepFile) {
+  llvm::SmallString<32> DepFilePath;
+  ASSERT_FALSE(
+      llvm::sys::fs::createTemporaryFile("depfile", "d", DepFilePath));
+  EXPECT_TRUE(runToolOnCodeWithArgs(
+      new SkipBodyAction, "",
+      { "-MMD", "-MT", DepFilePath.str(), "-MF", DepFilePath.str() }));
+  EXPECT_FALSE(llvm::sys::fs::exists(DepFilePath.str()));
+  EXPECT_FALSE(llvm::sys::fs::remove(DepFilePath.str()));
+}
+
 struct CheckSyntaxOnlyAdjuster: public ArgumentsAdjuster {
   bool &Found;
   bool &Ran;





More information about the cfe-commits mailing list