[llvm-branch-commits] [clang-tools-extra-branch] r352120 - Merging r352040:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jan 24 14:26:52 PST 2019
Author: hans
Date: Thu Jan 24 14:26:52 2019
New Revision: 352120
URL: http://llvm.org/viewvc/llvm-project?rev=352120&view=rev
Log:
Merging r352040:
------------------------------------------------------------------------
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
------------------------------------------------------------------------
Modified:
clang-tools-extra/branches/release_80/ (props changed)
clang-tools-extra/branches/release_80/clangd/ExpectedTypes.cpp
clang-tools-extra/branches/release_80/unittests/clangd/CodeCompleteTests.cpp
Propchange: clang-tools-extra/branches/release_80/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jan 24 14:26:52 2019
@@ -1 +1 @@
-/clang-tools-extra/trunk:351463,351466-351468,351531,351686,351738,351788
+/clang-tools-extra/trunk:351463,351466-351468,351531,351686,351738,351788,352040
Modified: clang-tools-extra/branches/release_80/clangd/ExpectedTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/branches/release_80/clangd/ExpectedTypes.cpp?rev=352120&r1=352119&r2=352120&view=diff
==============================================================================
--- clang-tools-extra/branches/release_80/clangd/ExpectedTypes.cpp (original)
+++ clang-tools-extra/branches/release_80/clangd/ExpectedTypes.cpp Thu Jan 24 14:26:52 2019
@@ -35,8 +35,10 @@ static llvm::Optional<QualType>
typeOfCompletion(const CodeCompletionResult &R) {
auto *VD = dyn_cast_or_null<ValueDecl>(R.Declaration);
if (!VD)
- return None; // We handle only variables and functions below.
+ return llvm::None; // We handle only variables and functions below.
auto T = VD->getType();
+ if (T.isNull())
+ return llvm::None;
if (auto FuncT = T->getAs<FunctionType>()) {
// Functions are a special case. They are completed as 'foo()' and we want
// to match their return type rather than the function type itself.
Modified: clang-tools-extra/branches/release_80/unittests/clangd/CodeCompleteTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/branches/release_80/unittests/clangd/CodeCompleteTests.cpp?rev=352120&r1=352119&r2=352120&view=diff
==============================================================================
--- clang-tools-extra/branches/release_80/unittests/clangd/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/branches/release_80/unittests/clangd/CodeCompleteTests.cpp Thu Jan 24 14:26:52 2019
@@ -2320,6 +2320,17 @@ TEST(CompletionTest, ObjectiveCMethodTwo
EXPECT_THAT(C, ElementsAre(SnippetSuffix("${1:(unsigned int)}")));
}
+TEST(CompletionTest, WorksWithNullType) {
+ auto R = completions(R"cpp(
+ int main() {
+ for (auto [loopVar] : y ) { // y has to be unresolved.
+ int z = loopV^;
+ }
+ }
+ )cpp");
+ EXPECT_THAT(R.Completions, ElementsAre(Named("loopVar")));
+}
+
} // namespace
} // namespace clangd
} // namespace clang
More information about the llvm-branch-commits
mailing list