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

Commit 4a35944

Browse files
authored
Merge pull request #26 from juanjux/update_sdk2
Update SDK, fix now-not-silently-dropped fields
2 parents 5b0f1b4 + c1ae4a1 commit 4a35944

File tree

86 files changed

+377683
-1871
lines changed

Some content is hidden

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

86 files changed

+377683
-1871
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
language: go
22

33
go:
4-
- '1.10'
4+
- '1.11'
55

66
services:
77
- docker
88

99
env:
10-
- BBLFSHD_VERSION=v2.9.1
10+
- BBLFSHD_VERSION=v2.11.7
1111

1212
install:
1313
- curl -L https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64 > $GOPATH/bin/dep

Gopkg.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# for detailed Gopkg.toml documentation.
33

44
[[constraint]]
5-
version = "2.13.x"
5+
version = "2.14.2"
66
name = "gopkg.in/bblfsh/sdk.v2"
77

88
[prune]

driver/normalizer/normalizer.go

Lines changed: 113 additions & 66 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", Drop: true, 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+
// FIXME(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+
// FIXME(juanjux): save this once we've a way
145+
"Resolved": Any(),
138146
},
139147
}),
140148
Obj{
@@ -148,8 +156,13 @@ 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+
// FIXME(juanjux): save all these once we have a way.
162+
{Name: "ExpandedFromMacro", Drop: true, Op: Any()},
163+
{Name: "LeadingComments", Drop: true, Op: Any()},
164+
{Name: "FreestadingComments", Drop: true, Op: Any()},
165+
{Name: "TrailingComments", Drop: true, Op: Any()},
153166
},
154167
Obj{
155168
"Statements": Var("statements"),
@@ -158,14 +171,23 @@ var Normalizers = []Mapping{
158171

159172
// Empty {}
160173
MapSemantic("CPPASTCompoundStatement", uast.Block{}, MapObj(
161-
Obj{},
174+
Fields{
175+
// FIXME(juanjux): save all these once we have a way
176+
{Name: "LeadingComments", Drop: true, Op: Any()},
177+
{Name: "FreestadingComments", Drop: true, Op: Any()},
178+
{Name: "TrailingComments", Drop: true, Op: Any()},
179+
},
162180
Obj{"Statements": Arr()},
163181
)),
164182

165183
MapSemantic("CPPASTLiteralExpression", uast.String{}, MapObj(
166184
Obj{
167-
"LiteralValue": Quote(Var("val")),
168-
"kind": String("string_literal"),
185+
"LiteralValue": Quote(Var("val")),
186+
"kind": String("string_literal"),
187+
"ExpressionValueCategory": String("LVALUE"),
188+
"IsLValue": Bool(true),
189+
// Will be const char[somenum]
190+
"ExpressionType": Any(),
169191
},
170192
Obj{
171193
"Value": Var("val"),
@@ -190,10 +212,13 @@ var Normalizers = []Mapping{
190212
)),
191213

192214
// 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-
},
215+
Map(
216+
Fields{
217+
{Name: "IASTClass", Op: String("CPPASTName")},
218+
{Name: "Name", Op: String("")},
219+
// FIXME(juanjux): save this once we have a way.
220+
{Name: "ExpandedFromMacro", Drop: true, Op: Any()},
221+
},
197222
Is(nil),
198223
),
199224

@@ -248,8 +273,14 @@ var Normalizers = []Mapping{
248273
},
249274
Is(nil),
250275
))},
276+
{Name: "IsConversionOperator", Op: Bool(false)},
251277
// Ignored: already on AllSegments
252-
{Name: "Prop_Qualifier", Optional: "optPropQual", Op: Any()},
278+
{Name: "Prop_Qualifier", Drop: true, Op: Any()},
279+
// FIXME(juanjux): save these two once we've a way
280+
{Name: "ExpandedFromMacro", Drop: true, Op: Any()},
281+
{Name: "IsFullyQualified", Op: Any()},
282+
// Same as Prop_AllSegments but in a single string ("foo::bar::baz") instead of a list
283+
{Name: "Name", Op: Any()},
253284
},
254285
Obj{
255286
"Names": Each("qualParts", Cases("caseQualParts",
@@ -271,55 +302,60 @@ var Normalizers = []Mapping{
271302
Fields{
272303
{Name: "IsDefaulted", Op: Any()},
273304
{Name: "IsDeleted", Op: Any()},
274-
{Name: "ExpandedFromMacro", Optional: "optMacro1", Op: Any()},
305+
// FIXME(juanjux): save this once we've a way
306+
{Name: "ExpandedFromMacro", Drop: true, Op: Any()},
275307
{Name: "Prop_Body", Optional: "optBody", Op: Var("body")},
308+
{Name: "LeadingComments", Optional: "optLeadingComments", Op: Var("leadingComments")},
309+
{Name: "FreestadingComments", Optional: "optFSComments", Op: Var("fsComments")},
310+
{Name: "TrailingComments", Optional: "optTlComments", Op: Var("tsComments")},
311+
{Name: "Prop_MemberInitializers", Optional: "optMemberInitializers", Op: Var("memberInitializers")},
276312

277313
{Name: "Prop_DeclSpecifier", Op: Cases("retTypeCase",
278314
Fields{
279315
{Name: uast.KeyType, Op: String("CPPASTSimpleDeclSpecifier")},
280316
{Name: uast.KeyPos, Op: Any()},
281-
{Name: "IsComplex", Op: Any()},
282-
{Name: "IsConst", Op: Any()},
283-
{Name: "IsConstExpr", Op: Any()},
284-
{Name: "IsExplicit", Op: Any()},
285-
{Name: "IsFriend", Op: Any()},
286-
{Name: "IsImaginary", Op: Any()},
287-
{Name: "IsInline", Op: Any()},
288-
{Name: "IsLong", Op: Any()},
289-
{Name: "IsLongLong", Op: Any()},
290-
{Name: "IsRestrict", Op: Any()},
291-
{Name: "IsShort", Op: Any()},
292-
{Name: "IsSigned", Op: Any()},
293-
{Name: "IsThreadLocal", Op: Any()},
294-
{Name: "IsUnsigned", Op: Any()},
295-
{Name: "IsVirtual", Op: Any()},
296-
{Name: "IsVolatile", Op: Any()},
297-
{Name: "StorageClass", Op: Any()},
298-
{Name: "ExpandedFromMacro", Optional: "optMacro2", Op: Any()},
317+
{Name: "IsComplex", Drop: true, Op: Any()},
318+
{Name: "IsConst", Drop: true, Op: Any()},
319+
{Name: "IsConstExpr", Drop: true, Op: Any()},
320+
{Name: "IsExplicit", Drop: true, Op: Any()},
321+
{Name: "IsFriend", Drop: true, Op: Any()},
322+
{Name: "IsImaginary", Drop: true, Op: Any()},
323+
{Name: "IsInline", Drop: true, Op: Any()},
324+
{Name: "IsLong", Drop: true, Op: Any()},
325+
{Name: "IsLongLong", Drop: true, Op: Any()},
326+
{Name: "IsRestrict", Drop: true, Op: Any()},
327+
{Name: "IsShort", Drop: true, Op: Any()},
328+
{Name: "IsSigned", Drop: true, Op: Any()},
329+
{Name: "IsThreadLocal", Drop: true, Op: Any()},
330+
{Name: "IsUnsigned", Drop: true, Op: Any()},
331+
{Name: "IsVirtual", Drop: true, Op: Any()},
332+
{Name: "IsVolatile", Drop: true, Op: Any()},
333+
{Name: "StorageClass", Drop: true, Op: Any()},
334+
{Name: "ExpandedFromMacro", Drop: true, Op: Any()},
299335
{Name: "Type", Op: String("void")},
300336
},
301337
// unspecified (ie constructor/destructors)
302338
Fields{
303339
{Name: uast.KeyType, Op: String("CPPASTSimpleDeclSpecifier")},
304-
{Name: uast.KeyPos, Op: Any()},
305-
{Name: "IsComplex", Op: Any()},
306-
{Name: "IsConst", Op: Any()},
307-
{Name: "IsConstExpr", Op: Any()},
308-
{Name: "IsExplicit", Op: Any()},
309-
{Name: "IsFriend", Op: Any()},
310-
{Name: "IsImaginary", Op: Any()},
311-
{Name: "IsInline", Op: Any()},
312-
{Name: "IsLong", Op: Any()},
313-
{Name: "IsLongLong", Op: Any()},
314-
{Name: "IsRestrict", Op: Any()},
315-
{Name: "IsShort", Op: Any()},
316-
{Name: "IsSigned", Op: Any()},
317-
{Name: "IsThreadLocal", Op: Any()},
318-
{Name: "IsUnsigned", Op: Any()},
319-
{Name: "IsVirtual", Op: Any()},
320-
{Name: "IsVolatile", Op: Any()},
321-
{Name: "StorageClass", Op: Any()},
322-
{Name: "ExpandedFromMacro", Optional: "optMacro3", Op: Any()},
340+
{Name: uast.KeyPos, Drop: true, Op: Any()},
341+
{Name: "IsComplex", Drop: true, Op: Any()},
342+
{Name: "IsConst", Drop: true, Op: Any()},
343+
{Name: "IsConstExpr", Drop: true, Op: Any()},
344+
{Name: "IsExplicit", Drop: true, Op: Any()},
345+
{Name: "IsFriend", Drop: true, Op: Any()},
346+
{Name: "IsImaginary", Drop: true, Op: Any()},
347+
{Name: "IsInline", Drop: true, Op: Any()},
348+
{Name: "IsLong", Drop: true, Op: Any()},
349+
{Name: "IsLongLong", Drop: true, Op: Any()},
350+
{Name: "IsRestrict", Drop: true, Op: Any()},
351+
{Name: "IsShort", Drop: true, Op: Any()},
352+
{Name: "IsSigned", Drop: true, Op: Any()},
353+
{Name: "IsThreadLocal", Drop: true, Op: Any()},
354+
{Name: "IsUnsigned", Drop: true, Op: Any()},
355+
{Name: "IsVirtual", Drop: true, Op: Any()},
356+
{Name: "IsVolatile", Drop: true, Op: Any()},
357+
{Name: "StorageClass", Drop: true, Op: Any()},
358+
{Name: "ExpandedFromMacro", Drop: true, Op: Any()},
323359
{Name: "Type", Op: String("unspecified")},
324360
},
325361
Fields{
@@ -343,7 +379,7 @@ var Normalizers = []Mapping{
343379
{Name: "IsVirtual", Op: Any()},
344380
{Name: "IsVolatile", Op: Any()},
345381
{Name: "StorageClass", Op: Var("StorageClass")},
346-
{Name: "ExpandedFromMacro", Optional: "optMacro4", Op: Any()},
382+
{Name: "ExpandedFromMacro", Drop: true, Op: Any()},
347383
{Name: "Type", Op: Var("retType")},
348384
},
349385
Fields{
@@ -361,7 +397,7 @@ var Normalizers = []Mapping{
361397
{Name: "IsTypeName", Op: Any()},
362398
{Name: "IsVirtual", Op: Any()},
363399
{Name: "IsVolatile", Op: Any()},
364-
{Name: "ExpandedFromMacro", Optional: "optMacro5", Op: Any()},
400+
{Name: "ExpandedFromMacro", Drop: true, Op: Any()},
365401
{Name: "Prop_Name", Op: Var("retType")},
366402
},
367403
)},
@@ -375,9 +411,9 @@ var Normalizers = []Mapping{
375411
{Name: "IsOverride", Op: Any()},
376412
{Name: "IsPureVirtual", Op: Any()},
377413
{Name: "IsVolatile", Op: Any()},
378-
{Name: "ExpandedFromMacro", Optional: "optMacro6", Op: Any()},
379-
{Name: "Prop_NoexceptExpression", Optional: "declNoExcept", Op: Any()},
380-
{Name: "Prop_VirtSpecifiers", Optional: "declVirtSpecs", Op: Any()},
414+
{Name: "ExpandedFromMacro", Drop: true, Op: Any()},
415+
{Name: "Prop_NoexceptExpression", Drop: true, Op: Any()},
416+
{Name: "Prop_VirtSpecifiers", Drop: true, Op: Any()},
381417

382418
{Name: "Prop_Name", Op: Cases("caseName",
383419
// Empty identifier
@@ -398,31 +434,33 @@ var Normalizers = []Mapping{
398434
)},
399435

400436
{Name: "TakesVarArgs", Op: Cases("takesVarArgs", Bool(false), Bool(true))},
401-
{Name: "Prop_ConstructorChain", Optional: "optConsChain", Op: Any()},
402-
{Name: "Prop_PointerOperators", Optional: "optPointerOps", Op: Any()},
437+
{Name: "Prop_ConstructorChain", Drop: true, Op: Any()},
438+
{Name: "Prop_PointerOperators", Drop: true, Op: Any()},
403439

404440
{Name: "Prop_Parameters", Optional: "optArgs", Op: Each("args", Cases("caseParams",
405441
Fields{
406442
{Name: uast.KeyType, Op: String("CPPASTDeclarator")},
407443
{Name: uast.KeyPos, Op: Var("parampos")},
408444
{Name: "Prop_Name", Op: Var("aname")},
409445
{Name: "Prop_TypeNode", Op: Var("atype")},
410-
{Name: "DeclaresParameterPack", Op: Any()},
411-
{Name: "Prop_PointerOperators", Optional: "optPointerOps", Op: Any()},
412446
{Name: "Prop_Initializer", Optional: "optInitializer", Op: Var("ainit")},
413-
{Name: "ExpandedFromMacro", Optional: "optMacro", Op: Any()},
414-
{Name: "Prop_PointerOperators", Optional: "optPointerOps", Op: Any()},
447+
// FIXME(juanjux): save these once we've a way
448+
{Name: "DeclaresParameterPack", Drop: true, Op: Any()},
449+
{Name: "Prop_PointerOperators", Drop: true, Op: Any()},
450+
{Name: "ExpandedFromMacro", Drop: true, Op: Any()},
451+
{Name: "Prop_PointerOperators", Drop: true, Op: Any()},
415452
},
416453
Fields{
417454
{Name: uast.KeyType, Op: String("CPPASTArrayDeclarator")},
418455
{Name: uast.KeyPos, Op: Var("parampos")},
419456
{Name: "Prop_Name", Op: Var("aname")},
420457
{Name: "Prop_TypeNode", Op: Var("atype")},
421-
{Name: "DeclaresParameterPack", Op: Any()},
422-
{Name: "Prop_ArrayModifiers", Op: Any()},
423458
{Name: "Prop_Initializer", Optional: "optInitializer", Op: Var("ainit")},
424-
{Name: "ExpandedFromMacro", Optional: "optMacro", Op: Any()},
425-
{Name: "Prop_PointerOperators", Optional: "optPointerOps", Op: Any()},
459+
// FIXME(juanjux): save these once we've a way
460+
{Name: "DeclaresParameterPack", Drop: true, Op: Any()},
461+
{Name: "Prop_ArrayModifiers", Drop: true, Op: Any()},
462+
{Name: "ExpandedFromMacro", Drop: true, Op: Any()},
463+
{Name: "Prop_PointerOperators", Drop: true, Op: Any()},
426464
},
427465
Fields{
428466
{Name: uast.KeyType, Op: String("CPPASTElaboratedTypeSpecifier")},
@@ -440,13 +478,22 @@ var Normalizers = []Mapping{
440478
{Name: "IsVirtual", Op: Any()},
441479
{Name: "IsVolatile", Op: Any()},
442480
{Name: "StorageClass", Op: Any()},
443-
{Name: "ExpandedFromMacro", Optional: "optMacro", Op: Any()},
481+
// FIXME(juanjux): save these once we've a way
482+
{Name: "ExpandedFromMacro", Drop: true, Op: Any()},
444483
},
445484
))},
446485
}},
447486
},
448487
Obj{
449488
"Nodes": Arr(
489+
Fields{
490+
{Name: "Comments", Op: Fields{
491+
{Name: "LeadingComments", Optional: "optLeadingComments", Op: Var("leadingComments")},
492+
{Name: "FreestadingComments", Optional: "optFSComments", Op: Var("fsComments")},
493+
{Name: "TrailingComments", Optional: "optTlComments", Op: Var("tsComments")},
494+
}},
495+
{Name: "MemberInitializers", Optional: "optMemberInitializers", Op: Var("memberInitializers")},
496+
},
450497
UASTType(uast.Alias{}, Obj{
451498
"Name": UASTType(uast.Identifier{}, CasesObj("caseName", Obj{},
452499
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)