[PATCH] D64864: [CodeComplete] Fix ASTUnit cached completion of macros from preamble, broken in r342528
Sam McCall via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 17 06:21:28 PDT 2019
sammccall created this revision.
sammccall added reviewers: ilya-biryukov, nik.
Herald added subscribers: llvm-commits, arphaman.
Herald added a project: LLVM.
The problem is the default LoadExternal with no completer, which happens when
loading global results.
Repository:
rL LLVM
https://reviews.llvm.org/D64864
Files:
clang/lib/Sema/SemaCodeComplete.cpp
clang/test/Index/complete-macros.c
clang/test/Index/complete-macros.h
Index: clang/test/Index/complete-macros.h
===================================================================
--- clang/test/Index/complete-macros.h
+++ clang/test/Index/complete-macros.h
@@ -2,5 +2,6 @@
#define COMPLETE_MACROS_H_GUARD
void in_header(int);
+#define MACRO_IN_HEADER 1
#endif
Index: clang/test/Index/complete-macros.c
===================================================================
--- clang/test/Index/complete-macros.c
+++ clang/test/Index/complete-macros.c
@@ -28,7 +28,10 @@
// RUN: c-index-test -code-completion-at=%s:7:1 %s -I%S | FileCheck -check-prefix=CHECK-CC0 %s
// CHECK-CC0-NOT: FOO
// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:1 %s -I%S | FileCheck -check-prefix=CHECK-CC1 %s
+// (we had a regression that only occurred when parsing as C++, so check that too)
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:1 -x c++ %s -I%S | FileCheck -check-prefix=CHECK-CC1 %s
// CHECK-CC1: macro definition:{TypedText FOO} (70)
+// CHECK-CC1: macro definition:{TypedText MACRO_IN_HEADER} (70)
// RUN: c-index-test -code-completion-at=%s:13:13 %s -I%S | FileCheck -check-prefix=CHECK-CC2 %s
// RUN: c-index-test -code-completion-at=%s:14:8 %s -I%S | FileCheck -check-prefix=CHECK-CC2 %s
// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:14:8 %s -I%S | FileCheck -check-prefix=CHECK-CC2 %s
Index: clang/lib/Sema/SemaCodeComplete.cpp
===================================================================
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -8603,8 +8603,7 @@
if (!CodeCompleter || CodeCompleter->includeMacros())
AddMacroResults(PP, Results,
- CodeCompleter ? CodeCompleter->loadExternal() : false,
- true);
+ !CodeCompleter || CodeCompleter->loadExternal(), true);
// defined (<macro>)
Results.EnterNewScope();
@@ -8801,8 +8800,7 @@
if (!CodeCompleter || CodeCompleter->includeMacros())
AddMacroResults(PP, Builder,
- CodeCompleter ? CodeCompleter->loadExternal() : false,
- true);
+ !CodeCompleter || CodeCompleter->loadExternal(), true);
Results.clear();
Results.insert(Results.end(), Builder.data(),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64864.210307.patch
Type: text/x-patch
Size: 2396 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190717/48dbfeff/attachment.bin>
More information about the llvm-commits
mailing list