[cfe-commits] r139087 - in /cfe/trunk: lib/Lex/MacroArgs.cpp test/Index/complete-in-stringify.c

Argyrios Kyrtzidis akyrtzi at gmail.com
Sat Sep 3 20:32:20 PDT 2011


Author: akirtzidis
Date: Sat Sep  3 22:32:19 2011
New Revision: 139087

URL: http://llvm.org/viewvc/llvm-project?rev=139087&view=rev
Log:
Handle a code-completion token being passed to the macro stringify operator.
Fixes http://llvm.org/PR10826.

Added:
    cfe/trunk/test/Index/complete-in-stringify.c
Modified:
    cfe/trunk/lib/Lex/MacroArgs.cpp

Modified: cfe/trunk/lib/Lex/MacroArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/MacroArgs.cpp?rev=139087&r1=139086&r2=139087&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/MacroArgs.cpp (original)
+++ cfe/trunk/lib/Lex/MacroArgs.cpp Sat Sep  3 22:32:19 2011
@@ -221,6 +221,8 @@
         std::string Str = Lexer::Stringify(TokStr);
         Result.append(Str.begin(), Str.end());
       }
+    } else if (Tok.is(tok::code_completion)) {
+      PP.CodeCompleteNaturalLanguage();
     } else {
       // Otherwise, just append the token.  Do some gymnastics to get the token
       // in place and avoid copies where possible.

Added: cfe/trunk/test/Index/complete-in-stringify.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-in-stringify.c?rev=139087&view=auto
==============================================================================
--- cfe/trunk/test/Index/complete-in-stringify.c (added)
+++ cfe/trunk/test/Index/complete-in-stringify.c Sat Sep  3 22:32:19 2011
@@ -0,0 +1,17 @@
+const char *func(const char *);
+
+#define MORE __FILE__
+
+#define M(x) "1"#x
+#define N(x) func("2"#x MORE)
+
+void foo(const char *);
+
+int test() {
+    foo(M(x()));
+    foo(N(x()));
+}
+
+// RUN: c-index-test -code-completion-at=%s:11:11 %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:12:11 %s | FileCheck %s
+// CHECK: Natural language





More information about the cfe-commits mailing list