diff --git a/clang/lib/Lex/MacroArgs.cpp b/clang/lib/Lex/MacroArgs.cpp index ccd0b705c8b3..42aafd818889 100644 --- a/clang/lib/Lex/MacroArgs.cpp +++ b/clang/lib/Lex/MacroArgs.cpp @@ -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/clang/test/Index/complete-in-stringify.c b/clang/test/Index/complete-in-stringify.c new file mode 100644 index 000000000000..d5185496f8b7 --- /dev/null +++ b/clang/test/Index/complete-in-stringify.c @@ -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