Skip to content
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
6 changes: 4 additions & 2 deletions clang/include/clang/AST/PrettyPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "clang/Basic/LLVM.h"
#include "clang/Basic/LangOptions.h"
#include "llvm/ADT/STLForwardCompat.h"

namespace clang {

Expand Down Expand Up @@ -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),
Expand Down
6 changes: 4 additions & 2 deletions clang/lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NamespaceDecl>(Ctx)->isRedundantInlineQualifierFor(
NameInScope))) {
continue;
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/ASTMatchers/ASTMatchersInternal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/CIR/CodeGen/CIRGenTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CodeGenTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
}

Expand Down
Loading