Re: [clang-tools-extra] r352040 - [CodeComplete] [clangd] Fix crash on ValueDecl with a null type

2019-01-24 Thread Hans Wennborg via cfe-commits
Merged in r352118 (cfe) and r352120 (clang-tools-extra). Please let me
know if there are any follow-ups.

Thanks,
Hans

On Thu, Jan 24, 2019 at 5:11 AM Ilya Biryukov  wrote:
>
> +Hans Wennborg, could you please merge this fix into the release branch?
>
> On Thu, Jan 24, 2019 at 1:41 PM Ilya Biryukov via cfe-commits 
>  wrote:
>>
>> Author: ibiryukov
>> Date: Thu Jan 24 02:41:43 2019
>> New Revision: 352040
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=352040=rev
>> Log:
>> [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/trunk/clangd/ExpectedTypes.cpp
>> clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
>>
>> Modified: clang-tools-extra/trunk/clangd/ExpectedTypes.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ExpectedTypes.cpp?rev=352040=352039=352040=diff
>> ==
>> --- clang-tools-extra/trunk/clangd/ExpectedTypes.cpp (original)
>> +++ clang-tools-extra/trunk/clangd/ExpectedTypes.cpp Thu Jan 24 02:41:43 2019
>> @@ -35,8 +35,10 @@ static llvm::Optional
>>  typeOfCompletion(const CodeCompletionResult ) {
>>auto *VD = dyn_cast_or_null(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()) {
>>  // 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/trunk/unittests/clangd/CodeCompleteTests.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=352040=352039=352040=diff
>> ==
>> --- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original)
>> +++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Thu Jan 
>> 24 02:41:43 2019
>> @@ -2319,6 +2319,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
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
> --
> Regards,
> Ilya Biryukov
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang-tools-extra] r352040 - [CodeComplete] [clangd] Fix crash on ValueDecl with a null type

2019-01-24 Thread Ilya Biryukov via cfe-commits
+Hans Wennborg , could you please merge this fix into
the release branch?

On Thu, Jan 24, 2019 at 1:41 PM Ilya Biryukov via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ibiryukov
> Date: Thu Jan 24 02:41:43 2019
> New Revision: 352040
>
> URL: http://llvm.org/viewvc/llvm-project?rev=352040=rev
> Log:
> [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/trunk/clangd/ExpectedTypes.cpp
> clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
>
> Modified: clang-tools-extra/trunk/clangd/ExpectedTypes.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ExpectedTypes.cpp?rev=352040=352039=352040=diff
>
> ==
> --- clang-tools-extra/trunk/clangd/ExpectedTypes.cpp (original)
> +++ clang-tools-extra/trunk/clangd/ExpectedTypes.cpp Thu Jan 24 02:41:43
> 2019
> @@ -35,8 +35,10 @@ static llvm::Optional
>  typeOfCompletion(const CodeCompletionResult ) {
>auto *VD = dyn_cast_or_null(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()) {
>  // 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/trunk/unittests/clangd/CodeCompleteTests.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=352040=352039=352040=diff
>
> ==
> --- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
> (original)
> +++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Thu Jan
> 24 02:41:43 2019
> @@ -2319,6 +2319,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
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>


-- 
Regards,
Ilya Biryukov
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r352040 - [CodeComplete] [clangd] Fix crash on ValueDecl with a null type

2019-01-24 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Thu Jan 24 02:41:43 2019
New Revision: 352040

URL: http://llvm.org/viewvc/llvm-project?rev=352040=rev
Log:
[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/trunk/clangd/ExpectedTypes.cpp
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp

Modified: clang-tools-extra/trunk/clangd/ExpectedTypes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ExpectedTypes.cpp?rev=352040=352039=352040=diff
==
--- clang-tools-extra/trunk/clangd/ExpectedTypes.cpp (original)
+++ clang-tools-extra/trunk/clangd/ExpectedTypes.cpp Thu Jan 24 02:41:43 2019
@@ -35,8 +35,10 @@ static llvm::Optional
 typeOfCompletion(const CodeCompletionResult ) {
   auto *VD = dyn_cast_or_null(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()) {
 // 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/trunk/unittests/clangd/CodeCompleteTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=352040=352039=352040=diff
==
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Thu Jan 24 
02:41:43 2019
@@ -2319,6 +2319,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


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits