|
clang 24.0.0git
|
Describes how types, statements, expressions, and declarations should be printed. More...
#include "clang/AST/PrettyPrinter.h"
Public Types | |
| enum class | SuppressInlineNamespaceMode : uint8_t { None , Redundant , All } |
| enum class | AnonymousTagMode { Plain , SourceLocation } |
| Dictates how anonymous/unnamed entities are printed. More... | |
Public Member Functions | |
| PrintingPolicy (const LangOptions &LO) | |
| Create a default printing policy for the specified language. | |
| void | adjustForCPlusPlus () |
| Adjust this printing policy for cases where it's known that we're printing C++ code (for instance, if AST dumping reaches a C++-only construct). | |
Public Attributes | |
| unsigned | Indentation: 8 |
| The number of spaces to use to indent each line. | |
| unsigned | SuppressSpecifiers: 1 |
| Whether we should suppress printing of the actual specifiers for the given type or declaration. | |
| unsigned | SuppressTagKeyword: 1 |
| Whether type printing should skip printing the tag keyword. | |
| unsigned | SuppressTagKeywordInAnonNames: 1 |
| Whether type printing should skip printing the tag keyword of anonymous entities. | |
| unsigned | IncludeTagDefinition: 1 |
| When true, include the body of a tag definition. | |
| unsigned | SuppressScope: 1 |
| Suppresses printing of scope specifiers. | |
| unsigned | SuppressUnwrittenScope: 1 |
| Suppress printing parts of scope specifiers that are never written, e.g., for anonymous namespaces. | |
| unsigned | SuppressInlineNamespace: 2 |
| Suppress printing parts of scope specifiers that correspond to inline namespaces. | |
| unsigned | SuppressInitializers: 1 |
| Suppress printing of variable initializers. | |
| unsigned | ConstantArraySizeAsWritten: 1 |
| Whether we should print the sizes of constant array expressions as written in the sources. | |
| unsigned | AnonymousTagNameStyle: 1 |
| unsigned | SuppressStrongLifetime: 1 |
| When true, suppress printing of the __strong lifetime qualifier in ARC. | |
| unsigned | SuppressLifetimeQualifiers: 1 |
| When true, suppress printing of lifetime qualifier in ARC. | |
| unsigned | SuppressTemplateArgsInCXXConstructors: 1 |
| When true, suppresses printing template arguments in names of C++ constructors. | |
| unsigned | SuppressDefaultTemplateArgs: 1 |
| When true, attempt to suppress template arguments that match the default argument for the parameter. | |
| unsigned | Bool: 1 |
| Whether we can use 'bool' rather than '_Bool' (even if the language doesn't actually have 'bool', because, e.g., it is defined as a macro). | |
| unsigned | Nullptr: 1 |
| Whether we should use 'nullptr' rather than '0' as a null pointer constant. | |
| unsigned | NullptrTypeInNamespace: 1 |
| Whether 'nullptr_t' is in namespace 'std' or not. | |
| unsigned | Restrict: 1 |
| Whether we can use 'restrict' rather than '__restrict'. | |
| unsigned | Alignof: 1 |
| Whether we can use 'alignof' rather than '__alignof'. | |
| unsigned | UnderscoreAlignof: 1 |
| Whether we can use '_Alignof' rather than '__alignof'. | |
| unsigned | UseVoidForZeroParams: 1 |
| Whether we should use '(void)' rather than '()' for a function prototype with zero parameters. | |
| unsigned | SplitTemplateClosers: 1 |
| Whether nested templates must be closed like 'a<b<c> >' rather than 'a<b<c>>'. | |
| unsigned | TerseOutput: 1 |
| Provide a 'terse' output. | |
| unsigned | PolishForDeclaration: 1 |
| When true, do certain refinement needed for producing proper declaration tag; such as, do not print attributes attached to the declaration. | |
| unsigned | Half: 1 |
| When true, print the half-precision floating-point type as 'half' instead of '__fp16'. | |
| unsigned | MSWChar: 1 |
| When true, print the built-in wchar_t type as __wchar_t. | |
| unsigned | IncludeNewlines: 1 |
| When true, include newlines after statements like "break", etc. | |
| unsigned | ResolveDecltype: 1 |
| Use whitespace and punctuation like MSVC does. | |
| unsigned | EntireContentsOfLargeArray: 1 |
| Whether to print the entire array initializers, especially on non-type template parameters, no matter how many elements there are. | |
| unsigned | PrettyEnums: 1 |
| Whether to print enumerators with a matching enumerator name or via cast. | |
| unsigned | UseEnumerators: 1 |
| Whether to print enumerator non-type template parameters with a matching enumerator name or via cast of an integer. | |
| unsigned | UseHLSLTypes: 1 |
| Whether or not we're printing known HLSL code and should print HLSL sugared types when possible. | |
| unsigned | SuppressDeclAttributes: 1 |
| Whether to suppress attributes in decl printing. | |
| unsigned | SuppressLambdaBody: 1 |
| Whether to suppress printing the body of a lambda. | |
| const PrintingCallbacks * | Callbacks = nullptr |
| Callbacks to use to allow the behavior of printing to be customized. | |
Describes how types, statements, expressions, and declarations should be printed.
This type is intended to be small and suitable for passing by value. It is very frequently copied.
Definition at line 58 of file PrettyPrinter.h.
|
strong |
Dictates how anonymous/unnamed entities are printed.
| Enumerator | |
|---|---|
| Plain | E.g., (anonymous enum)/(unnamed struct)/etc. |
| SourceLocation | When printing an anonymous tag name, also print the location of that entity (e.g., "enum <anonymous at t.h:10:5>"). |
Definition at line 62 of file PrettyPrinter.h.
|
strong |
| Enumerator | |
|---|---|
| None | |
| Redundant | |
| All | |
Definition at line 59 of file PrettyPrinter.h.
|
inline |
Create a default printing policy for the specified language.
Definition at line 72 of file PrettyPrinter.h.
References Alignof, AnonymousTagNameStyle, Bool, clang::C11, clang::C23, clang::C99, ConstantArraySizeAsWritten, clang::CPlusPlus, clang::CPlusPlus11, EntireContentsOfLargeArray, false, Half, clang::HLSL, IncludeNewlines, IncludeTagDefinition, Indentation, MSWChar, Nullptr, NullptrTypeInNamespace, PolishForDeclaration, PrettyEnums, Redundant, ResolveDecltype, Restrict, SourceLocation, SplitTemplateClosers, SuppressDeclAttributes, SuppressDefaultTemplateArgs, SuppressInitializers, SuppressInlineNamespace, SuppressLambdaBody, SuppressLifetimeQualifiers, SuppressScope, SuppressSpecifiers, SuppressStrongLifetime, SuppressTagKeyword, SuppressTagKeywordInAnonNames, SuppressTemplateArgsInCXXConstructors, SuppressUnwrittenScope, TerseOutput, true, UnderscoreAlignof, UseEnumerators, UseHLSLTypes, and UseVoidForZeroParams.
|
inline |
Adjust this printing policy for cases where it's known that we're printing C++ code (for instance, if AST dumping reaches a C++-only construct).
This should not be used if a real LangOptions object is available.
Definition at line 104 of file PrettyPrinter.h.
References Bool, SuppressTagKeyword, and UseVoidForZeroParams.
Referenced by clang::DeclarationName::print(), printCXXConstructorDestructorName(), and clang::DeclarationNameInfo::printName().
| unsigned clang::PrintingPolicy::Alignof |
Whether we can use 'alignof' rather than '__alignof'.
Definition at line 252 of file PrettyPrinter.h.
Referenced by PrintingPolicy().
| unsigned clang::PrintingPolicy::AnonymousTagNameStyle |
Definition at line 212 of file PrettyPrinter.h.
Referenced by clang::ExtractAPIAction::CreateASTConsumer(), clang::WrappingExtractAPIAction::CreateASTConsumer(), getCompletionPrintingPolicy(), clang::GetFullTypeName(), clang::TagDecl::printAnonymousTagDecl(), PrintingPolicy(), and printQualifier().
| unsigned clang::PrintingPolicy::Bool |
Whether we can use 'bool' rather than '_Bool' (even if the language doesn't actually have 'bool', because, e.g., it is defined as a macro).
Definition at line 235 of file PrettyPrinter.h.
Referenced by adjustForCPlusPlus(), clang::BuiltinType::getName(), clang::Sema::getPrintingPolicy(), clang::DeclSpec::getSpecifierName(), and PrintingPolicy().
| const PrintingCallbacks* clang::PrintingPolicy::Callbacks = nullptr |
Callbacks to use to allow the behavior of printing to be customized.
Definition at line 392 of file PrettyPrinter.h.
Referenced by clang::PredefinedExpr::ComputeName(), clang::TagDecl::printAnonymousTagDeclLocation(), and clang::NamedDecl::printNestedNameSpecifier().
| unsigned clang::PrintingPolicy::ConstantArraySizeAsWritten |
Whether we should print the sizes of constant array expressions as written in the sources.
This flag determines whether array types declared as
will be printed as written or as follows:
Definition at line 209 of file PrettyPrinter.h.
Referenced by PrintingPolicy(), and printQualifier().
| unsigned clang::PrintingPolicy::EntireContentsOfLargeArray |
Whether to print the entire array initializers, especially on non-type template parameters, no matter how many elements there are.
Definition at line 366 of file PrettyPrinter.h.
Referenced by clang::Sema::getPrintingPolicy(), PrintingPolicy(), clang::APValue::printPretty(), and TryPrintAsStringLiteral().
| unsigned clang::PrintingPolicy::Half |
When true, print the half-precision floating-point type as 'half' instead of '__fp16'.
Definition at line 285 of file PrettyPrinter.h.
Referenced by clang::BuiltinType::getName(), and PrintingPolicy().
| unsigned clang::PrintingPolicy::IncludeNewlines |
When true, include newlines after statements like "break", etc.
Definition at line 294 of file PrettyPrinter.h.
Referenced by getAPINotesParameterSelectorPrintingPolicy(), print_elem(), and PrintingPolicy().
| unsigned clang::PrintingPolicy::IncludeTagDefinition |
When true, include the body of a tag definition.
This is used to place the definition of a struct in the middle of another declaration as with:
Definition at line 159 of file PrettyPrinter.h.
Referenced by PrintingPolicy().
| unsigned clang::PrintingPolicy::Indentation |
The number of spaces to use to indent each line.
Definition at line 111 of file PrettyPrinter.h.
Referenced by PrintingPolicy().
| unsigned clang::PrintingPolicy::MSWChar |
When true, print the built-in wchar_t type as __wchar_t.
For use in Microsoft mode when wchar_t is not available.
Definition at line 290 of file PrettyPrinter.h.
Referenced by clang::BuiltinType::getName(), clang::DeclSpec::getSpecifierName(), and PrintingPolicy().
| unsigned clang::PrintingPolicy::Nullptr |
Whether we should use 'nullptr' rather than '0' as a null pointer constant.
Definition at line 240 of file PrettyPrinter.h.
Referenced by PrintingPolicy(), and clang::APValue::printPretty().
| unsigned clang::PrintingPolicy::NullptrTypeInNamespace |
Whether 'nullptr_t' is in namespace 'std' or not.
Definition at line 244 of file PrettyPrinter.h.
Referenced by clang::BuiltinType::getName(), and PrintingPolicy().
| unsigned clang::PrintingPolicy::PolishForDeclaration |
When true, do certain refinement needed for producing proper declaration tag; such as, do not print attributes attached to the declaration.
Definition at line 280 of file PrettyPrinter.h.
Referenced by PrintingPolicy().
| unsigned clang::PrintingPolicy::PrettyEnums |
Whether to print enumerators with a matching enumerator name or via cast.
Definition at line 371 of file PrettyPrinter.h.
Referenced by PrintingPolicy().
| unsigned clang::PrintingPolicy::ResolveDecltype |
Use whitespace and punctuation like MSVC does.
In particular, this prints anonymous namespaces as ‘anonymous namespace’ and does not insert spaces / after template arguments.
unsigned MSVCFormatting : 1;
/ Whether we should print the constant expressions as written in the / sources. / / This flag determines whether constants expressions like / /
/ / will be printed as written or as follows: / /
unsigned ConstantsAsWritten : 1;
/ When true, don't print the implicit 'self' or 'this' expressions.
unsigned SuppressImplicitBase : 1;
/ When true, print the fully qualified name of function declarations. / This is the opposite of SuppressScope and thus overrules it.
unsigned FullyQualifiedName : 1;
/ Whether to print entities as written or canonically.
unsigned PrintAsCanonical : 1;
/ Whether to print an InjectedClassNameType with template arguments or as / written. When a template argument is unnamed, printing it results in / invalid C++ code.
unsigned PrintInjectedClassNameWithArguments : 1;
/ Whether to use C++ template preferred_name attributes when printing / templates.
unsigned UsePreferredNames : 1;
/ Whether to use type suffixes (eg: 1U) on integral non-type template / parameters.
unsigned AlwaysIncludeTypeForTemplateArgument : 1;
/ Whether to strip underscores when printing reserved parameter names. / e.g. std::vector<class _Tp> becomes std::vector<class Tp>. / This only affects parameter names, and so describes a compatible API.
unsigned CleanUglifiedParameters : 1;
/ Whether to print the type a non-dependent decltype(expr) resolves to, / rather than the decltype specifier itself. Intended for display / contexts such as code completion, where int is more informative than / decltype(x); it does not describe how the type was spelled.
Definition at line 361 of file PrettyPrinter.h.
Referenced by getCompletionPrintingPolicy(), and PrintingPolicy().
| unsigned clang::PrintingPolicy::Restrict |
Whether we can use 'restrict' rather than '__restrict'.
Definition at line 248 of file PrettyPrinter.h.
Referenced by clang::Qualifiers::print(), and PrintingPolicy().
| unsigned clang::PrintingPolicy::SplitTemplateClosers |
Whether nested templates must be closed like 'a<b<c> >' rather than 'a<b<c>>'.
Definition at line 266 of file PrettyPrinter.h.
Referenced by getAPINotesParameterSelectorPrintingPolicy(), PrintingPolicy(), printTo(), and QualTypeToString().
| unsigned clang::PrintingPolicy::SuppressDeclAttributes |
Whether to suppress attributes in decl printing.
Definition at line 385 of file PrettyPrinter.h.
Referenced by PrintingPolicy().
| unsigned clang::PrintingPolicy::SuppressDefaultTemplateArgs |
When true, attempt to suppress template arguments that match the default argument for the parameter.
Definition at line 230 of file PrettyPrinter.h.
Referenced by PrintingPolicy(), printTo(), and QualTypeToString().
| unsigned clang::PrintingPolicy::SuppressInitializers |
Suppress printing of variable initializers.
This flag is used when printing the loop variable in a for-range statement. For example, given:
SuppressInitializers will be true when printing "auto x", so that the internal initializer constructed for x will not be printed.
Definition at line 190 of file PrettyPrinter.h.
Referenced by PrintingPolicy().
| unsigned clang::PrintingPolicy::SuppressInlineNamespace |
Suppress printing parts of scope specifiers that correspond to inline namespaces.
If Redundant, where the name is unambiguous with the specifier removed. If All, even if the name is ambiguous with the specifier removed.
Definition at line 176 of file PrettyPrinter.h.
Referenced by clang::CodeGen::CodeGenTypes::addRecordTypeName(), clang::CIRGen::CIRGenTypes::getRecordTypeName(), PrintingPolicy(), and clang::NamedDecl::printNestedNameSpecifier().
| unsigned clang::PrintingPolicy::SuppressLambdaBody |
Whether to suppress printing the body of a lambda.
Definition at line 389 of file PrettyPrinter.h.
Referenced by clang::interp::InterpFrame::describe(), and PrintingPolicy().
| unsigned clang::PrintingPolicy::SuppressLifetimeQualifiers |
When true, suppress printing of lifetime qualifier in ARC.
Definition at line 220 of file PrettyPrinter.h.
Referenced by PrintingPolicy().
| unsigned clang::PrintingPolicy::SuppressScope |
Suppresses printing of scope specifiers.
Definition at line 163 of file PrettyPrinter.h.
Referenced by getAPINotesParameterSelectorPrintingPolicy(), clang::GetFullTypeName(), clang::TemplateName::print(), printCXXConstructorDestructorName(), PrintingPolicy(), and clang::DeclarationNameInfo::printName().
| unsigned clang::PrintingPolicy::SuppressSpecifiers |
Whether we should suppress printing of the actual specifiers for the given type or declaration.
This flag is only used when we are printing declarators beyond the first declarator within a declaration group. For example, given:
SuppressSpecifiers will be false when printing the declaration for "x", so that we will print "int *x"; it will be true when we print "y", so that we suppress printing the "const int" type specifier and instead only print the "*y".
Definition at line 128 of file PrettyPrinter.h.
Referenced by clang::Decl::printGroup(), and PrintingPolicy().
| unsigned clang::PrintingPolicy::SuppressStrongLifetime |
When true, suppress printing of the __strong lifetime qualifier in ARC.
Definition at line 216 of file PrettyPrinter.h.
Referenced by getCompletionPrintingPolicy(), clang::Qualifiers::isEmptyWhenPrinted(), clang::Qualifiers::print(), clang::TemplateArgument::print(), and PrintingPolicy().
| unsigned clang::PrintingPolicy::SuppressTagKeyword |
Whether type printing should skip printing the tag keyword.
This is used when printing the inner type of elaborated types, (as the tag keyword is part of the elaborated type):
Definition at line 139 of file PrettyPrinter.h.
Referenced by adjustForCPlusPlus(), clang::PredefinedExpr::ComputeName(), clang::infer_alloc::getAllocTokenMetadata(), clang::CIRGen::CIRGenTypes::getRecordTypeName(), clang::NestedNameSpecifier::print(), clang::TagDecl::printAnonymousTagDecl(), PrintingPolicy(), and printQualifier().
| unsigned clang::PrintingPolicy::SuppressTagKeywordInAnonNames |
Whether type printing should skip printing the tag keyword of anonymous entities.
E.g.,
(anonymous) as opopsed to (anonymous struct)(unnamed) as opposed to (unnamed enum) Definition at line 148 of file PrettyPrinter.h.
Referenced by clang::TagDecl::printAnonymousTagDecl(), and PrintingPolicy().
| unsigned clang::PrintingPolicy::SuppressTemplateArgsInCXXConstructors |
When true, suppresses printing template arguments in names of C++ constructors.
Definition at line 225 of file PrettyPrinter.h.
Referenced by clang::CodeCompleteConsumer::OverloadCandidate::CreateSignatureString(), printCXXConstructorDestructorName(), PrintingPolicy(), and clang::index::printSymbolName().
| unsigned clang::PrintingPolicy::SuppressUnwrittenScope |
Suppress printing parts of scope specifiers that are never written, e.g., for anonymous namespaces.
Definition at line 168 of file PrettyPrinter.h.
Referenced by getCompletionPrintingPolicy(), clang::TemplateName::print(), PrintingPolicy(), clang::NamedDecl::printNestedNameSpecifier(), printQualifier(), and QualTypeToString().
| unsigned clang::PrintingPolicy::TerseOutput |
Provide a 'terse' output.
For example, in this mode we don't print function bodies, class members, declarations inside namespaces etc. Effectively, this should print only the requested declaration.
Definition at line 274 of file PrettyPrinter.h.
Referenced by clang::StackFrame::dumpStack(), noteLocation(), PrintingPolicy(), and clang::StackFrame::printJson().
| unsigned clang::PrintingPolicy::UnderscoreAlignof |
Whether we can use '_Alignof' rather than '__alignof'.
Definition at line 256 of file PrettyPrinter.h.
Referenced by PrintingPolicy().
| unsigned clang::PrintingPolicy::UseEnumerators |
Whether to print enumerator non-type template parameters with a matching enumerator name or via cast of an integer.
Definition at line 376 of file PrettyPrinter.h.
Referenced by PrintingPolicy(), and printIntegral().
| unsigned clang::PrintingPolicy::UseHLSLTypes |
Whether or not we're printing known HLSL code and should print HLSL sugared types when possible.
Definition at line 381 of file PrettyPrinter.h.
Referenced by PrintingPolicy().
| unsigned clang::PrintingPolicy::UseVoidForZeroParams |
Whether we should use '(void)' rather than '()' for a function prototype with zero parameters.
Definition at line 261 of file PrettyPrinter.h.
Referenced by adjustForCPlusPlus(), and PrintingPolicy().