Skip to content

Commit f85ee0a

Browse files
author
Erich Keane
committed
Refactor the print section to trick aaron less
1 parent ee13887 commit f85ee0a

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4655,8 +4655,8 @@ static void EmitSpecIdShims(raw_ostream &OS, unsigned &ShimCounter,
46554655
// function call parameters.
46564656
static std::string EmitSpecIdShims(raw_ostream &OS, unsigned &ShimCounter,
46574657
const VarDecl *VD) {
4658-
assert(VD->isInAnonymousNamespace() &&
4659-
"Function assumes this is in an anonymous namespace");
4658+
if (!VD->isInAnonymousNamespace())
4659+
return "";
46604660
std::string RelativeName = VD->getNameAsString();
46614661
EmitSpecIdShims(OS, ShimCounter, VD->getDeclContext(), RelativeName);
46624662
return RelativeName;
@@ -4673,29 +4673,24 @@ bool SYCLIntegrationFooter::emit(raw_ostream &OS) {
46734673
unsigned ShimCounter = 0;
46744674
for (const VarDecl *VD : SpecConstants) {
46754675
VD = VD->getCanonicalDecl();
4676+
std::string TopShim = EmitSpecIdShims(OS, ShimCounter, VD);
4677+
OS << "__SYCL_INLINE_NAMESPACE(cl) {\n";
4678+
OS << "namespace sycl {\n";
4679+
OS << "namespace detail {\n";
4680+
OS << "template<>\n";
4681+
OS << "inline const char *get_spec_constant_symbolic_ID<";
4682+
46764683
if (VD->isInAnonymousNamespace()) {
4677-
std::string TopShim = EmitSpecIdShims(OS, ShimCounter, VD);
4678-
OS << "__SYCL_INLINE_NAMESPACE(cl) {\n";
4679-
OS << "namespace sycl {\n";
4680-
OS << "namespace detail {\n";
4681-
OS << "template<>\n";
4682-
OS << "inline const char *get_spec_constant_symbolic_ID<" << TopShim
4683-
<< ">() {\n";
4684-
OS << " return \"";
4685-
emitSpecIDName(OS, VD);
4686-
OS << "\";\n";
4684+
OS << TopShim;
46874685
} else {
4688-
OS << "__SYCL_INLINE_NAMESPACE(cl) {\n";
4689-
OS << "namespace sycl {\n";
4690-
OS << "namespace detail {\n";
4691-
OS << "template<>\n";
4692-
OS << "inline const char *get_spec_constant_symbolic_ID<::";
4686+
OS << "::";
46934687
VD->printQualifiedName(OS, Policy);
4694-
OS << ">() {\n";
4695-
OS << " return \"";
4696-
emitSpecIDName(OS, VD);
4697-
OS << "\";\n";
46984688
}
4689+
4690+
OS << ">() {\n";
4691+
OS << " return \"";
4692+
emitSpecIDName(OS, VD);
4693+
OS << "\";\n";
46994694
OS << "}\n";
47004695
OS << "} // namespace detail\n";
47014696
OS << "} // namespace sycl\n";

0 commit comments

Comments
 (0)