From: Argyrios Kyrtzidis Date: Fri, 21 Dec 2012 01:51:12 +0000 (+0000) Subject: [libclang] Follow-up to r170824, provide the correct number of arguments for X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f1e5b155088203f88a8172aa61c1d84185966bf0;p=clang [libclang] Follow-up to r170824, provide the correct number of arguments for a not-fully-formed macro invocation during code-completion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170833 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp index a523612fbd..b7ea30e83c 100644 --- a/lib/Lex/PPMacroExpansion.cpp +++ b/lib/Lex/PPMacroExpansion.cpp @@ -619,6 +619,17 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName, // See MacroArgs instance var for description of this. bool isVarargsElided = false; + if (ContainsCodeCompletionTok) { + // Recover from not-fully-formed macro invocation during code-completion. + Token EOFTok; + EOFTok.startToken(); + EOFTok.setKind(tok::eof); + EOFTok.setLocation(Tok.getLocation()); + EOFTok.setLength(0); + for (; NumActuals < MinArgsExpected; ++NumActuals) + ArgTokens.push_back(EOFTok); + } + if (NumActuals < MinArgsExpected) { // There are several cases where too few arguments is ok, handle them now. if (NumActuals == 0 && MinArgsExpected == 1) { diff --git a/test/Index/complete-macro-args.c b/test/Index/complete-macro-args.c index 2f3833d989..62a42ffa21 100644 --- a/test/Index/complete-macro-args.c +++ b/test/Index/complete-macro-args.c @@ -12,7 +12,7 @@ void test(struct Point *p) { MACRO(p->x); } -#define MACRO3(x,y,z) x +#define MACRO3(x,y,z) x;y;z void test(struct Point *p) { MACRO3(p->x);