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

Keane, Erich via cfe-dev cfe-dev at lists.llvm.org
Fri Jun 15 10:01:31 PDT 2018


You don’t need a plugin for the alternate spellings, just use –fno-operator-names.  If you really need to detect them, find the IdentiferInfo object, and check isCPlusPlusOperatorKeyword.

I don’t see anything Digraph specific however…


From: cfe-dev [mailto:cfe-dev-bounces at lists.llvm.org] On Behalf Of Jacob Bandes-Storch via cfe-dev
Sent: Friday, June 15, 2018 9:36 AM
To: Clang Dev <cfe-dev at lists.llvm.org>
Subject: [cfe-dev] Diagnosing alternative operator spellings & digraphs from a plugin

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/8b425863/attachment.html>


More information about the cfe-dev mailing list