[llvm-branch-commits] [clang-tools-extra] 2378a6e - [clangd] Fix null check in FindTarget.
Haojian Wu via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jun 10 01:31:29 PDT 2020
Author: Sam McCall
Date: 2020-06-10T10:28:44+02:00
New Revision: 2378a6e4f136d574c294da72f2dde0225ba05e89
URL: https://github.com/llvm/llvm-project/commit/2378a6e4f136d574c294da72f2dde0225ba05e89
DIFF: https://github.com/llvm/llvm-project/commit/2378a6e4f136d574c294da72f2dde0225ba05e89.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.
(cherry picked from commit 9a5c448a31bacc08e73fcae4636094f9b6e2be6a)
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 82a2e8c27d56..71bb9d3d5066 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -229,7 +229,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 llvm-branch-commits
mailing list