mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-20 12:05:48 -04:00
[clangd] Fix a crash in expected types
Reviewers: kadircet Reviewed By: kadircet Subscribers: merge_guards_bot, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70481
This commit is contained in:
parent
c1ed22954a
commit
b5135a86e0
@ -44,12 +44,10 @@ static const Type *toEquivClass(ASTContext &Ctx, QualType T) {
|
|||||||
static llvm::Optional<QualType>
|
static llvm::Optional<QualType>
|
||||||
typeOfCompletion(const CodeCompletionResult &R) {
|
typeOfCompletion(const CodeCompletionResult &R) {
|
||||||
const NamedDecl *D = R.Declaration;
|
const NamedDecl *D = R.Declaration;
|
||||||
if (!D)
|
|
||||||
return llvm::None;
|
|
||||||
// Templates do not have a type on their own, look at the templated decl.
|
// Templates do not have a type on their own, look at the templated decl.
|
||||||
if (auto *Template = dyn_cast<TemplateDecl>(D))
|
if (auto *Template = dyn_cast_or_null<TemplateDecl>(D))
|
||||||
D = Template->getTemplatedDecl();
|
D = Template->getTemplatedDecl();
|
||||||
auto *VD = dyn_cast<ValueDecl>(D);
|
auto *VD = dyn_cast_or_null<ValueDecl>(D);
|
||||||
if (!VD)
|
if (!VD)
|
||||||
return llvm::None; // We handle only variables and functions below.
|
return llvm::None; // We handle only variables and functions below.
|
||||||
auto T = VD->getType();
|
auto T = VD->getType();
|
||||||
|
@ -1030,6 +1030,16 @@ TEST(CompletionTest, DefaultArgs) {
|
|||||||
SnippetSuffix("(${1:int A})"))));
|
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,
|
SignatureHelp signatures(llvm::StringRef Text, Position Point,
|
||||||
std::vector<Symbol> IndexSymbols = {}) {
|
std::vector<Symbol> IndexSymbols = {}) {
|
||||||
std::unique_ptr<SymbolIndex> Index;
|
std::unique_ptr<SymbolIndex> Index;
|
||||||
|
Loading…
Reference in New Issue
Block a user