[all-commits] [llvm/llvm-project] ece4e9: [CodeComplete] Basic code completion for attribute...

Sam McCall via All-commits all-commits at lists.llvm.org
Thu Aug 12 15:04:16 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ece4e920852185b332c2f7ba027e0c4a2972855a
      https://github.com/llvm/llvm-project/commit/ece4e920852185b332c2f7ba027e0c4a2972855a
  Author: Sam McCall <sam.mccall at gmail.com>
  Date:   2021-08-12 (Thu, 12 Aug 2021)

  Changed paths:
    M clang-tools-extra/clangd/CodeComplete.cpp
    M clang/include/clang/Parse/Parser.h
    M clang/include/clang/Sema/CodeCompleteConsumer.h
    M clang/include/clang/Sema/ParsedAttr.h
    M clang/include/clang/Sema/Sema.h
    M clang/lib/Frontend/ASTUnit.cpp
    M clang/lib/Parse/ParseDecl.cpp
    M clang/lib/Parse/ParseDeclCXX.cpp
    M clang/lib/Parse/ParsePragma.cpp
    M clang/lib/Sema/CodeCompleteConsumer.cpp
    M clang/lib/Sema/ParsedAttr.cpp
    M clang/lib/Sema/SemaCodeComplete.cpp
    A clang/test/CodeCompletion/attr.cpp
    M clang/tools/libclang/CIndexCodeCompletion.cpp

  Log Message:
  -----------
  [CodeComplete] Basic code completion for attribute names.

Only the bare name is completed, with no args.
For args to be useful we need arg names. These *are* in the tablegen but
not currently emitted in usable form, so left this as future work.

C++11, C2x, GNU, declspec, MS syntax is supported, with the appropriate
spellings of attributes suggested.
`#pragma clang attribute` is supported but not terribly useful as we
only reach completion if parens are balanced (i.e. the line is not truncated)

There's no filtering of which attributes might make sense in this
grammatical context (e.g. attached to a function). In code-completion context
this is hard to do, and will only work in few cases :-(

There's also no filtering by langopts: this is because currently the
only way of checking is to try to produce diagnostics, which requires a
valid ParsedAttr which is hard to get.
This should be fairly simple to fix but requires some tablegen changes
to expose the logic without the side-effect.

Differential Revision: https://reviews.llvm.org/D107696




More information about the All-commits mailing list