]> granicus.if.org Git - clang/commitdiff
Handle a code-completion token being passed to the macro stringify operator.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sun, 4 Sep 2011 03:32:19 +0000 (03:32 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sun, 4 Sep 2011 03:32:19 +0000 (03:32 +0000)
Fixes http://llvm.org/PR10826.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139087 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/MacroArgs.cpp
test/Index/complete-in-stringify.c [new file with mode: 0644]

index ccd0b705c8b38df153947064b78f9b939147e7dd..42aafd818889c34c4b0704c0b467bd8bb03dc632 100644 (file)
@@ -221,6 +221,8 @@ Token MacroArgs::StringifyArgument(const Token *ArgToks,
         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.
diff --git a/test/Index/complete-in-stringify.c b/test/Index/complete-in-stringify.c
new file mode 100644 (file)
index 0000000..d518549
--- /dev/null
@@ -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