[clang-tools-extra] 3ad0181 - [clangd] Fix null check after D82739.

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 21 03:15:52 PDT 2020


Author: Haojian Wu
Date: 2020-07-21T12:15:17+02:00
New Revision: 3ad0181169dc8efcdec7166a76a4624d73bdad48

URL: https://github.com/llvm/llvm-project/commit/3ad0181169dc8efcdec7166a76a4624d73bdad48
DIFF: https://github.com/llvm/llvm-project/commit/3ad0181169dc8efcdec7166a76a4624d73bdad48.diff

LOG: [clangd] Fix null check after D82739.

I hit the null-deference crash when opening ASTReaderDecl.cpp.

The BaseType can be a nullptr,

Added: 
    

Modified: 
    clang-tools-extra/clangd/FindTarget.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/FindTarget.cpp b/clang-tools-extra/clangd/FindTarget.cpp
index bc4002c42623..c6022b2463e8 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -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


        


More information about the cfe-commits mailing list