From 1535989c8bfeced06e6ebdb2b336c45a0dffd973 Mon Sep 17 00:00:00 2001 From: Michael D Toguchi Date: Sun, 29 Mar 2020 09:26:16 -0700 Subject: [PATCH] [Driver][NFC] Fix string problem used for tracking duplicate triples There is a test in sycl-offload.c that checks for duplicate triples and emits a diagnostic when one is seen. It has been witnessed that the second triple when emitted can be corrupted causing the test to fail. Signed-off-by: Michael D Toguchi --- clang/lib/Driver/Driver.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 934703a8d8b7d..8f6005173494a 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -803,7 +803,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, Arg *SYCLTargetsValues = SYCLTargets ? SYCLTargets : SYCLLinkTargets; if (SYCLTargetsValues) { if (SYCLTargetsValues->getNumValues()) { - for (const char *Val : SYCLTargetsValues->getValues()) { + for (StringRef Val : SYCLTargetsValues->getValues()) { llvm::Triple TT(Val); if (!isValidSYCLTriple(TT)) { Diag(clang::diag::err_drv_invalid_sycl_target) << Val; @@ -821,7 +821,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, // Store the current triple so that we can check for duplicates in // the following iterations. - FoundNormalizedTriples[NormalizedName] = NormalizedName; + FoundNormalizedTriples[NormalizedName] = Val; UniqueSYCLTriplesVec.push_back(TT); } } else @@ -857,7 +857,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, // Store the current triple so that we can check for duplicates in // the following iterations. - FoundNormalizedTriples[NormalizedName] = NormalizedName; + FoundNormalizedTriples[NormalizedName] = Val; UniqueSYCLTriplesVec.push_back(TT); } else { // No colon found, do not use the input