From 982a87ab74d8d050ae56164fcead7cf19038b077 Mon Sep 17 00:00:00 2001 From: "Manna, Soumi" Date: Thu, 22 Jun 2023 12:52:25 -0700 Subject: [CLANG] Fix potential null pointer dereference bugs This patch uses castAs instead of getAs which will assert if the type doesn't match and adds nullptr check if needed. Also this patch improves the codes and passes I.getData() instead of doing a lookup in dumpVarDefinitionName() since we're iterating over the same map in LocalVariableMap::dumpContex(). Reviewed By: aaron.ballman, aaronpuchert Differential Revision: https://reviews.llvm.org/D153033 --- clang/lib/Analysis/ThreadSafety.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'clang/lib/Analysis/ThreadSafety.cpp') diff --git a/clang/lib/Analysis/ThreadSafety.cpp b/clang/lib/Analysis/ThreadSafety.cpp index ef7d2cf..087994e 100644 --- a/clang/lib/Analysis/ThreadSafety.cpp +++ b/clang/lib/Analysis/ThreadSafety.cpp @@ -502,9 +502,8 @@ public: for (Context::iterator I = C.begin(), E = C.end(); I != E; ++I) { const NamedDecl *D = I.getKey(); D->printName(llvm::errs()); - const unsigned *i = C.lookup(D); llvm::errs() << " -> "; - dumpVarDefinitionName(*i); + dumpVarDefinitionName(I.getData()); llvm::errs() << "\n"; } } -- cgit v1.1