]> granicus.if.org Git - clang/commitdiff
[libclang] Follow-up to r170824, provide the correct number of arguments for
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 21 Dec 2012 01:51:12 +0000 (01:51 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 21 Dec 2012 01:51:12 +0000 (01:51 +0000)
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

lib/Lex/PPMacroExpansion.cpp
test/Index/complete-macro-args.c

index a523612fbdb49b738064ca2f3a71d1408b6b4862..b7ea30e83cf0b7195325962f3f3c2e231626c583 100644 (file)
@@ -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) {
index 2f3833d989ee95286b1250802365b87c5c3458bb..62a42ffa217859c5c78522bdd27179cdf624060e 100644 (file)
@@ -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);