Skip to content

Commit

Permalink
Revert "[clangd] Fix a crash in expected types"
Browse files Browse the repository at this point in the history
This reverts commit b5135a8.
Test fails on Windows.
  • Loading branch information
nico committed Nov 20, 2019
1 parent f751a79 commit 6de4577
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
6 changes: 4 additions & 2 deletions clang-tools-extra/clangd/ExpectedTypes.cpp
Expand Up @@ -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();
Expand Down
10 changes: 0 additions & 10 deletions clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit 6de4577

Please sign in to comment.