[cfe-commits] r170833 - in /cfe/trunk: lib/Lex/PPMacroExpansion.cpp test/Index/complete-macro-args.c
Argyrios Kyrtzidis
akyrtzi at gmail.com
Thu Dec 20 17:51:12 PST 2012
Author: akirtzidis
Date: Thu Dec 20 19:51:12 2012
New Revision: 170833
URL: http://llvm.org/viewvc/llvm-project?rev=170833&view=rev
Log:
[libclang] Follow-up to r170824, provide the correct number of arguments for
a not-fully-formed macro invocation during code-completion.
Modified:
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/test/Index/complete-macro-args.c
Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=170833&r1=170832&r2=170833&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Thu Dec 20 19:51:12 2012
@@ -619,6 +619,17 @@
// 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) {
Modified: cfe/trunk/test/Index/complete-macro-args.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-macro-args.c?rev=170833&r1=170832&r2=170833&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-macro-args.c (original)
+++ cfe/trunk/test/Index/complete-macro-args.c Thu Dec 20 19:51:12 2012
@@ -12,7 +12,7 @@
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);
More information about the cfe-commits
mailing list