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

Commit 7307131

Browse files
author
Juanjo Alvarez
committed
Fix: qualified identifiers can have nil members
Signed-off-by: Juanjo Alvarez <[email protected]>
1 parent ff8d63f commit 7307131

File tree

5 files changed

+233428
-6
lines changed

5 files changed

+233428
-6
lines changed

driver/normalizer/normalizer.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ var Normalizers = []Mapping{
220220
)),
221221

222222
MapSemantic("CPPASTQualifiedName", uast.QualifiedIdentifier{}, MapObj(
223-
Obj{
224-
"Prop_AllSegments": Each("qualParts", Cases("caseQualParts",
223+
Fields{
224+
{Name: "Prop_AllSegments", Op: Each("qualParts", Cases("caseQualParts",
225225
Fields{
226226
{Name: uast.KeyType, Op: String("uast:Identifier")},
227227
{Name: uast.KeyPos, Op: AnyNode(nil)},
@@ -245,14 +245,24 @@ var Normalizers = []Mapping{
245245
"Name": Var("name"),
246246
}},
247247
},
248-
)),
248+
Is(nil),
249+
))},
250+
// Ignored: already on AllSegments
251+
{Name: "Prop_Qualifier", Optional: "optPropQual", Op: AnyNode(nil)},
249252
},
250253
Obj{
251-
"Names": Each("qualParts",
252-
// "caseQualParts" ommited since all 3 cases extract the "name" variable
254+
"Names": Each("qualParts", Cases("caseQualParts",
253255
UASTType(uast.Identifier{}, Obj{
254256
"Name": Var("name"),
255-
})),
257+
}),
258+
UASTType(uast.Identifier{}, Obj{
259+
"Name": Var("name"),
260+
}),
261+
UASTType(uast.Identifier{}, Obj{
262+
"Name": Var("name"),
263+
}),
264+
Is(nil),
265+
)),
256266
},
257267
)),
258268

@@ -402,6 +412,7 @@ var Normalizers = []Mapping{
402412
{Name: "Prop_PointerOperators", Optional: "optPointerOps", Op: AnyNode(nil)},
403413
{Name: "Prop_Initializer", Optional: "optInitializer", Op: Var("ainit")},
404414
{Name: "ExpandedFromMacro", Optional: "optMacro7", Op: AnyNode(nil)},
415+
{Name: "Prop_PointerOperators", Optional: "optPointerOps", Op: AnyNode(nil)},
405416
},
406417
Fields{
407418
{Name: uast.KeyType, Op: String("CPPASTArrayDeclarator")},
@@ -412,6 +423,7 @@ var Normalizers = []Mapping{
412423
{Name: "Prop_ArrayModifiers", Op: AnyNode(nil)},
413424
{Name: "Prop_Initializer", Optional: "optInitializer", Op: Var("ainit")},
414425
{Name: "ExpandedFromMacro", Optional: "optMacro8", Op: AnyNode(nil)},
426+
{Name: "Prop_PointerOperators", Optional: "optPointerOps", Op: AnyNode(nil)},
415427
},
416428
))},
417429
}},

0 commit comments

Comments
 (0)