[OpenMP] Fix translation of target args
authorJonas Hahnfeld <hahnjo@hahnjo.de>
Wed, 27 Sep 2017 18:12:36 +0000 (18:12 +0000)
committerJonas Hahnfeld <hahnjo@hahnjo.de>
Wed, 27 Sep 2017 18:12:36 +0000 (18:12 +0000)
ToolChain::TranslateArgs() returns nullptr if no changes are performed.
This would currently mean that OpenMPArgs are lost. Patch fixes this
by falling back to simply using OpenMPArgs in that case.

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

llvm-svn: 314330

clang/lib/Driver/Compilation.cpp

index fe2a181..b3991da 100644 (file)
@@ -57,14 +57,16 @@ Compilation::getArgsForToolChain(const ToolChain *TC, StringRef BoundArch,
         *TranslatedArgs, DeviceOffloadKind, AllocatedArgs);
     if (!OpenMPArgs) {
       Entry = TC->TranslateArgs(*TranslatedArgs, BoundArch, DeviceOffloadKind);
+      if (!Entry)
+        Entry = TranslatedArgs;
     } else {
       Entry = TC->TranslateArgs(*OpenMPArgs, BoundArch, DeviceOffloadKind);
-      delete OpenMPArgs;
+      if (!Entry)
+        Entry = OpenMPArgs;
+      else
+        delete OpenMPArgs;
     }
 
-    if (!Entry)
-      Entry = TranslatedArgs;
-
     // Add allocated arguments to the final DAL.
     for (auto ArgPtr : AllocatedArgs) {
       Entry->AddSynthesizedArg(ArgPtr);