]> granicus.if.org Git - clang/commitdiff
Disable all dependency output options when using the Tooling library.
authorPeter Collingbourne <peter@pcc.me.uk>
Sun, 2 Mar 2014 23:37:26 +0000 (23:37 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Sun, 2 Mar 2014 23:37:26 +0000 (23:37 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202669 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Tooling/Tooling.cpp
unittests/Tooling/ToolingTest.cpp

index a58854d1af30d6bb87658bc11604c521df8d7836..ee110e33b69a79b7356c1b8735d5c5922ae95c03 100644 (file)
@@ -99,6 +99,7 @@ static clang::CompilerInvocation *newInvocation(
       *Diagnostics);
   Invocation->getFrontendOpts().DisableFree = false;
   Invocation->getCodeGenOpts().DisableFree = false;
+  Invocation->getDependencyOutputOpts() = DependencyOutputOptions();
   return Invocation;
 }
 
index a75710e86c22251ec72cd67af113a5d54e9f09e4..f34fab0fc7854c1432f2c933c86752f4623e5605 100644 (file)
@@ -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;