Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit b9b7a4f

Browse files
author
Juanjo Alvarez
committed
Fix now-not-silently dropped fields
Signed-off-by: Juanjo Alvarez <[email protected]>
1 parent c6f9c91 commit b9b7a4f

File tree

83 files changed

+377618
-1808
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+377618
-1808
lines changed

driver/normalizer/normalizer.go

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ var Preprocessors = []Mapping{
3131

3232
func mapIASTNameDerived(typ string) Mapping {
3333
return MapSemantic(typ, uast.Identifier{}, MapObj(
34-
Obj{
35-
"Name": Var("name"),
34+
Fields{
35+
{Name: "Name", Op: Var("name")},
36+
{Name: "ExpandedFromMacro", Optional: "optMacro", Op: Any()},
3637
},
3738
Obj{
3839
"Name": Var("name"),
@@ -131,10 +132,17 @@ var Normalizers = []Mapping{
131132
{
132133
"Name": Var("path"),
133134
"IsSystem": Bool(true),
135+
// Always empty on current tests, this should detect other cases
136+
"Path": String(""),
137+
// TODO(juanjux): save this once we've a way
138+
"Resolved": Any(),
134139
},
135140
{
136141
"Name": StringConv(Var("path"), prependDotSlash, removeDotSlash),
137142
"IsSystem": Bool(false),
143+
"Path": String(""),
144+
// TODO(juanjux): save this once we've a way
145+
"Resolved": Any(),
138146
},
139147
}),
140148
Obj{
@@ -148,8 +156,14 @@ var Normalizers = []Mapping{
148156
)),
149157

150158
MapSemantic("CPPASTCompoundStatement", uast.Block{}, MapObj(
151-
Obj{
152-
"Prop_Statements": Var("statements"),
159+
Fields{
160+
{Name: "Prop_Statements", Op: Var("statements")},
161+
// TODO(juanjyux): save this once we have a way.
162+
{Name: "ExpandedFromMacro", Optional: "optMacro", Op: Any()},
163+
// TODO(juanjux): do something to don't lose these
164+
{Name: "LeadingComments", Optional: "optLeadingComments", Op: Any()},
165+
{Name: "FreestadingComments", Optional: "optFSComments", Op: Any()},
166+
{Name: "TrailingComments", Optional: "optTlComments", Op: Any()},
153167
},
154168
Obj{
155169
"Statements": Var("statements"),
@@ -158,14 +172,23 @@ var Normalizers = []Mapping{
158172

159173
// Empty {}
160174
MapSemantic("CPPASTCompoundStatement", uast.Block{}, MapObj(
161-
Obj{},
175+
Fields{
176+
// TODO(juanjux): do something to don't lose these
177+
{Name: "LeadingComments", Optional: "optLeadingComments", Op: Any()},
178+
{Name: "FreestadingComments", Optional: "optFSComments", Op: Any()},
179+
{Name: "TrailingComments", Optional: "optTlComments", Op: Any()},
180+
},
162181
Obj{"Statements": Arr()},
163182
)),
164183

165184
MapSemantic("CPPASTLiteralExpression", uast.String{}, MapObj(
166185
Obj{
167186
"LiteralValue": Quote(Var("val")),
168187
"kind": String("string_literal"),
188+
"ExpressionValueCategory": String("LVALUE"),
189+
"IsLValue": Bool(true),
190+
// Will be const char[somenum]
191+
"ExpressionType": Any(),
169192
},
170193
Obj{
171194
"Value": Var("val"),
@@ -190,10 +213,13 @@ var Normalizers = []Mapping{
190213
)),
191214

192215
// Args in C can have type but be empty (typically in headers, but also in implementations): int main(int, char**)
193-
Map(Obj{
194-
"IASTClass": String("CPPASTName"),
195-
"Name": String(""),
196-
},
216+
Map(
217+
Fields{
218+
{Name: "IASTClass", Op: String("CPPASTName")},
219+
{Name: "Name", Op: String("")},
220+
// TODO(juanjyux): save this once we have a way.
221+
{Name: "ExpandedFromMacro", Optional: "optMacro", Op: Any()},
222+
},
197223
Is(nil),
198224
),
199225

@@ -248,8 +274,14 @@ var Normalizers = []Mapping{
248274
},
249275
Is(nil),
250276
))},
277+
{Name: "IsConversionOperator", Op: Bool(false)},
251278
// Ignored: already on AllSegments
252279
{Name: "Prop_Qualifier", Optional: "optPropQual", Op: Any()},
280+
// TODO(juanjux): save these two once we've a way
281+
{Name: "ExpandedFromMacro", Optional: "optMacro1", Op: Any()},
282+
{Name: "IsFullyQualified", Op: Any()},
283+
// Same as Prop_AllSegments but in a single string ("foo::bar::baz") instead of a list
284+
{Name: "Name", Op: Any()},
253285
},
254286
Obj{
255287
"Names": Each("qualParts", Cases("caseQualParts",
@@ -271,8 +303,13 @@ var Normalizers = []Mapping{
271303
Fields{
272304
{Name: "IsDefaulted", Op: Any()},
273305
{Name: "IsDeleted", Op: Any()},
306+
// TODO(juanjux): save this once we've a way
274307
{Name: "ExpandedFromMacro", Optional: "optMacro1", Op: Any()},
275308
{Name: "Prop_Body", Optional: "optBody", Op: Var("body")},
309+
{Name: "LeadingComments", Optional: "optLeadingComments", Op: Var("leadingComments")},
310+
{Name: "FreestadingComments", Optional: "optFSComments", Op: Var("fsComments")},
311+
{Name: "TrailingComments", Optional: "optTlComments", Op: Var("tsComments")},
312+
{Name: "Prop_MemberInitializers", Optional: "optMemberInitializers", Op: Var("memberInitializers")},
276313

277314
{Name: "Prop_DeclSpecifier", Op: Cases("retTypeCase",
278315
Fields{
@@ -447,6 +484,14 @@ var Normalizers = []Mapping{
447484
},
448485
Obj{
449486
"Nodes": Arr(
487+
Fields{
488+
{Name: "Comments", Op: Fields{
489+
{Name: "LeadingComments", Optional: "optLeadingComments", Op: Var("leadingComments")},
490+
{Name: "FreestadingComments", Optional: "optFSComments", Op: Var("fsComments")},
491+
{Name: "TrailingComments", Optional: "optTlComments", Op: Var("tsComments")},
492+
}},
493+
{Name: "MemberInitializers", Optional: "optMemberInitializers", Op: Var("memberInitializers")},
494+
},
450495
UASTType(uast.Alias{}, Obj{
451496
"Name": UASTType(uast.Identifier{}, CasesObj("caseName", Obj{},
452497
Objs{

fixtures/_integration.cpp.sem.uast

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
},
2929
},
3030
Nodes: [
31+
{
32+
Comments: {},
33+
},
3134
{ '@type': "uast:Alias",
3235
Name: { '@type': "uast:Identifier",
3336
Name: "main",

fixtures/arithmeticops.cpp.sem.uast

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
},
2929
},
3030
Nodes: [
31+
{
32+
Comments: {},
33+
},
3134
{ '@type': "uast:Alias",
3235
Name: { '@type': "uast:Identifier",
3336
Name: "main",

fixtures/array.cpp.sem.uast

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
},
2929
},
3030
Nodes: [
31+
{
32+
Comments: {},
33+
},
3134
{ '@type': "uast:Alias",
3235
Name: { '@type': "uast:Identifier",
3336
Name: "main",

fixtures/asm.cpp.sem.uast

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@
151151
},
152152
},
153153
Nodes: [
154+
{
155+
Comments: {},
156+
},
154157
{ '@type': "uast:Alias",
155158
Name: { '@type': "uast:Identifier",
156159
Name: "main",

0 commit comments

Comments
 (0)