aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-12-21 01:51:12 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-12-21 01:51:12 +0000
commitf1e5b155088203f88a8172aa61c1d84185966bf0 (patch)
treedc75414cf8b6bd1621ed42e1b4783aa5ae4f55c0
parent1655bcd052a67a3050fc55df8ecce57342352e68 (diff)
[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
-rw-r--r--lib/Lex/PPMacroExpansion.cpp11
-rw-r--r--test/Index/complete-macro-args.c2
2 files changed, 12 insertions, 1 deletions
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);