[PATCH] D32081: Add support for editor placeholders to Clang's lexer

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 14 06:46:53 PDT 2017


arphaman created this revision.

This patch is based on the RFC that I've sent out earlier (http://lists.llvm.org/pipermail/cfe-dev/2017-April/053394.html).
It teaches Clang's Lexer to recognize the editor placeholders that are produced by some editors like Xcode when expanding code-completion results that include placeholders. When the Lexer sees a placeholder, it emits an error 'editor placeholder in source file', suppresses all diagnostics in the placeholder range and lexes the tokens in the placeholder.

This patch also includes a new compiler option called '-fsuppress-editor-placeholder-error' that surpasses the 'editor placeholder in source file' error. This option is useful for an IDE like Xcode as we don't want to display those errors as live diagnostics in the editor.

There are still certain things that can be improved. For example, in the future we may want to add support for different kinds of placeholders (e.g. typed, it would produce special typed expressions) that would actually produce a special token instead of lexing the contents of the placeholder in order to improve the parser's recovery. But they will require changes to the code-completion code as well, so I left them for later to keep this patch small.


Repository:
  rL LLVM

https://reviews.llvm.org/D32081

Files:
  include/clang/Basic/Diagnostic.h
  include/clang/Basic/DiagnosticLexKinds.td
  include/clang/Basic/DiagnosticOptions.def
  include/clang/Driver/Options.td
  include/clang/Lex/Lexer.h
  lib/Basic/Diagnostic.cpp
  lib/Basic/DiagnosticIDs.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Lex/Lexer.cpp
  test/Driver/clang_f_opts.c
  test/Lexer/editor-placeholder.cpp
  test/Parser/placeholder-recovery.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32081.95291.patch
Type: text/x-patch
Size: 12354 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170414/8db83179/attachment-0001.bin>


More information about the cfe-commits mailing list