This is an archive of the discontinued LLVM Phabricator instance.

[AST] Flag the typo-corrected nodes for better tooling
Needs ReviewPublic

Authored by arphaman on Oct 9 2017, 3:32 PM.

Details

Summary

This patch adds a new boolean field to the DeclRefExpr, MemberExpr, CXXCtorInitializer, ObjCIvarRefExpr, ObjCPropertyRefExpr nodes which is set to true when these nodes have been produced during typo-correction.

This is useful for Clang-based tooling as it can distinguish between true references and the typo-corrected references. The initial tooling support uses the flag to prevent token annotation for typo-corrected references and to prevent finding typo-corrected references during single TU reference search.

Diff Detail

Repository
rL LLVM

Event Timeline

arphaman created this revision.Oct 9 2017, 3:32 PM
ilya-biryukov edited edge metadata.Nov 14 2017, 8:25 AM

Sorry, not familiar enough with the AST bits yet to LGTM this.

Looks good from a higher-level perspective, though.
It's a bit of a shame that's it is still super-easy to write code that does not account for typo-corrected nodes. A more explicit approach, similar to non-canonical and sugared Types, would probably be nicer, but getting there seems to be hard and may not be worth the effort.

Could you rebase this patch against ToT?

Also, it's not clear to me why only four Exprs (DeclRefExpr, MemberExpr, ObjCIvarRefExpr, and ObjCPropertyRefExpr) should have the IsTypoCorrected flag. Can you elaborate on how you chose that set of Exprs and whether you plan to add the flag to other Exprs?