[Lldb-commits] [lldb] c934913 - [lldb] CxxModuleHandler - use cast<> instead of dyn_cast<> to avoid dereference of nullptr

Simon Pilgrim via lldb-commits lldb-commits at lists.llvm.org
Sun Jan 23 07:14:39 PST 2022


Author: Simon Pilgrim
Date: 2022-01-23T15:10:33Z
New Revision: c93491352cf3146559de7755283f0dd259392126

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

LOG: [lldb] CxxModuleHandler - use cast<> instead of dyn_cast<> to avoid dereference of nullptr

The pointer is dereferenced immediately, so assert the cast is correct instead of returning nullptr

Added: 
    

Modified: 
    lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
index 74dd04600b4be..fecffd1183f89 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
@@ -138,7 +138,7 @@ getEqualLocalDeclContext(Sema &sema, DeclContext *foreign_ctxt) {
 
   // We currently only support building namespaces.
   if (foreign_ctxt->isNamespace()) {
-    NamedDecl *ns = llvm::dyn_cast<NamedDecl>(foreign_ctxt);
+    NamedDecl *ns = llvm::cast<NamedDecl>(foreign_ctxt);
     llvm::StringRef ns_name = ns->getName();
 
     auto lookup_result = emulateLookupInCtxt(sema, ns_name, *parent);


        


More information about the lldb-commits mailing list