Skip to content

Commit

Permalink
Merging r352040:
Browse files Browse the repository at this point in the history
------------------------------------------------------------------------
r352040 | ibiryukov | 2019-01-24 11:41:43 +0100 (Thu, 24 Jan 2019) | 9 lines

[CodeComplete] [clangd] Fix crash on ValueDecl with a null type

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D57093
------------------------------------------------------------------------

llvm-svn: 352118
  • Loading branch information
zmodem committed Jan 24, 2019
1 parent 22c2b2b commit a008fbe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clang/lib/Sema/SemaCodeComplete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,8 @@ QualType clang::getDeclUsageType(ASTContext &C, const NamedDecl *ND) {
T = Property->getType();
else if (const auto *Value = dyn_cast<ValueDecl>(ND))
T = Value->getType();
else

if (T.isNull())
return QualType();

// Dig through references, function pointers, and block pointers to
Expand Down
8 changes: 8 additions & 0 deletions clang/test/CodeCompletion/crash-null-type.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
void test() {
for (auto [loopVar] : y) { // y has to be unresolved
loopVa
}
}
// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:3:11 %s -o - \
// RUN: | FileCheck %s
// CHECK: COMPLETION: loopVar

0 comments on commit a008fbe

Please sign in to comment.