clang  6.0.0svn
Public Member Functions | Public Attributes | List of all members
clang::PrintingPolicy Struct Reference

Describes how types, statements, expressions, and declarations should be printed. More...

#include "clang/AST/PrettyPrinter.h"

Collaboration diagram for clang::PrintingPolicy:
Collaboration graph
[legend]

Public Member Functions

 PrintingPolicy (const LangOptions &LO)
 Create a default printing policy for the specified language. More...
 
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). More...
 

Public Attributes

unsigned Indentation: 8
 The number of spaces to use to indent each line. More...
 
bool SuppressSpecifiers: 1
 Whether we should suppress printing of the actual specifiers for the given type or declaration. More...
 
bool SuppressTagKeyword: 1
 Whether type printing should skip printing the tag keyword. More...
 
bool IncludeTagDefinition: 1
 When true, include the body of a tag definition. More...
 
bool SuppressScope: 1
 Suppresses printing of scope specifiers. More...
 
bool SuppressUnwrittenScope: 1
 Suppress printing parts of scope specifiers that don't need to be written, e.g., for inline or anonymous namespaces. More...
 
bool SuppressInitializers: 1
 Suppress printing of variable initializers. More...
 
bool ConstantArraySizeAsWritten: 1
 Whether we should print the sizes of constant array expressions as written in the sources. More...
 
bool AnonymousTagLocations: 1
 When printing an anonymous tag name, also print the location of that entity (e.g., "enum <anonymous at t.h:10:5>"). More...
 
unsigned SuppressStrongLifetime: 1
 When true, suppress printing of the __strong lifetime qualifier in ARC. More...
 
unsigned SuppressLifetimeQualifiers: 1
 When true, suppress printing of lifetime qualifier in ARC. More...
 
unsigned SuppressTemplateArgsInCXXConstructors: 1
 When true, suppresses printing template arguments in names of C++ constructors. More...
 
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). More...
 
unsigned Restrict: 1
 Whether we can use 'restrict' rather than '__restrict'. More...
 
unsigned Alignof: 1
 Whether we can use 'alignof' rather than '__alignof'. More...
 
unsigned UnderscoreAlignof: 1
 Whether we can use '_Alignof' rather than '__alignof'. More...
 
unsigned UseVoidForZeroParams: 1
 Whether we should use '(void)' rather than '()' for a function prototype with zero parameters. More...
 
unsigned TerseOutput: 1
 Provide a 'terse' output. More...
 
unsigned PolishForDeclaration: 1
 When true, do certain refinement needed for producing proper declaration tag; such as, do not print attributes attached to the declaration. More...
 
unsigned Half: 1
 When true, print the half-precision floating-point type as 'half' instead of '__fp16'. More...
 
unsigned MSWChar: 1
 When true, print the built-in wchar_t type as __wchar_t. More...
 
unsigned IncludeNewlines: 1
 When true, include newlines after statements like "break", etc. More...
 
bool MSVCFormatting: 1
 Use whitespace and punctuation like MSVC does. More...
 
bool ConstantsAsWritten
 Whether we should print the constant expressions as written in the sources. More...
 

Detailed Description

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 38 of file PrettyPrinter.h.

Constructor & Destructor Documentation

◆ PrintingPolicy()

clang::PrintingPolicy::PrintingPolicy ( const LangOptions LO)
inline

Create a default printing policy for the specified language.

Definition at line 40 of file PrettyPrinter.h.

Member Function Documentation

◆ adjustForCPlusPlus()

void clang::PrintingPolicy::adjustForCPlusPlus ( )
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 60 of file PrettyPrinter.h.

Referenced by clang::DeclarationName::print(), and clang::printCXXConstructorDestructorName().

Member Data Documentation

◆ Alignof

unsigned clang::PrintingPolicy::Alignof

Whether we can use 'alignof' rather than '__alignof'.

Definition at line 168 of file PrettyPrinter.h.

Referenced by PrintFloatingLiteral().

◆ AnonymousTagLocations

bool clang::PrintingPolicy::AnonymousTagLocations

When printing an anonymous tag name, also print the location of that entity (e.g., "enum <anonymous at t.h:10:5>").

Otherwise, just prints "(anonymous)" for the name.

Definition at line 146 of file PrettyPrinter.h.

Referenced by clang::diff::SyntaxTree::Impl::Impl().

◆ Bool

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 162 of file PrettyPrinter.h.

Referenced by clang::BuiltinType::getName(), and clang::DeclSpec::getSpecifierName().

◆ ConstantArraySizeAsWritten

bool 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

int a[4+10*10];
char a[] = "A string";

will be printed as written or as follows:

int a[104];
char a[9] = "A string";

