[clang-tools-extra] 6de4577 - Revert "[clangd] Fix a crash in expected types"
Nico Weber via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 20 11:38:57 PST 2019
Author: Nico Weber
Date: 2019-11-20T14:38:35-05:00
New Revision: 6de45772e0910bf7fa626e5493a2798b071eb26c
URL: https://github.com/llvm/llvm-project/commit/6de45772e0910bf7fa626e5493a2798b071eb26c
DIFF: https://github.com/llvm/llvm-project/commit/6de45772e0910bf7fa626e5493a2798b071eb26c.diff
LOG: Revert "[clangd] Fix a crash in expected types"
This reverts commit b5135a86e04761577494c70e7c0057136cc90b5b.
Test fails on Windows.
Added:
Modified:
clang-tools-extra/clangd/ExpectedTypes.cpp
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/ExpectedTypes.cpp b/clang-tools-extra/clangd/ExpectedTypes.cpp
index a82a64cf14e2..3b0779ea66bc 100644
--- a/clang-tools-extra/clangd/ExpectedTypes.cpp
+++ b/clang-tools-extra/clangd/ExpectedTypes.cpp
@@ -44,10 +44,12 @@ static const Type *toEquivClass(ASTContext &Ctx, QualType T) {
static llvm::Optional<QualType>
typeOfCompletion(const CodeCompletionResult &R) {
const NamedDecl *D = R.Declaration;
+ if (!D)
+ return llvm::None;
// Templates do not have a type on their own, look at the templated decl.
- if (auto *Template = dyn_cast_or_null<TemplateDecl>(D))
+ if (auto *Template = dyn_cast<TemplateDecl>(D))
D = Template->getTemplatedDecl();
- auto *VD = dyn_cast_or_null<ValueDecl>(D);
+ auto *VD = dyn_cast<ValueDecl>(D);
if (!VD)
return llvm::None; // We handle only variables and functions below.
auto T = VD->getType();
diff --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index e69b2a6205f6..5b50b9fe9f8b 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1030,16 +1030,6 @@ TEST(CompletionTest, DefaultArgs) {
SnippetSuffix("(${1:int A})"))));
}
-TEST(CompletionTest, NoCrashWithTemplateParamsAndPreferredTypes) {
- auto Completions = completions(R"cpp(
-template <template <class> class TT> int foo() {
- int a = ^
-}
-)cpp")
- .Completions;
- EXPECT_THAT(Completions, Contains(Named("TT")));
-}
-
SignatureHelp signatures(llvm::StringRef Text, Position Point,
std::vector<Symbol> IndexSymbols = {}) {
std::unique_ptr<SymbolIndex> Index;
More information about the cfe-commits
mailing list