ObjC token annotations

Erik Verbruggen erikjv at me.com
Tue Apr 2 12:44:13 PDT 2013


Another token annotation question, this time about ObjC's self/super.

I have this snippet:

    SubIFace *inst;
    [inst a];
    [self a];
    [super a];

When running that through c-index-test -test-annotate-tokens, I get some results I don't completely understand:

Identifier: "SubIFace" [153:14 - 153:22] ObjCClassRef=SubIFace:148:12
Punctuation: "*" [153:23 - 153:24] VarDecl=inst:153:24 (Definition)
Identifier: "inst" [153:24 - 153:28] VarDecl=inst:153:24 (Definition)
Punctuation: ";" [153:28 - 153:29] DeclStmt=
Punctuation: "[" [154:5 - 154:6] ObjCMessageExpr=a:146:10
Identifier: "inst" [154:6 - 154:10] DeclRefExpr=inst:153:24
Identifier: "a" [154:11 - 154:12] ObjCMessageExpr=a:146:10
Punctuation: "]" [154:12 - 154:13] ObjCMessageExpr=a:146:10
Punctuation: ";" [154:13 - 154:14] CompoundStmt=
Punctuation: "[" [155:5 - 155:6] ObjCMessageExpr=a:146:10
Identifier: "self" [155:6 - 155:10] DeclRefExpr=self:0:0
Identifier: "a" [155:11 - 155:12] ObjCMessageExpr=a:146:10
Punctuation: "]" [155:12 - 155:13] ObjCMessageExpr=a:146:10
Punctuation: ";" [155:13 - 155:14] CompoundStmt=
Punctuation: "[" [156:5 - 156:6] ObjCMessageExpr=a:146:10
Identifier: "super" [156:6 - 156:11] ObjCMessageExpr=a:146:10
Identifier: "a" [156:12 - 156:13] ObjCMessageExpr=a:146:10
Punctuation: "]" [156:13 - 156:14] ObjCMessageExpr=a:146:10
Punctuation: ";" [156:14 - 156:15] CompoundStmt=

So, "inst" in the first expression is a DeclRefExpr, just like "self" in the second one. However, "super" in the last expression is annotated with "ObjCMessageExpr=a"... Is that on purpose, and if so, what is the reasoning behind it?

Regards,
Erik.



More information about the cfe-commits mailing list