diff options
author | Manna, Soumi <soumi.manna@intel.com> | 2023-06-22 12:52:25 -0700 |
---|---|---|
committer | Manna, Soumi <soumi.manna@intel.com> | 2023-06-22 12:58:38 -0700 |
commit | 982a87ab74d8d050ae56164fcead7cf19038b077 (patch) | |
tree | 2a0180e3b0a0c805802772a2fb87a4be6e4e21df /clang/lib/Analysis/ThreadSafety.cpp | |
parent | 30ac031dd5731fab02739ebe8a7dc9a013d008dc (diff) | |
download | llvm-982a87ab74d8d050ae56164fcead7cf19038b077.zip llvm-982a87ab74d8d050ae56164fcead7cf19038b077.tar.gz llvm-982a87ab74d8d050ae56164fcead7cf19038b077.tar.bz2 |
[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
Diffstat (limited to 'clang/lib/Analysis/ThreadSafety.cpp')
-rw-r--r-- | clang/lib/Analysis/ThreadSafety.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
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"; } } |