Skip to content

Commit 6ba5063

Browse files
committed
Force namespace printing
1 parent da51a19 commit 6ba5063

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

clang/include/clang/AST/PrettyPrinter.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ struct PrintingPolicy {
7676
MSWChar(LO.MicrosoftExt && !LO.WChar), IncludeNewlines(true),
7777
MSVCFormatting(false), ConstantsAsWritten(false),
7878
SuppressImplicitBase(false), FullyQualifiedName(false),
79+
EnforceScopeForElaboratedTypes(false),
7980
SuppressDefinition(false), SuppressDefaultTemplateArguments(false),
8081
PrintCanonicalTypes(false),
8182
SkipCanonicalizationOfTemplateTypeParms(false),
@@ -342,6 +343,10 @@ struct PrintingPolicy {
342343
LLVM_PREFERRED_TYPE(bool)
343344
unsigned FullyQualifiedName : 1;
344345

346+
/// Enforce fully qualified name printing for elaborated types.
347+
LLVM_PREFERRED_TYPE(bool)
348+
unsigned EnforceScopeForElaboratedTypes : 1;
349+
345350
/// When true does not print definition of a type. E.g.
346351
/// \code
347352
/// template<typename T> class C0 : public C1 {...}

clang/lib/AST/TypePrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class ElaboratedTypePolicyRAII {
101101
SuppressTagKeyword = Policy.SuppressTagKeyword;
102102
SuppressScope = Policy.SuppressScope;
103103
Policy.SuppressTagKeyword = true;
104-
Policy.SuppressScope = true;
104+
Policy.SuppressScope = !Policy.EnforceScopeForElaboratedTypes;
105105
}
106106

107107
~ElaboratedTypePolicyRAII() {

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6483,6 +6483,8 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
64836483
Policy.SuppressDefinition = true;
64846484
Policy.PolishForDeclaration = true;
64856485
Policy.EnforceDefaultTemplateArgs = true;
6486+
Policy.FullyQualifiedName = true;
6487+
Policy.EnforceScopeForElaboratedTypes = true;
64866488
if (FTD) {
64876489
FTD->print(O, Policy);
64886490
} else {
@@ -6513,6 +6515,8 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
65136515
O << "}\n";
65146516
Policy.SuppressDefaultTemplateArgs = true;
65156517
Policy.EnforceDefaultTemplateArgs = false;
6518+
Policy.FullyQualifiedName = false;
6519+
Policy.EnforceScopeForElaboratedTypes = false;
65166520

65176521
// Generate is_kernel, is_single_task_kernel and nd_range_kernel functions.
65186522
O << "namespace sycl {\n";

0 commit comments

Comments
 (0)