aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Frontend/DeclXML.def
blob: 8b80d1dc11d8cbfd5bf2b81a2efcca796cef28bf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
//===-- DeclXML.def - Metadata about Decl XML nodes ------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//  This file defines the XML statement database structure as written in 
//  <TranslationUnit> sub-nodes of the XML document. 
//  The semantics of the attributes and enums are mostly self-documenting
//  by looking at the appropriate internally used functions and values.
//  The following macros are used:
//
//  NODE_XML( CLASS, NAME ) - A node of name NAME denotes a concrete 
//  statement of class CLASS where CLASS is a class name used internally by clang. 
//  After a NODE_XML the definition of all (optional) attributes of that statement 
//  node and possible sub-nodes follows.
//
//  END_NODE_XML - Closes the attribute definition of the current node.
//
//  ID_ATTRIBUTE_XML - Some statement nodes have an "id" attribute containing a 
//  string, which value uniquely identify that statement. Other nodes may refer 
//  by reference attributes to this value (currently used only for Label).
//
//  TYPE_ATTRIBUTE_XML( FN ) - Type nodes refer to the result type id of an
//  expression by a "type" attribute. FN is internally used by clang.
// 
//  ATTRIBUTE_XML( FN, NAME ) - An attribute named NAME. FN is internally 
//  used by clang. A boolean attribute have the values "0" or "1".
//
//  ATTRIBUTE_SPECIAL_XML( FN, NAME ) - An attribute named NAME which deserves 
//  a special handling. See the appropriate documentations. 
//
//  ATTRIBUTE_FILE_LOCATION_XML - A bunch of attributes denoting the location of
//  a statement in the source file(s).
//
//  ATTRIBUTE_OPT_XML( FN, NAME ) - An optional attribute named NAME. 
//  Optional attributes are omitted for boolean types, if the value is false, 
//  for integral types, if the value is null and for strings, 
//  if the value is the empty string. FN is internally used by clang.
//
//  ATTRIBUTE_ENUM[_OPT]_XML( FN, NAME ) - An attribute named NAME. The value
//  is an enumeration defined with ENUM_XML macros immediately following after 
//  that macro. An optional attribute is ommited, if the particular enum is the 
//  empty string. FN is internally used by clang.
//  
//  ENUM_XML( VALUE, NAME ) - An enumeration element named NAME. VALUE is 
//  internally used by clang.
//
//  END_ENUM_XML - Closes the enumeration definition of the current attribute.
//
//  SUB_NODE_XML( CLASS ) - A mandatory sub-node of class CLASS or its sub-classes.
//
//  SUB_NODE_OPT_XML( CLASS ) - An optional sub-node of class CLASS or its sub-classes.
//
//  SUB_NODE_SEQUENCE_XML( CLASS ) - Zero or more sub-nodes of class CLASS or 
//  its sub-classes.
//
//===----------------------------------------------------------------------===//

#ifndef ATTRIBUTE_FILE_LOCATION_XML
#  define ATTRIBUTE_FILE_LOCATION_XML             \
     ATTRIBUTE_XML(getFilename(), "file")         \
     ATTRIBUTE_XML(getLine(), "line")             \
     ATTRIBUTE_XML(getColumn(), "col")            \
     ATTRIBUTE_OPT_XML(getFilename(), "endfile")  \
     ATTRIBUTE_OPT_XML(getLine(), "endline")      \
     ATTRIBUTE_OPT_XML(getColumn(), "endcol")
#endif

#ifndef TYPE_ATTRIBUTE_XML
#  define TYPE_ATTRIBUTE_XML( FN )    ATTRIBUTE_XML(FN, "type")
#endif

#ifndef CONTEXT_ATTRIBUTE_XML
#  define CONTEXT_ATTRIBUTE_XML( FN ) ATTRIBUTE_XML(FN, "context")
#endif

//NODE_XML(TranslationUnitDecl, "TranslationUnit")
//  SUB_NODE_SEQUENCE_XML(Decl)
//END_NODE_XML

NODE_XML(Decl, "FIXME_Decl")
  ATTRIBUTE_FILE_LOCATION_XML
END_NODE_XML

NODE_XML(FunctionDecl, "Function")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  TYPE_ATTRIBUTE_XML(getType()->getAs<FunctionType>()->getResultType())
  ATTRIBUTE_XML(getType()->getAs<FunctionType>(), "function_type")
  ATTRIBUTE_ENUM_OPT_XML(getStorageClass(), "storage_class")
	  ENUM_XML(FunctionDecl::None, "")
	  ENUM_XML(FunctionDecl::Extern, "extern")
	  ENUM_XML(FunctionDecl::Static, "static")
	  ENUM_XML(FunctionDecl::PrivateExtern, "__private_extern__")
  END_ENUM_XML
  ATTRIBUTE_OPT_XML(isInlineSpecified(), "inline")
  //ATTRIBUTE_OPT_XML(isVariadic(), "variadic")       // in the type reference
  ATTRIBUTE_XML(getNumParams(), "num_args")
  SUB_NODE_SEQUENCE_XML(ParmVarDecl)
  //SUB_NODE_OPT_XML("Body")
