diff --git a/clang/include/clang/AST/PrettyPrinter.h b/clang/include/clang/AST/PrettyPrinter.h index fd995a653d167..48105b3b9d4cd 100644 --- a/clang/include/clang/AST/PrettyPrinter.h +++ b/clang/include/clang/AST/PrettyPrinter.h @@ -15,6 +15,7 @@ #include "clang/Basic/LLVM.h" #include "clang/Basic/LangOptions.h" +#include "llvm/ADT/STLForwardCompat.h" namespace clang { @@ -55,14 +56,15 @@ class PrintingCallbacks { /// This type is intended to be small and suitable for passing by value. /// It is very frequently copied. struct PrintingPolicy { - enum SuppressInlineNamespaceMode : uint8_t { None, Redundant, All }; + enum class SuppressInlineNamespaceMode : uint8_t { None, Redundant, All }; /// Create a default printing policy for the specified language. PrintingPolicy(const LangOptions &LO) : Indentation(2), SuppressSpecifiers(false), SuppressTagKeyword(LO.CPlusPlus), IncludeTagDefinition(false), SuppressScope(false), SuppressUnwrittenScope(false), - SuppressInlineNamespace(SuppressInlineNamespaceMode::Redundant), + SuppressInlineNamespace( + llvm::to_underlying(SuppressInlineNamespaceMode::Redundant)), SuppressInitializers(false), ConstantArraySizeAsWritten(false), AnonymousTagLocations(true), SuppressStrongLifetime(false), SuppressLifetimeQualifiers(false), diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 591457b1d66b4..4444b10db8cc0 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -1753,9 +1753,11 @@ void NamedDecl::printNestedNameSpecifier(raw_ostream &OS, // Suppress inline namespace if it doesn't make the result ambiguous. if (Ctx->isInlineNamespace() && NameInScope) { if (P.SuppressInlineNamespace == - PrintingPolicy::SuppressInlineNamespaceMode::All || + llvm::to_underlying( + PrintingPolicy::SuppressInlineNamespaceMode::All) || (P.SuppressInlineNamespace == - PrintingPolicy::SuppressInlineNamespaceMode::Redundant && + llvm::to_underlying( + PrintingPolicy::SuppressInlineNamespaceMode::Redundant) && cast(Ctx)->isRedundantInlineQualifierFor( NameInScope))) { continue; diff --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp index fbb8b49676045..a556ffca96903 100644 --- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp +++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp @@ -654,9 +654,9 @@ bool HasNameMatcher::matchesNodeFullSlow(const NamedDecl &Node) const { PrintingPolicy Policy = Node.getASTContext().getPrintingPolicy(); Policy.SuppressUnwrittenScope = SkipUnwritten; - Policy.SuppressInlineNamespace = + Policy.SuppressInlineNamespace = llvm::to_underlying( SkipUnwritten ? PrintingPolicy::SuppressInlineNamespaceMode::All - : PrintingPolicy::SuppressInlineNamespaceMode::None; + : PrintingPolicy::SuppressInlineNamespaceMode::None); Node.printQualifiedName(OS, Policy); const StringRef FullName = OS.str(); diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp index efc2c6c0ba500..24b106b4bcee7 100644 --- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp @@ -97,7 +97,8 @@ std::string CIRGenTypes::getRecordTypeName(const clang::RecordDecl *recordDecl, llvm::raw_svector_ostream outStream(typeName); PrintingPolicy policy = recordDecl->getASTContext().getPrintingPolicy(); - policy.SuppressInlineNamespace = false; + policy.SuppressInlineNamespace = + llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::None); policy.AlwaysIncludeTypeForTemplateArgument = true; policy.PrintAsCanonical = true; policy.SuppressTagKeyword = true; diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index c50f372c1f331..5a83c151901f9 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -417,7 +417,7 @@ PrintingPolicy CGDebugInfo::getPrintingPolicy() const { } PP.SuppressInlineNamespace = - PrintingPolicy::SuppressInlineNamespaceMode::None; + llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::None); PP.PrintAsCanonical = true; PP.UsePreferredNames = false; PP.AlwaysIncludeTypeForTemplateArgument = true; diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp index ea31195b7f92e..be862cf07f177 100644 --- a/clang/lib/CodeGen/CodeGenTypes.cpp +++ b/clang/lib/CodeGen/CodeGenTypes.cpp @@ -62,7 +62,7 @@ void CodeGenTypes::addRecordTypeName(const RecordDecl *RD, // FullyQualifiedNames. PrintingPolicy Policy = RD->getASTContext().getPrintingPolicy(); Policy.SuppressInlineNamespace = - PrintingPolicy::SuppressInlineNamespaceMode::None; + llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::None); // Name the codegen type after the typedef name // if there is no tag type name available diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index aa8d309fbc730..2cb4a46130c84 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -2149,7 +2149,8 @@ PrintingPolicy TypeSystemClang::GetTypePrintingPolicy() { printing_policy.SuppressTagKeyword = true; // Inline namespaces are important for some type formatters (e.g., libc++ // and libstdc++ are differentiated by their inline namespaces). - printing_policy.SuppressInlineNamespace = false; + printing_policy.SuppressInlineNamespace = + llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::None); printing_policy.SuppressUnwrittenScope = false; // Default arguments are also always important for type formatters. Otherwise // we would need to always specify two type names for the setups where we do @@ -3870,7 +3871,9 @@ TypeSystemClang::GetDisplayTypeName(lldb::opaque_compiler_type_t type) { printing_policy.SuppressTagKeyword = true; printing_policy.SuppressScope = false; printing_policy.SuppressUnwrittenScope = true; - printing_policy.SuppressInlineNamespace = true; + // FIXME: should we suppress "All" inline namespaces? + printing_policy.SuppressInlineNamespace = llvm::to_underlying( + PrintingPolicy::SuppressInlineNamespaceMode::Redundant); return ConstString(qual_type.getAsString(printing_policy)); }