[clangd] Fix null check after D82739.
authorHaojian Wu <hokein.wu@gmail.com>
Tue, 21 Jul 2020 10:11:52 +0000 (12:11 +0200)
committerHaojian Wu <hokein.wu@gmail.com>
Tue, 21 Jul 2020 10:15:17 +0000 (12:15 +0200)
I hit the null-deference crash when opening ASTReaderDecl.cpp.

The BaseType can be a nullptr,

clang-tools-extra/clangd/FindTarget.cpp

index bc4002c..c6022b2 100644 (file)
@@ -175,6 +175,8 @@ std::vector<const NamedDecl *> resolveDependentExprToDecls(const Expr *E) {
     if (ME->isArrow()) {
       BaseType = getPointeeType(BaseType);
     }
+    if (!BaseType)
+      return {};
     if (const auto *BT = BaseType->getAs<BuiltinType>()) {
       // If BaseType is the type of a dependent expression, it's just
       // represented as BultinType::Dependent which gives us no information. We