[cfe-dev] Diagnosing alternative operator spellings & digraphs from a plugin

Jacob Bandes-Storch via cfe-dev cfe-dev at lists.llvm.org
Fri Jun 15 09:35:58 PDT 2018


I'm interested in writing a plugin to disallow alternative spelling
<https://en.cppreference.com/w/cpp/language/operator_alternative>/digraphs for
operators and tokens. However I haven't been able to find a way to access
this information from a PluginASTAction.

I see that the digraphs (<: %: etc.) are handled in Lexer.cpp, but perhaps
the only way to get the original spelling is Lexer::getSpelling(). Would I
be able to get access to the Lexer, SourceLocation, SourceManager, etc.
from a PluginASTAction in order to call this?

I also found the `CXX_KEYWORD_OPERATOR`s in TokenKinds.def, but it looks
like these get mapped to the same token kinds as the regular operator
spellings so I'm not sure how to distinguish them after the AST is built.

Any recommendations would be appreciated, thanks!
Jacob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180615/27f09c90/attachment.html>


More information about the cfe-dev mailing list