llvm-project/clang/test/CodeCompletion
Alex Lorenz 24a1bedf76 [Preprocessor] Fix incorrect token caching that occurs when lexing _Pragma
in macro argument pre-expansion mode when skipping a function body

This commit fixes a token caching problem that currently occurs when clang is
skipping a function body (e.g. when looking for a code completion token) and at
the same time caching the tokens for _Pragma when lexing it in macro argument
pre-expansion mode.

When _Pragma is being lexed in macro argument pre-expansion mode, it caches the
tokens so that it can avoid interpreting the pragma immediately (as the macro
argument may not be used in the macro body), and then either backtracks over or
commits these tokens. The problem is that, when we're backtracking/committing in
such a scenario, there's already a previous backtracking position stored in
BacktrackPositions (as we're skipping the function body), and this leads to a
situation where the cached tokens from the pragma (like '(' 'string_literal'
and ')') will remain in the cached tokens array incorrectly even after they're
consumed (in the case of backtracking) or just ignored (in the case when they're
committed). Furthermore, what makes it even worse, is that because of a previous
backtracking position, the logic that deals with when should we call
ExitCachingLexMode in CachingLex no longer works for us in this situation, and
more tokens in the macro argument get cached, to the point where the EOF token
that corresponds to the macro argument EOF is cached. This problem leads to all
sorts of issues in code completion mode, where incorrect errors get presented
and code completion completely fails to produce completion results.

rdar://28523863

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

llvm-svn: 296140
2017-02-24 17:45:16 +00:00
..
Inputs [CodeCompletion] Allow system headers providing private symbols with a single underscore. 2016-07-01 01:17:02 +00:00
PR9728.cpp
auto.cpp
auto_type.c [CodeCompletion] Code complete the '__auto_type' keyword 2017-02-13 23:35:59 +00:00
bracket-decl.c [Parse] Code complete expressions in bracket declarators. 2016-02-18 15:30:24 +00:00
call.c
call.cpp
constexpr.cpp
ctor-initializer.cpp Fix heuristics skipping invalid ctor-initializers with C++11 2016-11-03 07:36:17 +00:00
documentation.cpp
documentation.m Fix ObjCMethodDecl::findPropertyDecl for class properties. 2016-03-11 21:14:40 +00:00
enum-switch-case-qualified.cpp
enum-switch-case.c
enum-switch-case.cpp
function-templates.cpp
functions.cpp
keywords.cpp [CodeCompletion] Code complete the missing C++11 keywords 2017-02-13 23:19:40 +00:00
macros-in-modules.c
macros-in-modules.m
macros.c
member-access.c
member-access.cpp [code-completion] Fix crash when trying to do postfix completion of instance member inside a static function. 2017-01-15 06:11:04 +00:00
namespace-alias.cpp
namespace.cpp
nested-name-specifier.cpp
objc-expr.m
objc-message.m
objc-message.mm Implement filtering for code completion of identifiers. 2016-07-27 14:56:59 +00:00
objc-protocol-member-access.m [CodeCompletion] Show protocol properties that are accessed through qualified id 2016-10-12 11:40:15 +00:00
operator.cpp
ordinary-name-cxx11.cpp [CodeCompletion] Code complete the missing C++11 keywords 2017-02-13 23:19:40 +00:00
ordinary-name.c [CodeCompletion] Allow system headers providing private symbols with a single underscore. 2016-07-01 01:17:02 +00:00
ordinary-name.cpp [Tests] Modified Lit Tests to be C++11 compatibile 2015-08-27 18:49:15 +00:00
pch-and-module.m Fix CodeCompletion & TypoCorrection when combining a PCH with Modules 2016-05-04 00:53:13 +00:00
pragma-macro-token-caching.c [Preprocessor] Fix incorrect token caching that occurs when lexing _Pragma 2017-02-24 17:45:16 +00:00
preamble.c
some_struct.h
stdin.c
tag.c
tag.cpp
templates.cpp
truncation.c
truncation.c.h
using-namespace.cpp
using.cpp