]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/AST/PrettyPrinter.h
Update to BIND 9.6.3, the latest from ISC on the 9.6 branch.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / AST / PrettyPrinter.h
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
17 namespace llvm {
18   class raw_ostream;
19 }
20
21 namespace clang {
22
23 class Stmt;
24 class TagDecl;
25 class LangOptions;
26
27 class PrinterHelper {
28 public:
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.
35 struct 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),
41       AnonymousTagLocations(true) { }
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;
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;
106 };
107
108 } // end namespace clang
109
110 #endif