r240571 - [Preprocessor] Iterating over all macros should include those from modules.
Jordan Rose
jordan_rose at apple.com
Wed Jun 24 12:27:02 PDT 2015
Author: jrose
Date: Wed Jun 24 14:27:02 2015
New Revision: 240571
URL: http://llvm.org/viewvc/llvm-project?rev=240571&view=rev
Log:
[Preprocessor] Iterating over all macros should include those from modules.
So, iterate over the list of macros mentioned in modules, and make sure those
are in the master table.
This isn't particularly efficient, but hopefully it's something that isn't
done too often.
PR23929 and rdar://problem/21480635
Added:
cfe/trunk/test/CodeCompletion/macros-in-modules.c
cfe/trunk/test/CodeCompletion/macros-in-modules.m
Modified:
cfe/trunk/lib/Lex/Preprocessor.cpp
Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=240571&r1=240570&r2=240571&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Wed Jun 24 14:27:02 2015
@@ -286,6 +286,10 @@ Preprocessor::macro_begin(bool IncludeEx
ExternalSource->ReadDefinedMacros();
}
+ // Make sure we cover all macros in visible modules.
+ for (const ModuleMacro &Macro : ModuleMacros)
+ CurSubmoduleState->Macros.insert(std::make_pair(Macro.II, MacroState()));
+
return CurSubmoduleState->Macros.begin();
}
Added: cfe/trunk/test/CodeCompletion/macros-in-modules.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/macros-in-modules.c?rev=240571&view=auto
==============================================================================
--- cfe/trunk/test/CodeCompletion/macros-in-modules.c (added)
+++ cfe/trunk/test/CodeCompletion/macros-in-modules.c Wed Jun 24 14:27:02 2015
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: echo 'module Foo { header "foo.h" }' > %t/module.modulemap
+// RUN: echo '#define FOO_MACRO 42' > %t/foo.h
+// RUN: c-index-test -code-completion-at=%s:9:1 -I %t %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:9:1 -I %t -fmodules %s | FileCheck %s
+
+#include "foo.h"
+int x =
+/*here*/1;
+
+// CHECK: FOO_MACRO
Added: cfe/trunk/test/CodeCompletion/macros-in-modules.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/macros-in-modules.m?rev=240571&view=auto
==============================================================================
--- cfe/trunk/test/CodeCompletion/macros-in-modules.m (added)
+++ cfe/trunk/test/CodeCompletion/macros-in-modules.m Wed Jun 24 14:27:02 2015
@@ -0,0 +1,10 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: echo 'module Foo { header "foo.h" }' > %t/module.modulemap
+// RUN: echo '#define FOO_MACRO 42' > %t/foo.h
+// RUN: c-index-test -code-completion-at=%s:8:1 -I %t -fmodules %s | FileCheck %s
+
+ at import Foo;
+int x =
+/*here*/1;
+
+// CHECK: FOO_MACRO
More information about the cfe-commits
mailing list