]> granicus.if.org Git - clang/commitdiff
Fix validation of the -mthread-model flag in the Clang driver
authorJonathan Roelofs <jonathan@codesourcery.com>
Thu, 7 Sep 2017 22:01:25 +0000 (22:01 +0000)
committerJonathan Roelofs <jonathan@codesourcery.com>
Thu, 7 Sep 2017 22:01:25 +0000 (22:01 +0000)
The ToolChain class validates the -mthread-model flag in the constructor which
doesn't work correctly since the thread model methods are virtual methods. The
check is moved into Clang::ConstructJob() when constructing the internal
command line.

https://reviews.llvm.org/D37496

Patch by: Ian Tessier!

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

lib/Driver/ToolChain.cpp
lib/Driver/ToolChains/Clang.cpp

index 93410a7f2a59dbcc80c803bb2f76c63aec0f5995..566d430b1a64398614804f526ed2f08d00215347 100644 (file)
@@ -74,11 +74,6 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple &T,
     : D(D), Triple(T), Args(Args), CachedRTTIArg(GetRTTIArgument(Args)),
       CachedRTTIMode(CalculateRTTIMode(Args, Triple, CachedRTTIArg)),
       EffectiveTriple() {
-  if (Arg *A = Args.getLastArg(options::OPT_mthread_model))
-    if (!isThreadModelSupported(A->getValue()))
-      D.Diag(diag::err_drv_invalid_thread_model_for_target)
-          << A->getValue() << A->getAsString(Args);
-
   std::string CandidateLibPath = getArchSpecificLibPath();
   if (getVFS().exists(CandidateLibPath))
     getFilePaths().push_back(CandidateLibPath);
index ba03fcd57c6e709340926d835fbc60cf3d76e046..98652703f1e8ffc245298a849b43ad69a45ce9fc 100644 (file)
@@ -3235,8 +3235,12 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   }
 
   CmdArgs.push_back("-mthread-model");
-  if (Arg *A = Args.getLastArg(options::OPT_mthread_model))
+  if (Arg *A = Args.getLastArg(options::OPT_mthread_model)) {
+    if (!getToolChain().isThreadModelSupported(A->getValue()))
+      D.Diag(diag::err_drv_invalid_thread_model_for_target)
+          << A->getValue() << A->getAsString(Args);
     CmdArgs.push_back(A->getValue());
+  }
   else
     CmdArgs.push_back(Args.MakeArgString(getToolChain().getThreadModel()));