[clang][DependencyFileGenerator] Fix missing -MT option handling
authorJan Korous <jkorous@apple.com>
Sat, 7 Sep 2019 00:59:13 +0000 (00:59 +0000)
committerJan Korous <jkorous@apple.com>
Sat, 7 Sep 2019 00:59:13 +0000 (00:59 +0000)
Targets in DependencyFileGenerator don't necessarily come from -MT option.

Differential Revision: https://reviews.llvm.org/D67308

llvm-svn: 371279

clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/DependencyFile.cpp

index f162453..99713e5 100644 (file)
@@ -3406,6 +3406,11 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
   Success &= ParseAnalyzerArgs(*Res.getAnalyzerOpts(), Args, Diags);
   Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args);
   ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), Args);
+  if (!Res.getDependencyOutputOpts().OutputFile.empty() &&
+      Res.getDependencyOutputOpts().Targets.empty()) {
+    Diags.Report(diag::err_fe_dependency_file_requires_MT);
+    Success = false;
+  }
   Success &=
       ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags,
                           false /*DefaultDiagColor*/, false /*DefaultShowOpt*/);
index b9c753d..4bb0167 100644 (file)
@@ -192,11 +192,6 @@ DependencyFileGenerator::DependencyFileGenerator(
 }
 
 void DependencyFileGenerator::attachToPreprocessor(Preprocessor &PP) {
-  if (Targets.empty()) {
-    PP.getDiagnostics().Report(diag::err_fe_dependency_file_requires_MT);
-    return;
-  }
-
   // Disable the "file not found" diagnostic if the -MG option was given.
   if (AddMissingHeaderDeps)
     PP.SetSuppressIncludeNotFoundError(true);