END_NODE_XML

NODE_XML(CXXMethodDecl, "CXXMethodDecl")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  TYPE_ATTRIBUTE_XML(getType()->getAs<FunctionType>()->getResultType())
  ATTRIBUTE_XML(getType()->getAs<FunctionType>(), "function_type")
  ATTRIBUTE_OPT_XML(isInlineSpecified(), "inline")
  ATTRIBUTE_OPT_XML(isStatic(), "static")       
  ATTRIBUTE_OPT_XML(isVirtual(), "virtual")       
  ATTRIBUTE_XML(getNumParams(), "num_args")
  SUB_NODE_SEQUENCE_XML(ParmVarDecl)
  //SUB_NODE_OPT_XML("Body")
END_NODE_XML

//NODE_XML("Body")
//  SUB_NODE_XML(Stmt)
//END_NODE_XML
  
NODE_XML(NamespaceDecl, "Namespace")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
END_NODE_XML

NODE_XML(UsingDirectiveDecl, "UsingDirective")
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  ATTRIBUTE_XML(getNominatedNamespace(), "ref")
END_NODE_XML

NODE_XML(NamespaceAliasDecl, "NamespaceAlias")
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  ATTRIBUTE_XML(getNamespace(), "ref")
END_NODE_XML

NODE_XML(RecordDecl, "Record")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  ATTRIBUTE_OPT_XML(isDefinition() == false, "forward")
  ATTRIBUTE_XML(getTypeForDecl(), "type")             // refers to the type this decl creates 
  SUB_NODE_SEQUENCE_XML(FieldDecl)
END_NODE_XML

NODE_XML(EnumDecl, "Enum")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  ATTRIBUTE_OPT_XML(isDefinition() == false, "forward")
  ATTRIBUTE_SPECIAL_XML(getIntegerType(), "type")     // is NULL in pure declarations thus deserves special handling 
  SUB_NODE_SEQUENCE_XML(EnumConstantDecl)             // only present in definition
END_NODE_XML

NODE_XML(EnumConstantDecl, "EnumConstant")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  TYPE_ATTRIBUTE_XML(getType())
  ATTRIBUTE_XML(getInitVal().toString(10, true), "value")     // integer
  SUB_NODE_OPT_XML(Expr)                                      // init expr of this constant
END_NODE_XML

NODE_XML(FieldDecl, "Field")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  TYPE_ATTRIBUTE_XML(getType())
  ATTRIBUTE_OPT_XML(isMutable(), "mutable")
  ATTRIBUTE_OPT_XML(isBitField(), "bitfield")
  SUB_NODE_OPT_XML(Expr)                                      // init expr of a bit field
END_NODE_XML

NODE_XML(TypedefDecl, "Typedef")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  TYPE_ATTRIBUTE_XML(getUnderlyingType())
END_NODE_XML

NODE_XML(VarDecl, "Var")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  TYPE_ATTRIBUTE_XML(getType())
  ATTRIBUTE_ENUM_OPT_XML(getStorageClass(), "storage_class")
	  ENUM_XML(VarDecl::None, "")
	  ENUM_XML(VarDecl::Auto, "auto")
	  ENUM_XML(VarDecl::Register, "register")
	  ENUM_XML(VarDecl::Extern, "extern")
	  ENUM_XML(VarDecl::Static, "static")
	  ENUM_XML(VarDecl::PrivateExtern, "__private_extern__")
  END_ENUM_XML
  SUB_NODE_OPT_XML(Expr)                                      // init expr 
END_NODE_XML

NODE_XML(ParmVarDecl, "ParmVar")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  TYPE_ATTRIBUTE_XML(getType())
  SUB_NODE_OPT_XML(Expr)                                      // default argument expression 
END_NODE_XML

NODE_XML(LinkageSpecDecl, "LinkageSpec")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_ENUM_OPT_XML(getLanguage(), "lang")
	  ENUM_XML(LinkageSpecDecl::lang_c, "C")
	  ENUM_XML(LinkageSpecDecl::lang_cxx, "CXX")
  END_ENUM_XML
END_NODE_XML


//===----------------------------------------------------------------------===//
#undef NODE_XML
#undef ID_ATTRIBUTE_XML                
#undef TYPE_ATTRIBUTE_XML
#undef ATTRIBUTE_XML
#undef ATTRIBUTE_SPECIAL_XML
#undef ATTRIBUTE_OPT_XML
#undef ATTRIBUTE_ENUM_XML
#undef ATTRIBUTE_ENUM_OPT_XML
#undef ATTRIBUTE_FILE_LOCATION_XML
#undef ENUM_XML
#undef END_ENUM_XML                    
#undef END_NODE_XML                    
#undef SUB_NODE_XML
#undef SUB_NODE_SEQUENCE_XML
#undef SUB_NODE_OPT_XML