1//===--- PrettyPrinter.h - Classes for aiding with AST printing -*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file defines the PrinterHelper interface. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_CLANG_AST_PRETTY_PRINTER_H 15#define LLVM_CLANG_AST_PRETTY_PRINTER_H 16 17namespace llvm { 18 class raw_ostream; 19} 20 21namespace clang { 22 23class Stmt; 24class TagDecl; 25class LangOptions; 26 27class PrinterHelper { 28public: 29 virtual ~PrinterHelper(); 30 virtual bool handledStmt(Stmt* E, llvm::raw_ostream& OS) = 0; 31}; 32 33/// \brief Describes how types, statements, expressions, and 34/// declarations should be printed. 35struct PrintingPolicy { 36 /// \brief Create a default printing policy for C. 37 PrintingPolicy(const LangOptions &LO) 38 : Indentation(2), LangOpts(LO), SuppressSpecifiers(false), 39 SuppressTag(false), SuppressScope(false),
| 1//===--- PrettyPrinter.h - Classes for aiding with AST printing -*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file defines the PrinterHelper interface. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_CLANG_AST_PRETTY_PRINTER_H 15#define LLVM_CLANG_AST_PRETTY_PRINTER_H 16 17namespace llvm { 18 class raw_ostream; 19} 20 21namespace clang { 22 23class Stmt; 24class TagDecl; 25class LangOptions; 26 27class PrinterHelper { 28public: 29 virtual ~PrinterHelper(); 30 virtual bool handledStmt(Stmt* E, llvm::raw_ostream& OS) = 0; 31}; 32 33/// \brief Describes how types, statements, expressions, and 34/// declarations should be printed. 35struct PrintingPolicy { 36 /// \brief Create a default printing policy for C. 37 PrintingPolicy(const LangOptions &LO) 38 : Indentation(2), LangOpts(LO), SuppressSpecifiers(false), 39 SuppressTag(false), SuppressScope(false),
|
40 Dump(false), ConstantArraySizeAsWritten(false) { }
| 40 Dump(false), ConstantArraySizeAsWritten(false), 41 AnonymousTagLocations(true) { }
|
41 42 /// \brief The number of spaces to use to indent each line. 43 unsigned Indentation : 8; 44 45 /// \brief What language we're printing. 46 const LangOptions &LangOpts; 47 48 /// \brief Whether we should suppress printing of the actual specifiers for 49 /// the given type or declaration. 50 /// 51 /// This flag is only used when we are printing declarators beyond 52 /// the first declarator within a declaration group. For example, given: 53 /// 54 /// \code 55 /// const int *x, *y; 56 /// \endcode 57 /// 58 /// SuppressSpecifiers will be false when printing the 59 /// declaration for "x", so that we will print "int *x"; it will be 60 /// \c true when we print "y", so that we suppress printing the 61 /// "const int" type specifier and instead only print the "*y". 62 bool SuppressSpecifiers : 1; 63 64 /// \brief Whether type printing should skip printing the actual tag type. 65 /// 66 /// This is used when the caller needs to print a tag definition in front 67 /// of the type, as in constructs like the following: 68 /// 69 /// \code 70 /// typedef struct { int x, y; } Point; 71 /// \endcode 72 bool SuppressTag : 1; 73 74 /// \brief Suppresses printing of scope specifiers. 75 bool SuppressScope : 1; 76 77 /// \brief True when we are "dumping" rather than "pretty-printing", 78 /// where dumping involves printing the internal details of the AST 79 /// and pretty-printing involves printing something similar to 80 /// source code. 81 bool Dump : 1; 82 83 /// \brief Whether we should print the sizes of constant array expressions 84 /// as written in the sources. 85 /// 86 /// This flag is determines whether arrays types declared as 87 /// 88 /// \code 89 /// int a[4+10*10]; 90 /// char a[] = "A string"; 91 /// \endcode 92 /// 93 /// will be printed as written or as follows: 94 /// 95 /// \code 96 /// int a[104]; 97 /// char a[9] = "A string"; 98 /// \endcode 99 bool ConstantArraySizeAsWritten : 1;
| 42 43 /// \brief The number of spaces to use to indent each line. 44 unsigned Indentation : 8; 45 46 /// \brief What language we're printing. 47 const LangOptions &LangOpts; 48 49 /// \brief Whether we should suppress printing of the actual specifiers for 50 /// the given type or declaration. 51 /// 52 /// This flag is only used when we are printing declarators beyond 53 /// the first declarator within a declaration group. For example, given: 54 /// 55 /// \code 56 /// const int *x, *y; 57 /// \endcode 58 /// 59 /// SuppressSpecifiers will be false when printing the 60 /// declaration for "x", so that we will print "int *x"; it will be 61 /// \c true when we print "y", so that we suppress printing the 62 /// "const int" type specifier and instead only print the "*y". 63 bool SuppressSpecifiers : 1; 64 65 /// \brief Whether type printing should skip printing the actual tag type. 66 /// 67 /// This is used when the caller needs to print a tag definition in front 68 /// of the type, as in constructs like the following: 69 /// 70 /// \code 71 /// typedef struct { int x, y; } Point; 72 /// \endcode 73 bool SuppressTag : 1; 74 75 /// \brief Suppresses printing of scope specifiers. 76 bool SuppressScope : 1; 77 78 /// \brief True when we are "dumping" rather than "pretty-printing", 79 /// where dumping involves printing the internal details of the AST 80 /// and pretty-printing involves printing something similar to 81 /// source code. 82 bool Dump : 1; 83 84 /// \brief Whether we should print the sizes of constant array expressions 85 /// as written in the sources. 86 /// 87 /// This flag is determines whether arrays types declared as 88 /// 89 /// \code 90 /// int a[4+10*10]; 91 /// char a[] = "A string"; 92 /// \endcode 93 /// 94 /// will be printed as written or as follows: 95 /// 96 /// \code 97 /// int a[104]; 98 /// char a[9] = "A string"; 99 /// \endcode 100 bool ConstantArraySizeAsWritten : 1;
|
100
| 101 102 /// \brief When printing an anonymous tag name, also print the location of 103 /// that entity (e.g., "enum <anonymous at t.h:10:5>"). Otherwise, just 104 /// prints "<anonymous>" for the name. 105 bool AnonymousTagLocations : 1;
|
101}; 102 103} // end namespace clang 104 105#endif
| 106}; 107 108} // end namespace clang 109 110#endif
|