llvm-project/clang/lib/Parse
Sam McCall d8716cd7d3 [CodeCompletion] (mostly) fix completion in incomplete C++ ctor initializers.
C++ member function bodies (including ctor initializers) are first captured
into a buffer and then parsed after the class is complete. (This allows
members to be referenced even if declared later).

When the boundary of the function body cannot be established, its buffer is
discarded and late-parsing never happens (it would surely fail).
For code completion this is the wrong tradeoff: the point of the parse is to
generate completions as a side-effect.
Today, when the ctor body wasn't typed yet there are no init list completions.
With this patch we parse such an init-list if it contains the completion point.

There's one caveat: the parser has to decide where to resume parsing members
after a broken init list. Often the first clear recovery point is *after* the
next member, so that member is missing from completion/signature help etc. e.g.
  struct S {
    S() m  //<- completion here
    int maaa;
    int mbbb;
  }
Here "int maaa;" is treated as part of the init list, so "maaa" is not available
as a completion. Maybe in future indentation can be used to recognize that
this is a separate member, not part of the init list.

Differential Revision: https://reviews.llvm.org/D116294
2022-01-13 08:06:35 +01:00
..
CMakeLists.txt [openmp] Base of tablegen generated OpenMP common declaration 2020-06-23 10:32:32 -04:00
ParseAST.cpp [Support] Add TimeTraceScope constructor without detail arg 2019-12-11 14:32:21 +00:00
ParseCXXInlineMethods.cpp [CodeCompletion] (mostly) fix completion in incomplete C++ ctor initializers. 2022-01-13 08:06:35 +01:00
ParseDecl.cpp Revert (2) "[AST] Add RParen loc for decltype AutoTypeloc." 2022-01-12 10:09:37 +00:00
ParseDeclCXX.cpp [AST] Add more source information for DecltypeTypeLoc. 2022-01-10 09:34:18 +01:00
ParseExpr.cpp [clang] Fix bugprone argument comments (NFC) 2022-01-09 00:19:49 -08:00
ParseExprCXX.cpp [Parse] Use empty RecoveryExpr when if/while/do/switch conditions fail to parse 2022-01-10 10:38:27 +01:00
ParseInit.cpp [clang] Use true/false instead of 1/0 (NFC) 2022-01-09 00:19:47 -08:00
ParseObjc.cpp [clang] Use true/false instead of 1/0 (NFC) 2022-01-09 00:19:47 -08:00
ParseOpenMP.cpp [OpenMP][Clang] Allow passing target features in ISA trait for metadirective clause 2022-01-12 05:24:49 +00:00
ParsePragma.cpp [MS compat] Handle #pragma fenv_access like #pragma STDC FENV_ACCESS (PR50694) 2021-10-11 17:07:26 +02:00
ParseStmt.cpp [Parse] Use empty RecoveryExpr when if/while/do/switch conditions fail to parse 2022-01-10 10:38:27 +01:00
ParseStmtAsm.cpp [clang] Fix bugprone argument comments (NFC) 2022-01-09 00:19:49 -08:00
ParseTemplate.cpp [clang] Fix bugprone argument comments (NFC) 2022-01-09 00:19:49 -08:00
ParseTentative.cpp [clang] Use true/false instead of 1/0 (NFC) 2022-01-09 00:19:47 -08:00
Parser.cpp [clang] Fix bugprone argument comments (NFC) 2022-01-09 00:19:49 -08:00