From c961d3ed12335fdc595e4cae7b45cc0d0b8b38ea Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Fri, 9 Apr 2021 06:11:30 -0700 Subject: [PATCH 1/3] [SYCL] Fix StringLiteral Ctor issue from #3504. I'm not sure what causes this to not like this conversion, the error message seems incorrect and only on certain configs of the build, but we should fix the build anyway. This calls the StringRef pointer-size directly, rather than having the StringLiteral type do it. --- clang/lib/Sema/SemaSYCL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaSYCL.cpp b/clang/lib/Sema/SemaSYCL.cpp index c7be03e5f813f..e67dbdb1c4619 100644 --- a/clang/lib/Sema/SemaSYCL.cpp +++ b/clang/lib/Sema/SemaSYCL.cpp @@ -73,7 +73,7 @@ class Util { template static constexpr DeclContextDesc MakeDeclContextDesc(Decl::Kind K, const char (&Str)[N]) { - return DeclContextDesc{K, llvm::StringLiteral{Str}}; + return DeclContextDesc{K, llvm::StringRef{Str, N}}; } static constexpr DeclContextDesc MakeDeclContextDesc(Decl::Kind K, From d88442d45926c9d318bc87e562260f9b0e1e6d33 Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Fri, 9 Apr 2021 06:54:42 -0700 Subject: [PATCH 2/3] Add note --- clang/lib/Sema/SemaSYCL.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaSYCL.cpp b/clang/lib/Sema/SemaSYCL.cpp index e67dbdb1c4619..ac428aa60116f 100644 --- a/clang/lib/Sema/SemaSYCL.cpp +++ b/clang/lib/Sema/SemaSYCL.cpp @@ -73,7 +73,12 @@ class Util { template static constexpr DeclContextDesc MakeDeclContextDesc(Decl::Kind K, const char (&Str)[N]) { - return DeclContextDesc{K, llvm::StringRef{Str, N}}; + // FIXME: This SHOULD be able to use the StringLiteral constructor here + // instead, however this seems to fail with an 'invalid string literal' note + // on the correct constructor in some build configurations. We need to + // figure that out before reverting this to use the StringLiteral + // constructor. + return DeclContextDesc{K, StringRef{Str, N}}; } static constexpr DeclContextDesc MakeDeclContextDesc(Decl::Kind K, From 8dc9103ad9a5c7f9f7d5e528520d730ec5e827b0 Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Fri, 9 Apr 2021 07:53:37 -0700 Subject: [PATCH 3/3] Looks like I forgot about the null-terminator, this should fix the build failures I believe --- clang/lib/Sema/SemaSYCL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaSYCL.cpp b/clang/lib/Sema/SemaSYCL.cpp index ac428aa60116f..bcc49c2232967 100644 --- a/clang/lib/Sema/SemaSYCL.cpp +++ b/clang/lib/Sema/SemaSYCL.cpp @@ -78,7 +78,7 @@ class Util { // on the correct constructor in some build configurations. We need to // figure that out before reverting this to use the StringLiteral // constructor. - return DeclContextDesc{K, StringRef{Str, N}}; + return DeclContextDesc{K, StringRef{Str, N - 1}}; } static constexpr DeclContextDesc MakeDeclContextDesc(Decl::Kind K,