r175925 - [libclang] Fix assertion hit when code-completing inside a function macro with more
Argyrios Kyrtzidis
akyrtzi at gmail.com
Fri Feb 22 14:28:58 PST 2013
Author: akirtzidis
Date: Fri Feb 22 16:28:58 2013
New Revision: 175925
URL: http://llvm.org/viewvc/llvm-project?rev=175925&view=rev
Log:
[libclang] Fix assertion hit when code-completing inside a function macro with more
arguments than it should accept.
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=175925&r1=175924&r2=175925&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Fri Feb 22 16:28:58 2013
@@ -620,8 +620,10 @@ MacroArgs *Preprocessor::ReadFunctionLik
EOFTok.setLength(0);
ArgTokens.push_back(EOFTok);
++NumActuals;
- assert(NumFixedArgsLeft != 0 && "Too many arguments parsed");
- --NumFixedArgsLeft;
+ if (!ContainsCodeCompletionTok || NumFixedArgsLeft != 0) {
+ assert(NumFixedArgsLeft != 0 && "Too many arguments parsed");
+ --NumFixedArgsLeft;
+ }
}
// Okay, we either found the r_paren. Check to see if we parsed too few
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=175925&r1=175924&r2=175925&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-macro-args.c (original)
+++ cfe/trunk/test/Index/complete-macro-args.c Fri Feb 22 16:28:58 2013
@@ -19,6 +19,11 @@ void test2(struct Point *p) {
MACRO3(p->x
}
+#define FM(x) x
+void test3(struct Point *p) {
+ FM(p->x, a);
+}
+
#define VGM(...) 0
#define VGM2(...) __VA_ARGS__
@@ -37,6 +42,7 @@ void test3(struct Point *p) {
// RUN: c-index-test -code-completion-at=%s:12:12 %s | FileCheck %s
// RUN: c-index-test -code-completion-at=%s:18:13 %s | FileCheck %s
// RUN: c-index-test -code-completion-at=%s:19:13 %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:24:9 %s | FileCheck %s
// CHECK: FieldDecl:{ResultType float}{TypedText x} (35)
// CHECK-NEXT: FieldDecl:{ResultType float}{TypedText y} (35)
// CHECK-NEXT: FieldDecl:{ResultType float}{TypedText z} (35)
@@ -46,7 +52,7 @@ void test3(struct Point *p) {
// With these, code-completion is unknown because the macro argument (and the
// completion point) is not expanded by the macro definition.
-// RUN: c-index-test -code-completion-at=%s:28:15 %s -DEOF_TEST1 | FileCheck %s -check-prefix=CHECK-EOF
-// RUN: c-index-test -code-completion-at=%s:32:20 %s -DEOF_TEST2 | FileCheck %s -check-prefix=CHECK-EOF
+// RUN: c-index-test -code-completion-at=%s:33:15 %s -DEOF_TEST1 | FileCheck %s -check-prefix=CHECK-EOF
+// RUN: c-index-test -code-completion-at=%s:37:20 %s -DEOF_TEST2 | FileCheck %s -check-prefix=CHECK-EOF
// CHECK-EOF: Completion contexts:
// CHECK-EOF: Unknown
More information about the cfe-commits
mailing list