r366409 - [CodeComplete] Fix ASTUnit cached completion of macros from preamble, broken in r342528
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 18 00:17:49 PDT 2019
Author: sammccall
Date: Thu Jul 18 00:17:49 2019
New Revision: 366409
URL: http://llvm.org/viewvc/llvm-project?rev=366409&view=rev
Log:
[CodeComplete] Fix ASTUnit cached completion of macros from preamble, broken in r342528
Summary:
The problem is the default LoadExternal with no completer, which happens when
loading global results.
Reviewers: ilya-biryukov, nik
Subscribers: arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64864
Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/Index/complete-macros.c
cfe/trunk/test/Index/complete-macros.h
Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=366409&r1=366408&r2=366409&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Thu Jul 18 00:17:49 2019
@@ -8603,8 +8603,7 @@ void Sema::CodeCompletePreprocessorExpre
if (!CodeCompleter || CodeCompleter->includeMacros())
AddMacroResults(PP, Results,
- CodeCompleter ? CodeCompleter->loadExternal() : false,
- true);
+ !CodeCompleter || CodeCompleter->loadExternal(), true);
// defined (<macro>)
Results.EnterNewScope();
@@ -8801,8 +8800,7 @@ void Sema::GatherGlobalCodeCompletions(
if (!CodeCompleter || CodeCompleter->includeMacros())
AddMacroResults(PP, Builder,
- CodeCompleter ? CodeCompleter->loadExternal() : false,
- true);
+ !CodeCompleter || CodeCompleter->loadExternal(), true);
Results.clear();
Results.insert(Results.end(), Builder.data(),
Modified: cfe/trunk/test/Index/complete-macros.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-macros.c?rev=366409&r1=366408&r2=366409&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-macros.c (original)
+++ cfe/trunk/test/Index/complete-macros.c Thu Jul 18 00:17:49 2019
@@ -28,7 +28,10 @@ void test_variadic() {
// 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
Modified: cfe/trunk/test/Index/complete-macros.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-macros.h?rev=366409&r1=366408&r2=366409&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-macros.h (original)
+++ cfe/trunk/test/Index/complete-macros.h Thu Jul 18 00:17:49 2019
@@ -2,5 +2,6 @@
#define COMPLETE_MACROS_H_GUARD
void in_header(int);
+#define MACRO_IN_HEADER 1
#endif
More information about the cfe-commits
mailing list