[clang-tools-extra] 9a5c448 - [clangd] Fix null check in FindTarget.

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 28 17:03:14 PST 2020


Author: Sam McCall
Date: 2020-01-29T02:01:42+01:00
New Revision: 9a5c448a31bacc08e73fcae4636094f9b6e2be6a

URL: https://github.com/llvm/llvm-project/commit/9a5c448a31bacc08e73fcae4636094f9b6e2be6a
DIFF: https://github.com/llvm/llvm-project/commit/9a5c448a31bacc08e73fcae4636094f9b6e2be6a.diff

LOG: [clangd] Fix null check in FindTarget.

I've hit this stack trace a few times but don't have a good reproducer.
The code is unsafe by inspection, though.

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 239258685cde..13e4819bec9b 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -231,7 +231,7 @@ struct TargetFinder {
   }
 
   void add(const Decl *Dcl, RelSet Flags) {
-    const NamedDecl *D = llvm::dyn_cast<NamedDecl>(Dcl);
+    const NamedDecl *D = llvm::dyn_cast_or_null<NamedDecl>(Dcl);
     if (!D)
       return;
     debug(*D, Flags);


        


More information about the cfe-commits mailing list