Definition at line 141 of file PrettyPrinter.h.

◆ ConstantsAsWritten

bool clang::PrintingPolicy::ConstantsAsWritten

Whether we should print the constant expressions as written in the sources.

This flag determines whether constants expressions like

0x10
2.5e3

will be printed as written or as follows:

0x10
2.5e3

Definition at line 221 of file PrettyPrinter.h.

Referenced by printExprAsWritten(), and PrintFloatingLiteral().

◆ Half

unsigned clang::PrintingPolicy::Half

When true, print the half-precision floating-point type as 'half' instead of '__fp16'.

Definition at line 191 of file PrettyPrinter.h.

Referenced by clang::BuiltinType::getName().

◆ IncludeNewlines

unsigned clang::PrintingPolicy::IncludeNewlines

When true, include newlines after statements like "break", etc.

Definition at line 198 of file PrettyPrinter.h.

◆ IncludeTagDefinition

bool 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:

typedef struct { int x, y; } Point;

Definition at line 103 of file PrettyPrinter.h.

Referenced by AppendTypeQualList(), clang::getParameterABISpelling(), and clang::Decl::printGroup().

◆ Indentation

unsigned clang::PrintingPolicy::Indentation

The number of spaces to use to indent each line.

Definition at line 67 of file PrettyPrinter.h.

◆ MSVCFormatting

bool clang::PrintingPolicy::MSVCFormatting

Use whitespace and punctuation like MSVC does.

In particular, this prints anonymous namespaces as `anonymous namespace' and does not insert spaces after template arguments.

Definition at line 203 of file PrettyPrinter.h.

Referenced by printIntegral().

◆ MSWChar

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 195 of file PrettyPrinter.h.

Referenced by clang::BuiltinType::getName(), and clang::DeclSpec::getSpecifierName().

◆ PolishForDeclaration

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 187 of file PrettyPrinter.h.

◆ Restrict

unsigned clang::PrintingPolicy::Restrict

Whether we can use 'restrict' rather than '__restrict'.

Definition at line 165 of file PrettyPrinter.h.

◆ SuppressInitializers

bool 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:

for (auto x : coll)

SuppressInitializers will be true when printing "auto x", so that the internal initializer constructed for x will not be printed.

Definition at line 123 of file PrettyPrinter.h.

◆ SuppressLifetimeQualifiers

unsigned clang::PrintingPolicy::SuppressLifetimeQualifiers

When true, suppress printing of lifetime qualifier in ARC.

Definition at line 154 of file PrettyPrinter.h.

◆ SuppressScope

bool clang::PrintingPolicy::SuppressScope

Suppresses printing of scope specifiers.

Definition at line 106 of file PrettyPrinter.h.

Referenced by clang::TypeName::getFullyQualifiedName(), and clang::NestedNameSpecifier::print().

◆ SuppressSpecifiers

bool 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:

const int *x, *y;

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 83 of file PrettyPrinter.h.

Referenced by clang::Decl::printGroup().

◆ SuppressStrongLifetime

unsigned clang::PrintingPolicy::SuppressStrongLifetime

When true, suppress printing of the __strong lifetime qualifier in ARC.

Definition at line 150 of file PrettyPrinter.h.

Referenced by clang::TemplateArgument::print(), and rewriteToObjCProperty().

◆ SuppressTagKeyword

bool 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):

struct Geometry::Point;

Definition at line 93 of file PrettyPrinter.h.

◆ SuppressTemplateArgsInCXXConstructors

unsigned clang::PrintingPolicy::SuppressTemplateArgsInCXXConstructors

When true, suppresses printing template arguments in names of C++ constructors.

Definition at line 158 of file PrettyPrinter.h.

Referenced by clang::printCXXConstructorDestructorName(), and clang::index::printSymbolName().

◆ SuppressUnwrittenScope

bool clang::PrintingPolicy::SuppressUnwrittenScope

Suppress printing parts of scope specifiers that don't need to be written, e.g., for inline or anonymous namespaces.

Definition at line 110 of file PrettyPrinter.h.

◆ TerseOutput

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 182 of file PrettyPrinter.h.

◆ UnderscoreAlignof

unsigned clang::PrintingPolicy::UnderscoreAlignof

Whether we can use '_Alignof' rather than '__alignof'.

Definition at line 171 of file PrettyPrinter.h.

Referenced by PrintFloatingLiteral().

◆ UseVoidForZeroParams

unsigned clang::PrintingPolicy::UseVoidForZeroParams

Whether we should use '(void)' rather than '()' for a function prototype with zero parameters.

Definition at line 175 of file PrettyPrinter.h.


The documentation for this struct was generated from the following file: