[libclang] Fix crash when code-completing inside constructor initializer for a builtin type.

rdar://20149746

llvm-svn: 232145
This commit is contained in:
Argyrios Kyrtzidis 2015-03-13 07:39:30 +00:00
parent 41a185c521
commit ee1d76f361
2 changed files with 21 additions and 1 deletions

View File

@ -4035,12 +4035,18 @@ void Sema::CodeCompleteConstructor(Scope *S, QualType Type, SourceLocation Loc,
if (RequireCompleteType(Loc, Type, 0))
return;
CXXRecordDecl *RD = Type->getAsCXXRecordDecl();
if (!RD) {
CodeCompleteExpression(S, Type);
return;
}
// FIXME: Provide support for member initializers.
// FIXME: Provide support for variadic template constructors.
OverloadCandidateSet CandidateSet(Loc, OverloadCandidateSet::CSK_Normal);
for (auto C : LookupConstructors(Type->getAsCXXRecordDecl())) {
for (auto C : LookupConstructors(RD)) {
if (auto FD = dyn_cast<FunctionDecl>(C)) {
AddOverloadCandidate(FD, DeclAccessPair::make(FD, C->getAccess()),
Args, CandidateSet,

View File

@ -14,6 +14,8 @@ int main() {
S<int>(42, 42, 42,);
S<int> z(42, 42, 42,);
int(42);
}
// RUN: c-index-test -code-completion-at=%s:11:10 %s | FileCheck -check-prefix=CHECK-CC1 %s
@ -124,3 +126,15 @@ int main() {
// CHECK-CC9-NEXT: Class name
// CHECK-CC9-NEXT: Nested name specifier
// CHECK-CC9-NEXT: Objective-C interface
// RUN: c-index-test -code-completion-at=%s:18:7 %s | FileCheck -check-prefix=CHECK-CC10 %s
// CHECK-CC10: FunctionDecl:{ResultType int}{TypedText main}{LeftParen (}{RightParen )} (12)
// CHECK-CC10: Completion contexts:
// CHECK-CC10-NEXT: Any type
// CHECK-CC10-NEXT: Any value
// CHECK-CC10-NEXT: Enum tag
// CHECK-CC10-NEXT: Union tag
// CHECK-CC10-NEXT: Struct tag
// CHECK-CC10-NEXT: Class name
// CHECK-CC10-NEXT: Nested name specifier
// CHECK-CC10-NEXT: Objective-C interface