2016-06-17 05:40:06 +08:00
|
|
|
struct Base1 {
|
|
|
|
Base1() : {}
|
Fix heuristics skipping invalid ctor-initializers with C++11
Use better heuristics to detect if a '{' might be the start of the constructor body
or not. Especially when there is a completion token.
Fix the test 'test/CodeCompletion/ctor-initializer.cpp ' when clang defaults to c++11
The problem was is how we recover invalid code in the ctor-init part as we skip the
function body. In particular, we want to know if a '{' is the begining of the body.
In C++03, we always consider it as the beginng of the body. The problem was that in
C++11, it may be the start of an initializer, so we skip over it, causing further
parse errors later. (It is important that we are able to parse correctly the rest
of the class definition, to know what are the class member, for example)
This commit is improving the heuristics to decide if the '{' is starting a function
body. The rules are the following: If we are not in a template argument, and that the
previous tokens are not an identifier, or a >, then it is much more likely to be the
function body. We verify that further by checking the token after the matching '}'
The commit also fix the behavior when there is a code_completion token in the
ctor-initializers.
Differential Revision: https://reviews.llvm.org/D21502
llvm-svn: 285883
2016-11-03 15:36:17 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:2:12 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:2:12 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
|
2018-11-01 23:54:18 +08:00
|
|
|
// CHECK-CC1: COMPLETION: Pattern : member1(<#int#>)
|
|
|
|
// CHECK-CC1: COMPLETION: Pattern : member2(<#float#>)
|
2016-06-17 05:40:06 +08:00
|
|
|
|
|
|
|
Base1(int) : member1(123), {}
|
Fix heuristics skipping invalid ctor-initializers with C++11
Use better heuristics to detect if a '{' might be the start of the constructor body
or not. Especially when there is a completion token.
Fix the test 'test/CodeCompletion/ctor-initializer.cpp ' when clang defaults to c++11
The problem was is how we recover invalid code in the ctor-init part as we skip the
function body. In particular, we want to know if a '{' is the begining of the body.
In C++03, we always consider it as the beginng of the body. The problem was that in
C++11, it may be the start of an initializer, so we skip over it, causing further
parse errors later. (It is important that we are able to parse correctly the rest
of the class definition, to know what are the class member, for example)
This commit is improving the heuristics to decide if the '{' is starting a function
body. The rules are the following: If we are not in a template argument, and that the
previous tokens are not an identifier, or a >, then it is much more likely to be the
function body. We verify that further by checking the token after the matching '}'
The commit also fix the behavior when there is a code_completion token in the
ctor-initializers.
Differential Revision: https://reviews.llvm.org/D21502
llvm-svn: 285883
2016-11-03 15:36:17 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:8:30 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:8:30 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
|
2018-11-01 23:54:18 +08:00
|
|
|
// CHECK-CC2-NOT: COMPLETION: Pattern : member1(<#int#>)
|
|
|
|
// CHECK-CC2: COMPLETION: Pattern : member2(<#float#>)
|
2016-06-17 05:40:06 +08:00
|
|
|
|
|
|
|
int member1;
|
|
|
|
float member2;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Derived : public Base1 {
|
|
|
|
Derived();
|
|
|
|
Derived(int);
|
|
|
|
Derived(float);
|
|
|
|
int deriv1;
|
|
|
|
};
|
|
|
|
|
|
|
|
Derived::Derived() : {}
|
Fix heuristics skipping invalid ctor-initializers with C++11
Use better heuristics to detect if a '{' might be the start of the constructor body
or not. Especially when there is a completion token.
Fix the test 'test/CodeCompletion/ctor-initializer.cpp ' when clang defaults to c++11
The problem was is how we recover invalid code in the ctor-init part as we skip the
function body. In particular, we want to know if a '{' is the begining of the body.
In C++03, we always consider it as the beginng of the body. The problem was that in
C++11, it may be the start of an initializer, so we skip over it, causing further
parse errors later. (It is important that we are able to parse correctly the rest
of the class definition, to know what are the class member, for example)
This commit is improving the heuristics to decide if the '{' is starting a function
body. The rules are the following: If we are not in a template argument, and that the
previous tokens are not an identifier, or a >, then it is much more likely to be the
function body. We verify that further by checking the token after the matching '}'
The commit also fix the behavior when there is a code_completion token in the
ctor-initializers.
Differential Revision: https://reviews.llvm.org/D21502
llvm-svn: 285883
2016-11-03 15:36:17 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:25:22 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:25:22 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
|
2018-11-01 23:54:18 +08:00
|
|
|
// CHECK-CC3: COMPLETION: Pattern : Base1()
|
|
|
|
// CHECK-CC3: COMPLETION: Pattern : Base1(<#int#>)
|
|
|
|
// CHECK-CC3: COMPLETION: Pattern : deriv1(<#int#>)
|
2016-06-17 05:40:06 +08:00
|
|
|
|
|
|
|
Derived::Derived(int) try : {
|
|
|
|
} catch (...) {
|
|
|
|
}
|
2018-11-01 23:54:18 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:32:29 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:32:29 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
|
2016-06-17 05:40:06 +08:00
|
|
|
|
|
|
|
Derived::Derived(float) try : Base1(),
|
|
|
|
{
|
|
|
|
} catch (...) {
|
|
|
|
}
|
2018-11-01 23:54:18 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:38:39 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:38:39 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
|
|
|
|
// CHECK-CC5-NOT: COMPLETION: Pattern : Base1
|
|
|
|
// CHECK-CC5: COMPLETION: Pattern : deriv1(<#int#>)
|
Fix heuristics skipping invalid ctor-initializers with C++11
Use better heuristics to detect if a '{' might be the start of the constructor body
or not. Especially when there is a completion token.
Fix the test 'test/CodeCompletion/ctor-initializer.cpp ' when clang defaults to c++11
The problem was is how we recover invalid code in the ctor-init part as we skip the
function body. In particular, we want to know if a '{' is the begining of the body.
In C++03, we always consider it as the beginng of the body. The problem was that in
C++11, it may be the start of an initializer, so we skip over it, causing further
parse errors later. (It is important that we are able to parse correctly the rest
of the class definition, to know what are the class member, for example)
This commit is improving the heuristics to decide if the '{' is starting a function
body. The rules are the following: If we are not in a template argument, and that the
previous tokens are not an identifier, or a >, then it is much more likely to be the
function body. We verify that further by checking the token after the matching '}'
The commit also fix the behavior when there is a code_completion token in the
ctor-initializers.
Differential Revision: https://reviews.llvm.org/D21502
llvm-svn: 285883
2016-11-03 15:36:17 +08:00
|
|
|
|
|
|
|
struct A {
|
|
|
|
A() : , member2() {}
|
2018-11-01 23:54:18 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:48:9 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:48:9 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s
|
|
|
|
// CHECK-CC6: COMPLETION: Pattern : member1(<#int#>)
|
Fix heuristics skipping invalid ctor-initializers with C++11
Use better heuristics to detect if a '{' might be the start of the constructor body
or not. Especially when there is a completion token.
Fix the test 'test/CodeCompletion/ctor-initializer.cpp ' when clang defaults to c++11
The problem was is how we recover invalid code in the ctor-init part as we skip the
function body. In particular, we want to know if a '{' is the begining of the body.
In C++03, we always consider it as the beginng of the body. The problem was that in
C++11, it may be the start of an initializer, so we skip over it, causing further
parse errors later. (It is important that we are able to parse correctly the rest
of the class definition, to know what are the class member, for example)
This commit is improving the heuristics to decide if the '{' is starting a function
body. The rules are the following: If we are not in a template argument, and that the
previous tokens are not an identifier, or a >, then it is much more likely to be the
function body. We verify that further by checking the token after the matching '}'
The commit also fix the behavior when there is a code_completion token in the
ctor-initializers.
Differential Revision: https://reviews.llvm.org/D21502
llvm-svn: 285883
2016-11-03 15:36:17 +08:00
|
|
|
int member1, member2;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct B {
|
|
|
|
B() : member2() {}
|
2018-11-01 23:54:18 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:56:9 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:56:9 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
|
|
|
|
// CHECK-CC7: COMPLETION: Pattern : member1(<#int#>)
|
2018-04-25 23:13:34 +08:00
|
|
|
// Check in the middle and at the end of identifier too.
|
2018-11-01 23:54:18 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:56:13 %s -o - | FileCheck -check-prefix=CHECK-CC8 %s
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:56:16 %s -o - | FileCheck -check-prefix=CHECK-CC8 %s
|
|
|
|
// CHECK-CC8: COMPLETION: Pattern : member2(<#int#>)
|
Fix heuristics skipping invalid ctor-initializers with C++11
Use better heuristics to detect if a '{' might be the start of the constructor body
or not. Especially when there is a completion token.
Fix the test 'test/CodeCompletion/ctor-initializer.cpp ' when clang defaults to c++11
The problem was is how we recover invalid code in the ctor-init part as we skip the
function body. In particular, we want to know if a '{' is the begining of the body.
In C++03, we always consider it as the beginng of the body. The problem was that in
C++11, it may be the start of an initializer, so we skip over it, causing further
parse errors later. (It is important that we are able to parse correctly the rest
of the class definition, to know what are the class member, for example)
This commit is improving the heuristics to decide if the '{' is starting a function
body. The rules are the following: If we are not in a template argument, and that the
previous tokens are not an identifier, or a >, then it is much more likely to be the
function body. We verify that further by checking the token after the matching '}'
The commit also fix the behavior when there is a code_completion token in the
ctor-initializers.
Differential Revision: https://reviews.llvm.org/D21502
llvm-svn: 285883
2016-11-03 15:36:17 +08:00
|
|
|
int member1, member2;
|
|
|
|
};
|
2018-09-11 23:02:18 +08:00
|
|
|
|
|
|
|
struct Base2 {
|
|
|
|
Base2(int);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Composition1 {
|
2018-11-01 23:54:18 +08:00
|
|
|
Composition1() : b2_elem(2) {}
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:72:28 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:72:28 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
|
2018-09-11 23:02:18 +08:00
|
|
|
// CHECK-CC9: OVERLOAD: Base2(<#int#>)
|
|
|
|
// CHECK-CC9: OVERLOAD: Base2(<#const Base2 &#>)
|
|
|
|
// CHECK-CC9-NOT: OVERLOAD: Composition1
|
|
|
|
Composition1(Base2);
|
|
|
|
Base2 b2_elem;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Composition2 {
|
|
|
|
Composition2() : c1_elem(Base2(1)) {}
|
2018-11-01 23:54:18 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:83:34 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:83:34 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:83:35 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:83:35 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
|
2018-09-11 23:02:18 +08:00
|
|
|
Composition1 c1_elem;
|
|
|
|
};
|
2018-11-01 23:54:18 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:83:20 %s -o - | FileCheck -check-prefix=CHECK-CC10 %s
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:83:20 %s -o - | FileCheck -check-prefix=CHECK-CC10 %s
|
|
|
|
// CHECK-CC10: Pattern : c1_elem()
|
|
|
|
// CHECK-CC10: Pattern : c1_elem(<#Base2#>)
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
struct Y : T {};
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
struct X : Y<T> {
|
|
|
|
X() : Y<T>() {};
|
|
|
|
};
|
|
|
|
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:100:9 %s -o - | FileCheck -check-prefix=CHECK-CC11 %s
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:100:9 %s -o - | FileCheck -check-prefix=CHECK-CC11 %s
|
|
|
|
// CHECK-CC11: Pattern : Y<T>(<#Y<T>#>)
|