Skip to content

[SYCL] Add global namespace specifier for Enum Values #1939

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/include/clang/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ class NamedDecl : public Decl {
bool WithGlobalNsPrefix = false) const;

// FIXME: Remove string version.
std::string getQualifiedNameAsString() const;
std::string getQualifiedNameAsString(bool WithGlobalNsPrefix = false) const;

/// Appends a human-readable name for this declaration into the given stream.
///
Expand Down
5 changes: 3 additions & 2 deletions clang/lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1527,10 +1527,11 @@ void NamedDecl::printName(raw_ostream &os) const {
os << Name;
}

std::string NamedDecl::getQualifiedNameAsString() const {
std::string NamedDecl::getQualifiedNameAsString(bool WithGlobalNsPrefix) const {
std::string QualName;
llvm::raw_string_ostream OS(QualName);
printQualifiedName(OS, getASTContext().getPrintingPolicy());
printQualifiedName(OS, getASTContext().getPrintingPolicy(),
WithGlobalNsPrefix);
return OS.str();
}

Expand Down
4 changes: 3 additions & 1 deletion clang/lib/Sema/SemaSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2138,7 +2138,9 @@ static void printArgument(ASTContext &Ctx, raw_ostream &ArgOS,

if (ET) {
const llvm::APSInt &Val = Arg.getAsIntegral();
ArgOS << "static_cast<" << ET->getDecl()->getQualifiedNameAsString()
ArgOS << "static_cast<"
<< ET->getDecl()->getQualifiedNameAsString(
/*WithGlobalNsPrefix*/ true)
<< ">"
<< "(" << Val << ")";
} else {
Expand Down
14 changes: 7 additions & 7 deletions clang/test/CodeGenSYCL/kernelname-enum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ int main() {
// CHECK: template <EnumValueIn EnumValue, typename EnumTypeIn> class Baz;
// CHECK: template <typename EnumTypeOut, template <EnumValueIn EnumValue, typename EnumTypeIn> class T> class dummy_functor_8;
// CHECK: Specializations of KernelInfo for kernel function types:
// CHECK: template <> struct KernelInfo<::dummy_functor_1<static_cast<no_namespace_int>(0)>>
// CHECK: template <> struct KernelInfo<::dummy_functor_2<static_cast<no_namespace_short>(1)>>
// CHECK: template <> struct KernelInfo<::dummy_functor_3<static_cast<internal::namespace_short>(1)>>
// CHECK: template <> struct KernelInfo<::dummy_functor_4<static_cast<enum_in_anonNS>(1)>>
// CHECK: template <> struct KernelInfo<::dummy_functor_5<static_cast<no_type_set>(0)>>
// CHECK: template <> struct KernelInfo<::dummy_functor_6<static_cast<unscoped_enum>(0)>>
// CHECK: template <> struct KernelInfo<::dummy_functor_1<static_cast<::no_namespace_int>(0)>>
// CHECK: template <> struct KernelInfo<::dummy_functor_2<static_cast<::no_namespace_short>(1)>>
// CHECK: template <> struct KernelInfo<::dummy_functor_3<static_cast<::internal::namespace_short>(1)>>
// CHECK: template <> struct KernelInfo<::dummy_functor_4<static_cast<::enum_in_anonNS>(1)>>
// CHECK: template <> struct KernelInfo<::dummy_functor_5<static_cast<::no_type_set>(0)>>
// CHECK: template <> struct KernelInfo<::dummy_functor_6<static_cast<::unscoped_enum>(0)>>
// CHECK: template <> struct KernelInfo<::dummy_functor_7<::no_namespace_int>>
// CHECK: template <> struct KernelInfo<::dummy_functor_7<::internal::namespace_short>>
// CHECK: template <> struct KernelInfo<::T1<::T2<static_cast<type_argument_template_enum::E>(0)>>>
// CHECK: template <> struct KernelInfo<::T1<::T2<static_cast<::type_argument_template_enum::E>(0)>>>
// CHECK: template <> struct KernelInfo<::T1<::T3<::type_argument_template_enum::E>>>
// CHECK: template <> struct KernelInfo<::dummy_functor_8<::EnumTypeOut, Baz>>