[clang-tools-extra] f7e9d5b - [clangd] Fix an inlay-hint crash on a null deduced type.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Sun Jan 8 06:48:18 PST 2023
Author: Haojian Wu
Date: 2023-01-08T15:48:04+01:00
New Revision: f7e9d5b43e72439f5841f9ff5ef690a625fd312c
URL: https://github.com/llvm/llvm-project/commit/f7e9d5b43e72439f5841f9ff5ef690a625fd312c
DIFF: https://github.com/llvm/llvm-project/commit/f7e9d5b43e72439f5841f9ff5ef690a625fd312c.diff
LOG: [clangd] Fix an inlay-hint crash on a null deduced type.
Added:
Modified:
clang-tools-extra/clangd/InlayHints.cpp
clang-tools-extra/clangd/unittests/InlayHintTests.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/InlayHints.cpp b/clang-tools-extra/clangd/InlayHints.cpp
index 30c7c05e3c02..f4e38aeb653e 100644
--- a/clang-tools-extra/clangd/InlayHints.cpp
+++ b/clang-tools-extra/clangd/InlayHints.cpp
@@ -671,7 +671,8 @@ class InlayHintVisitor : public RecursiveASTVisitor<InlayHintVisitor> {
if (QT->isDecltypeType())
return true;
if (const AutoType *AT = QT->getContainedAutoType())
- if (AT->getDeducedType()->isDecltypeType())
+ if (!AT->getDeducedType().isNull() &&
+ AT->getDeducedType()->isDecltypeType())
return true;
return false;
}
diff --git a/clang-tools-extra/clangd/unittests/InlayHintTests.cpp b/clang-tools-extra/clangd/unittests/InlayHintTests.cpp
index 53621f97a604..06f2c055a4d3 100644
--- a/clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ b/clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -1378,11 +1378,16 @@ TEST(TypeHints, Decltype) {
using G = Foo<$g[[decltype(0)]], float>;
auto $h[[h]] = $i[[decltype(0)]]{};
+
+ // No crash
+ /* error-ok */
+ auto $j[[s]];
)cpp",
ExpectedHint{": int", "a"}, ExpectedHint{": int", "b"},
ExpectedHint{": int", "c"}, ExpectedHint{": int", "e"},
ExpectedHint{": int", "f"}, ExpectedHint{": int", "g"},
- ExpectedHint{": int", "h"}, ExpectedHint{": int", "i"});
+ ExpectedHint{": int", "h"}, ExpectedHint{": int", "i"},
+ ExpectedHint{": auto", "j"});
}
TEST(DesignatorHints, Basic) {
More information about the cfe-commits
mailing list